mirror of
https://github.com/langgenius/dify.git
synced 2026-03-26 08:40:14 +08:00
- Add constants.ts with ROOT_ID, CONTEXT_MENU_TYPE, NODE_MENU_TYPE - Add root utilities to tree-utils.ts (isRootId, toApiParentId, etc.) - Replace '__root__' with ROOT_ID for consistent root identifier - Replace inline 'blank'/'root' strings with constants - Use NodeMenuType for type-safe menu type props - Remove duplicate ContextMenuType from types.ts, use from constants.ts
24 lines
667 B
TypeScript
24 lines
667 B
TypeScript
/**
|
|
* File Tree Constants - Single source of truth for root/blank identifiers
|
|
*/
|
|
|
|
// Root folder identifier (convert to null for API calls via toApiParentId)
|
|
export const ROOT_ID = 'root' as const
|
|
|
|
// Context menu trigger types (describes WHERE user clicked)
|
|
export const CONTEXT_MENU_TYPE = {
|
|
BLANK: 'blank',
|
|
NODE: 'node',
|
|
} as const
|
|
|
|
export type ContextMenuType = (typeof CONTEXT_MENU_TYPE)[keyof typeof CONTEXT_MENU_TYPE]
|
|
|
|
// Node menu types (determines which menu options to show)
|
|
export const NODE_MENU_TYPE = {
|
|
ROOT: 'root',
|
|
FOLDER: 'folder',
|
|
FILE: 'file',
|
|
} as const
|
|
|
|
export type NodeMenuType = (typeof NODE_MENU_TYPE)[keyof typeof NODE_MENU_TYPE]
|