mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
Merge 179bd01f65
into 2fed55ae6b
This commit is contained in:
commit
9910bdd604
|
@ -34,13 +34,12 @@ const MembersPage = () => {
|
||||||
}
|
}
|
||||||
const { locale } = useContext(I18n)
|
const { locale } = useContext(I18n)
|
||||||
|
|
||||||
const { userProfile, currentWorkspace, isCurrentWorkspaceManager } = useAppContext()
|
const { userProfile, currentWorkspace, isCurrentWorkspaceOwner, isCurrentWorkspaceManager } = useAppContext()
|
||||||
const { data, mutate } = useSWR({ url: '/workspaces/current/members' }, fetchMembers)
|
const { data, mutate } = useSWR({ url: '/workspaces/current/members' }, fetchMembers)
|
||||||
const [inviteModalVisible, setInviteModalVisible] = useState(false)
|
const [inviteModalVisible, setInviteModalVisible] = useState(false)
|
||||||
const [invitationResults, setInvitationResults] = useState<InvitationResult[]>([])
|
const [invitationResults, setInvitationResults] = useState<InvitationResult[]>([])
|
||||||
const [invitedModalVisible, setInvitedModalVisible] = useState(false)
|
const [invitedModalVisible, setInvitedModalVisible] = useState(false)
|
||||||
const accounts = data?.accounts || []
|
const accounts = data?.accounts || []
|
||||||
const owner = accounts.filter(account => account.role === 'owner')?.[0]?.email === userProfile.email
|
|
||||||
const { plan, enableBilling } = useProviderContext()
|
const { plan, enableBilling } = useProviderContext()
|
||||||
const isNotUnlimitedMemberPlan = enableBilling && plan.type !== Plan.team && plan.type !== Plan.enterprise
|
const isNotUnlimitedMemberPlan = enableBilling && plan.type !== Plan.team && plan.type !== Plan.enterprise
|
||||||
const isMemberFull = enableBilling && isNotUnlimitedMemberPlan && accounts.length >= plan.total.teamMembers
|
const isMemberFull = enableBilling && isNotUnlimitedMemberPlan && accounts.length >= plan.total.teamMembers
|
||||||
|
@ -109,8 +108,8 @@ const MembersPage = () => {
|
||||||
<div className='shrink-0 flex items-center w-[104px] py-2 text-[13px] text-gray-700'>{dayjs(Number((account.last_active_at || account.created_at)) * 1000).locale(locale === 'zh-Hans' ? 'zh-cn' : 'en').fromNow()}</div>
|
<div className='shrink-0 flex items-center w-[104px] py-2 text-[13px] text-gray-700'>{dayjs(Number((account.last_active_at || account.created_at)) * 1000).locale(locale === 'zh-Hans' ? 'zh-cn' : 'en').fromNow()}</div>
|
||||||
<div className='shrink-0 w-[96px] flex items-center'>
|
<div className='shrink-0 w-[96px] flex items-center'>
|
||||||
{
|
{
|
||||||
(owner && account.role !== 'owner')
|
((isCurrentWorkspaceOwner && account.role !== 'owner') || (isCurrentWorkspaceManager && !['owner', 'admin'].includes(account.role)))
|
||||||
? <Operation member={account} onOperate={mutate} />
|
? <Operation member={account} operatorRole={currentWorkspace.role} onOperate={mutate} />
|
||||||
: <div className='px-3 text-[13px] text-gray-700'>{RoleMap[account.role] || RoleMap.normal}</div>
|
: <div className='px-3 text-[13px] text-gray-700'>{RoleMap[account.role] || RoleMap.normal}</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,11 +26,13 @@ const itemDescClassName = `
|
||||||
|
|
||||||
type IOperationProps = {
|
type IOperationProps = {
|
||||||
member: Member
|
member: Member
|
||||||
|
operatorRole: string
|
||||||
onOperate: () => void
|
onOperate: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const Operation = ({
|
const Operation = ({
|
||||||
member,
|
member,
|
||||||
|
operatorRole,
|
||||||
onOperate,
|
onOperate,
|
||||||
}: IOperationProps) => {
|
}: IOperationProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
@ -43,11 +45,20 @@ const Operation = ({
|
||||||
dataset_operator: t('common.members.datasetOperator'),
|
dataset_operator: t('common.members.datasetOperator'),
|
||||||
}
|
}
|
||||||
const roleList = useMemo(() => {
|
const roleList = useMemo(() => {
|
||||||
return [
|
if (operatorRole === 'owner') {
|
||||||
...['admin', 'editor', 'normal'],
|
return [
|
||||||
...(datasetOperatorEnabled ? ['dataset_operator'] : []),
|
...['admin', 'editor', 'normal'],
|
||||||
]
|
...(datasetOperatorEnabled ? ['dataset_operator'] : []),
|
||||||
}, [datasetOperatorEnabled])
|
]
|
||||||
|
}
|
||||||
|
if (operatorRole === 'admin') {
|
||||||
|
return [
|
||||||
|
...['editor', 'normal'],
|
||||||
|
...(datasetOperatorEnabled ? ['dataset_operator'] : []),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}, [operatorRole, datasetOperatorEnabled])
|
||||||
const { notify } = useContext(ToastContext)
|
const { notify } = useContext(ToastContext)
|
||||||
const toHump = (name: string) => name.replace(/_(\w)/g, (all, letter) => letter.toUpperCase())
|
const toHump = (name: string) => name.replace(/_(\w)/g, (all, letter) => letter.toUpperCase())
|
||||||
const handleDeleteMemberOrCancelInvitation = async () => {
|
const handleDeleteMemberOrCancelInvitation = async () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user