mirror of
https://github.com/langgenius/dify.git
synced 2026-11-13 23:06:40 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
'use client'
|
|
|
|
import { atom } from 'jotai'
|
|
import { currentWorkspaceAtom, currentWorkspaceLoadingAtom } from '@/context/workspace-state'
|
|
import { deploymentEditionAtom } from '@/features/system-features/state'
|
|
|
|
export const canReadNetworkAccessAtom = atom((get) => {
|
|
if (get(currentWorkspaceLoadingAtom) || get(deploymentEditionAtom) !== 'CLOUD') return false
|
|
const { id, role } = get(currentWorkspaceAtom)
|
|
return Boolean(id) && (role === 'owner' || role === 'admin' || role === 'editor')
|
|
})
|
|
|
|
export const canViewNetworkAccessStatusAtom = atom((get) => {
|
|
if (get(currentWorkspaceLoadingAtom) || get(deploymentEditionAtom) !== 'CLOUD') return false
|
|
const { id, role } = get(currentWorkspaceAtom)
|
|
return (
|
|
Boolean(id) && (role === 'owner' || role === 'admin' || role === 'editor' || role === 'normal')
|
|
)
|
|
})
|
|
|
|
export const canManageNetworkAccessPoliciesAtom = atom((get) => {
|
|
if (!get(canReadNetworkAccessAtom)) return false
|
|
const { role } = get(currentWorkspaceAtom)
|
|
return role === 'owner' || role === 'admin'
|
|
})
|