mirror of
https://github.com/langgenius/dify.git
synced 2026-11-14 07:11:06 +08:00
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: zhaohao1004 <zhaohao1004@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: FFXN <lizy@dify.ai>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
'use client'
|
|
|
|
import { atom } from 'jotai'
|
|
import { atomWithQuery } from 'jotai-tanstack-query'
|
|
import { consoleQuery } from '@/service/console'
|
|
import { emptyWorkspacePermissionKeys } from './app-context-normalizers'
|
|
|
|
const workspacePermissionKeysQueryAtom = atomWithQuery(() => {
|
|
return consoleQuery.workspaces.current.rbac.myPermissions.get.queryOptions()
|
|
})
|
|
|
|
export const workspacePermissionKeysAtom = atom((get) => {
|
|
return (
|
|
get(workspacePermissionKeysQueryAtom).data?.workspace?.permission_keys ??
|
|
emptyWorkspacePermissionKeys
|
|
)
|
|
})
|
|
|
|
export const datasetDefaultPermissionKeysAtom = atom((get) => {
|
|
return get(workspacePermissionKeysQueryAtom).data?.dataset?.default_permission_keys ?? []
|
|
})
|
|
|
|
export const agentDefaultPermissionKeysAtom = atom((get) => {
|
|
return get(workspacePermissionKeysQueryAtom).data?.agent?.default_permission_keys ?? []
|
|
})
|
|
|
|
export const workspacePermissionKeysLoadingAtom = atom((get) => {
|
|
return get(workspacePermissionKeysQueryAtom).isPending
|
|
})
|
|
|
|
export const workspacePermissionKeysErrorAtom = atom((get) => {
|
|
return get(workspacePermissionKeysQueryAtom).error
|
|
})
|