Files
dify/web/app/components/workflow/skill/constants.ts
yyh 31a7db2657 refactor(skill): unify root/blank constants and eliminate magic strings
- 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
2026-01-19 23:07:49 +08:00

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]