Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.0 KB
Raw Blame
'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'
})