Files
dify/web/features/network-access/permissions.ts
2a6764edc5 feat: add reusable network access group APIs (#41025)
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>
2026-10-20 05:52:18 +00:00

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'
})