Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
d4262ecc
Unverified
Commit
d4262ecc
authored
Jan 26, 2024
by
Joel
Committed by
GitHub
Jan 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove and create app not reload plan (#2220)
parent
8be7d8a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
37 deletions
+51
-37
AppCard.tsx
web/app/(commonLayout)/apps/AppCard.tsx
+3
-0
NewAppCard.tsx
web/app/(commonLayout)/apps/NewAppCard.tsx
+9
-1
provider-context.tsx
web/context/provider-context.tsx
+39
-36
No files found.
web/app/(commonLayout)/apps/AppCard.tsx
View file @
d4262ecc
...
@@ -20,6 +20,7 @@ import type { HtmlContentProps } from '@/app/components/base/popover'
...
@@ -20,6 +20,7 @@ import type { HtmlContentProps } from '@/app/components/base/popover'
import
CustomPopover
from
'@/app/components/base/popover'
import
CustomPopover
from
'@/app/components/base/popover'
import
Divider
from
'@/app/components/base/divider'
import
Divider
from
'@/app/components/base/divider'
import
{
asyncRunSafe
}
from
'@/utils'
import
{
asyncRunSafe
}
from
'@/utils'
import
{
useProviderContext
}
from
'@/context/provider-context'
export
type
AppCardProps
=
{
export
type
AppCardProps
=
{
app
:
App
app
:
App
...
@@ -30,6 +31,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
...
@@ -30,6 +31,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
{
onPlanInfoChanged
}
=
useProviderContext
()
const
{
push
}
=
useRouter
()
const
{
push
}
=
useRouter
()
const
mutateApps
=
useContextSelector
(
const
mutateApps
=
useContextSelector
(
...
@@ -51,6 +53,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
...
@@ -51,6 +53,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
if
(
onRefresh
)
if
(
onRefresh
)
onRefresh
()
onRefresh
()
mutateApps
()
mutateApps
()
onPlanInfoChanged
()
}
}
catch
(
e
:
any
)
{
catch
(
e
:
any
)
{
notify
({
notify
({
...
...
web/app/(commonLayout)/apps/NewAppCard.tsx
View file @
d4262ecc
...
@@ -5,6 +5,7 @@ import classNames from 'classnames'
...
@@ -5,6 +5,7 @@ import classNames from 'classnames'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
style
from
'../list.module.css'
import
style
from
'../list.module.css'
import
NewAppDialog
from
'./NewAppDialog'
import
NewAppDialog
from
'./NewAppDialog'
import
{
useProviderContext
}
from
'@/context/provider-context'
export
type
CreateAppCardProps
=
{
export
type
CreateAppCardProps
=
{
onSuccess
?:
()
=>
void
onSuccess
?:
()
=>
void
...
@@ -12,6 +13,8 @@ export type CreateAppCardProps = {
...
@@ -12,6 +13,8 @@ export type CreateAppCardProps = {
const
CreateAppCard
=
forwardRef
<
HTMLAnchorElement
,
CreateAppCardProps
>
(({
onSuccess
},
ref
)
=>
{
const
CreateAppCard
=
forwardRef
<
HTMLAnchorElement
,
CreateAppCardProps
>
(({
onSuccess
},
ref
)
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
onPlanInfoChanged
}
=
useProviderContext
()
const
[
showNewAppDialog
,
setShowNewAppDialog
]
=
useState
(
false
)
const
[
showNewAppDialog
,
setShowNewAppDialog
]
=
useState
(
false
)
return
(
return
(
<
a
ref=
{
ref
}
className=
{
classNames
(
style
.
listItem
,
style
.
newItemCard
)
}
onClick=
{
()
=>
setShowNewAppDialog
(
true
)
}
>
<
a
ref=
{
ref
}
className=
{
classNames
(
style
.
listItem
,
style
.
newItemCard
)
}
onClick=
{
()
=>
setShowNewAppDialog
(
true
)
}
>
...
@@ -24,7 +27,12 @@ const CreateAppCard = forwardRef<HTMLAnchorElement, CreateAppCardProps>(({ onSuc
...
@@ -24,7 +27,12 @@ const CreateAppCard = forwardRef<HTMLAnchorElement, CreateAppCardProps>(({ onSuc
</
div
>
</
div
>
</
div
>
</
div
>
{
/* <div className='text-xs text-gray-500'>{t('app.createFromConfigFile')}</div> */
}
{
/* <div className='text-xs text-gray-500'>{t('app.createFromConfigFile')}</div> */
}
<
NewAppDialog
show=
{
showNewAppDialog
}
onSuccess=
{
onSuccess
}
onClose=
{
()
=>
setShowNewAppDialog
(
false
)
}
/>
<
NewAppDialog
show=
{
showNewAppDialog
}
onSuccess=
{
()
=>
{
onPlanInfoChanged
()
if
(
onSuccess
)
onSuccess
()
}
}
onClose=
{
()
=>
setShowNewAppDialog
(
false
)
}
/>
</
a
>
</
a
>
)
)
})
})
...
...
web/context/provider-context.tsx
View file @
d4262ecc
...
@@ -34,32 +34,34 @@ const ProviderContext = createContext<{
...
@@ -34,32 +34,34 @@ const ProviderContext = createContext<{
}
}
isFetchedPlan
:
boolean
isFetchedPlan
:
boolean
enableBilling
:
boolean
enableBilling
:
boolean
onPlanInfoChanged
:
()
=>
void
enableReplaceWebAppLogo
:
boolean
enableReplaceWebAppLogo
:
boolean
}
>
({
}
>
({
modelProviders
:
[],
modelProviders
:
[],
textGenerationModelList
:
[],
textGenerationModelList
:
[],
agentThoughtModelList
:
[],
agentThoughtModelList
:
[],
supportRetrievalMethods
:
[],
supportRetrievalMethods
:
[],
hasSettedApiKey
:
true
,
hasSettedApiKey
:
true
,
plan
:
{
plan
:
{
type
:
Plan
.
sandbox
,
type
:
Plan
.
sandbox
,
usage
:
{
usage
:
{
vectorSpace
:
32
,
vectorSpace
:
32
,
buildApps
:
12
,
buildApps
:
12
,
teamMembers
:
1
,
teamMembers
:
1
,
annotatedResponse
:
1
,
annotatedResponse
:
1
,
},
},
total
:
{
total
:
{
vectorSpace
:
200
,
vectorSpace
:
200
,
buildApps
:
50
,
buildApps
:
50
,
teamMembers
:
1
,
teamMembers
:
1
,
annotatedResponse
:
10
,
annotatedResponse
:
10
,
},
},
},
},
isFetchedPlan
:
false
,
isFetchedPlan
:
false
,
enableBilling
:
false
,
enableBilling
:
false
,
enableReplaceWebAppLogo
:
false
,
onPlanInfoChanged
:
()
=>
{
},
})
enableReplaceWebAppLogo
:
false
,
})
export
const
useProviderContext
=
()
=>
useContext
(
ProviderContext
)
export
const
useProviderContext
=
()
=>
useContext
(
ProviderContext
)
...
@@ -98,7 +100,6 @@ export const ProviderContextProvider = ({
...
@@ -98,7 +100,6 @@ export const ProviderContextProvider = ({
const
[
isFetchedPlan
,
setIsFetchedPlan
]
=
useState
(
false
)
const
[
isFetchedPlan
,
setIsFetchedPlan
]
=
useState
(
false
)
const
[
enableBilling
,
setEnableBilling
]
=
useState
(
true
)
const
[
enableBilling
,
setEnableBilling
]
=
useState
(
true
)
const
[
enableReplaceWebAppLogo
,
setEnableReplaceWebAppLogo
]
=
useState
(
false
)
const
[
enableReplaceWebAppLogo
,
setEnableReplaceWebAppLogo
]
=
useState
(
false
)
const
handleOperateUtm
=
()
=>
{
const
handleOperateUtm
=
()
=>
{
let
utm
let
utm
try
{
try
{
...
@@ -116,18 +117,19 @@ export const ProviderContextProvider = ({
...
@@ -116,18 +117,19 @@ export const ProviderContextProvider = ({
if
(
utm
.
utm_source
||
utm
.
utm_medium
||
utm
.
utm_campaign
||
utm
.
utm_content
||
utm
.
utm_term
)
if
(
utm
.
utm_source
||
utm
.
utm_medium
||
utm
.
utm_campaign
||
utm
.
utm_content
||
utm
.
utm_term
)
operationUtm
({
url
:
'/operation/utm'
,
body
:
utm
})
operationUtm
({
url
:
'/operation/utm'
,
body
:
utm
})
}
}
const
fetchPlan
=
async
()
=>
{
const
data
=
await
fetchCurrentPlanInfo
()
const
enabled
=
data
.
billing
.
enabled
setEnableBilling
(
enabled
)
setEnableReplaceWebAppLogo
(
data
.
can_replace_logo
)
if
(
enabled
)
{
setPlan
(
parseCurrentPlan
(
data
))
handleOperateUtm
()
setIsFetchedPlan
(
true
)
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
fetchPlan
()
const
data
=
await
fetchCurrentPlanInfo
()
const
enabled
=
data
.
billing
.
enabled
setEnableBilling
(
enabled
)
setEnableReplaceWebAppLogo
(
data
.
can_replace_logo
)
if
(
enabled
)
{
setPlan
(
parseCurrentPlan
(
data
))
handleOperateUtm
()
setIsFetchedPlan
(
true
)
}
})()
},
[])
},
[])
return
(
return
(
...
@@ -140,6 +142,7 @@ export const ProviderContextProvider = ({
...
@@ -140,6 +142,7 @@ export const ProviderContextProvider = ({
plan
,
plan
,
isFetchedPlan
,
isFetchedPlan
,
enableBilling
,
enableBilling
,
onPlanInfoChanged
:
fetchPlan
,
enableReplaceWebAppLogo
,
enableReplaceWebAppLogo
,
}
}
>
}
}
>
{
children
}
{
children
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment