mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 02:28:30 +08:00
25 lines
822 B
TypeScript
25 lines
822 B
TypeScript
'use client'
|
|
|
|
import { atom } from 'jotai'
|
|
import { atomWithQuery } from 'jotai-tanstack-query'
|
|
import { workspacePermissionKeysQueryOptions } from '@/service/access-control/use-permission-keys'
|
|
import { emptyWorkspacePermissionKeys } from './app-context-normalizers'
|
|
import { currentWorkspaceIdAtom } from './workspace-state'
|
|
|
|
const workspacePermissionKeysQueryAtom = atomWithQuery((get) => {
|
|
const workspaceId = get(currentWorkspaceIdAtom)
|
|
|
|
return workspacePermissionKeysQueryOptions(workspaceId)
|
|
})
|
|
|
|
export const workspacePermissionKeysAtom = atom((get) => {
|
|
return (
|
|
get(workspacePermissionKeysQueryAtom).data?.workspace?.permission_keys ??
|
|
emptyWorkspacePermissionKeys
|
|
)
|
|
})
|
|
|
|
export const workspacePermissionKeysLoadingAtom = atom((get) => {
|
|
return get(workspacePermissionKeysQueryAtom).isPending
|
|
})
|