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
354d033e
Unverified
Commit
354d033e
authored
Dec 18, 2023
by
Joel
Committed by
GitHub
Dec 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: not owner can not pay (#1772)
parent
ebc2cdad
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
8 deletions
+24
-8
index.tsx
web/app/components/billing/billing-page/index.tsx
+4
-4
index.tsx
web/app/components/billing/pricing/index.tsx
+7
-1
plan-item.tsx
web/app/components/billing/pricing/plan-item.tsx
+6
-1
index.tsx
...ents/header/account-dropdown/workplace-selector/index.tsx
+2
-1
app-context.tsx
web/context/app-context.tsx
+3
-1
billing.en.ts
web/i18n/lang/billing.en.ts
+1
-0
billing.zh.ts
web/i18n/lang/billing.zh.ts
+1
-0
No files found.
web/app/components/billing/billing-page/index.tsx
View file @
354d033e
...
...
@@ -11,23 +11,23 @@ import { useProviderContext } from '@/context/provider-context'
const
Billing
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
isCurrentWorkspace
Manag
er
}
=
useAppContext
()
const
{
isCurrentWorkspace
Own
er
}
=
useAppContext
()
const
[
billingUrl
,
setBillingUrl
]
=
React
.
useState
(
''
)
const
{
enableBilling
}
=
useProviderContext
()
useEffect
(()
=>
{
if
(
!
enableBilling
&&
!
isCurrentWorkspaceManag
er
)
if
(
!
enableBilling
||
!
isCurrentWorkspaceOwn
er
)
return
(
async
()
=>
{
const
{
url
}
=
await
fetchBillingUrl
()
setBillingUrl
(
url
)
})()
},
[
isCurrentWorkspace
Manag
er
])
},
[
isCurrentWorkspace
Own
er
])
return
(
<
div
>
<
PlanComp
loc=
{
'billing-page'
}
/>
{
enableBilling
&&
isCurrentWorkspace
Manag
er
&&
billingUrl
&&
(
{
enableBilling
&&
isCurrentWorkspace
Own
er
&&
billingUrl
&&
(
<
a
className=
'mt-5 flex px-6 justify-between h-12 items-center bg-gray-50 rounded-xl cursor-pointer'
href=
{
billingUrl
}
target=
'_blank'
>
<
div
className=
'flex items-center'
>
<
ReceiptList
className=
'w-4 h-4 text-gray-700'
/>
...
...
web/app/components/billing/pricing/index.tsx
View file @
354d033e
...
...
@@ -9,6 +9,7 @@ import PlanItem from './plan-item'
import
{
XClose
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
useProviderContext
}
from
'@/context/provider-context'
import
GridMask
from
'@/app/components/base/grid-mask'
import
{
useAppContext
}
from
'@/context/app-context'
type
Props
=
{
onCancel
:
()
=>
void
...
...
@@ -19,7 +20,8 @@ const Pricing: FC<Props> = ({
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
plan
}
=
useProviderContext
()
const
{
isCurrentWorkspaceOwner
}
=
useAppContext
()
const
canPay
=
isCurrentWorkspaceOwner
const
[
planRange
,
setPlanRange
]
=
React
.
useState
<
PlanRange
>
(
PlanRange
.
monthly
)
return
createPortal
(
...
...
@@ -41,21 +43,25 @@ const Pricing: FC<Props> = ({
currentPlan=
{
plan
.
type
}
plan=
{
Plan
.
sandbox
}
planRange=
{
planRange
}
canPay=
{
canPay
}
/>
<
PlanItem
currentPlan=
{
plan
.
type
}
plan=
{
Plan
.
professional
}
planRange=
{
planRange
}
canPay=
{
canPay
}
/>
<
PlanItem
currentPlan=
{
plan
.
type
}
plan=
{
Plan
.
team
}
planRange=
{
planRange
}
canPay=
{
canPay
}
/>
<
PlanItem
currentPlan=
{
plan
.
type
}
plan=
{
Plan
.
enterprise
}
planRange=
{
planRange
}
canPay=
{
canPay
}
/>
</
div
>
</
div
>
...
...
web/app/components/billing/pricing/plan-item.tsx
View file @
354d033e
...
...
@@ -16,6 +16,7 @@ type Props = {
currentPlan
:
Plan
plan
:
Plan
planRange
:
PlanRange
canPay
:
boolean
}
const
KeyValue
=
({
label
,
value
,
tooltip
}:
{
label
:
string
;
value
:
string
|
number
|
JSX
.
Element
;
tooltip
?:
string
})
=>
{
...
...
@@ -65,6 +66,7 @@ const PlanItem: FC<Props> = ({
plan
,
currentPlan
,
planRange
,
canPay
,
})
=>
{
const
{
t
}
=
useTranslation
()
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
...
...
@@ -75,10 +77,13 @@ const PlanItem: FC<Props> = ({
const
planInfo
=
ALL_PLANS
[
plan
]
const
isYear
=
planRange
===
PlanRange
.
yearly
const
isCurrent
=
plan
===
currentPlan
const
isPlanDisabled
=
planInfo
.
level
<=
ALL_PLANS
[
currentPlan
].
level
const
isPlanDisabled
=
planInfo
.
level
<=
ALL_PLANS
[
currentPlan
].
level
||
(
!
canPay
&&
plan
!==
Plan
.
enterprise
)
const
{
isCurrentWorkspaceManager
}
=
useAppContext
()
const
btnText
=
(()
=>
{
if
(
!
canPay
&&
plan
!==
Plan
.
enterprise
)
return
t
(
'billing.plansCommon.contractOwner'
)
if
(
isCurrent
)
return
t
(
'billing.plansCommon.currentPlan'
)
...
...
web/app/components/header/account-dropdown/workplace-selector/index.tsx
View file @
354d033e
...
...
@@ -31,7 +31,8 @@ const WorkplaceSelector = () => {
const
handleSwitchWorkspace
=
async
(
tenant_id
:
string
)
=>
{
try
{
if
(
currentWorkspace
?.
id
===
tenant_id
)
return
if
(
currentWorkspace
?.
id
===
tenant_id
)
return
await
switchWorkspace
({
url
:
'/workspaces/switch'
,
body
:
{
tenant_id
}
})
notify
({
type
:
'success'
,
message
:
t
(
'common.actionMsg.modifiedSuccessfully'
)
})
location
.
assign
(
`
${
location
.
origin
}
`
)
...
...
web/context/app-context.tsx
View file @
354d033e
...
...
@@ -18,6 +18,7 @@ export type AppContextValue = {
mutateUserProfile
:
VoidFunction
currentWorkspace
:
ICurrentWorkspace
isCurrentWorkspaceManager
:
boolean
isCurrentWorkspaceOwner
:
boolean
mutateCurrentWorkspace
:
VoidFunction
pageContainerRef
:
React
.
RefObject
<
HTMLDivElement
>
langeniusVersionInfo
:
LangGeniusVersionResponse
...
...
@@ -83,7 +84,7 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
const
[
langeniusVersionInfo
,
setLangeniusVersionInfo
]
=
useState
<
LangGeniusVersionResponse
>
(
initialLangeniusVersionInfo
)
const
[
currentWorkspace
,
setCurrentWorkspace
]
=
useState
<
ICurrentWorkspace
>
(
initialWorkspaceInfo
)
const
isCurrentWorkspaceManager
=
useMemo
(()
=>
[
'owner'
,
'admin'
].
includes
(
currentWorkspace
.
role
),
[
currentWorkspace
.
role
])
const
isCurrentWorkspaceOwner
=
useMemo
(()
=>
currentWorkspace
.
role
===
'owner'
,
[
currentWorkspace
.
role
])
const
updateUserProfileAndVersion
=
useCallback
(
async
()
=>
{
if
(
userProfileResponse
&&
!
userProfileResponse
.
bodyUsed
)
{
const
result
=
await
userProfileResponse
.
json
()
...
...
@@ -118,6 +119,7 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
useSelector
,
currentWorkspace
,
isCurrentWorkspaceManager
,
isCurrentWorkspaceOwner
,
mutateCurrentWorkspace
,
}
}
>
<
div
className=
'flex flex-col h-full overflow-y-auto'
>
...
...
web/i18n/lang/billing.en.ts
View file @
354d033e
...
...
@@ -20,6 +20,7 @@ const translation = {
save
:
'Save '
,
free
:
'Free'
,
currentPlan
:
'Current Plan'
,
contractOwner
:
'Contact your workspace owner'
,
startForFree
:
'Start for free'
,
getStartedWith
:
'Get started with '
,
contactSales
:
'Contact Sales'
,
...
...
web/i18n/lang/billing.zh.ts
View file @
354d033e
...
...
@@ -19,6 +19,7 @@ const translation = {
year
:
'年'
,
save
:
'节省'
,
currentPlan
:
'当前计划'
,
contractOwner
:
'联系您的工作区所有者'
,
free
:
'免费'
,
startForFree
:
'免费开始'
,
getStartedWith
:
'开始使用'
,
...
...
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