Skip to content

feat: add the exportYaml for each exportable resource's list&show pages - #104

Open
jintao2002 wants to merge 4 commits into
neutree-ai:mainfrom
jintao2002:feature/NEU-162
Open

jintao2002 wants to merge 4 commits into
neutree-ai:mainfrom
jintao2002:feature/NEU-162

Conversation

@jintao2002

@jintao2002 jintao2002 commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

Global State Management for Dialog Lifecycle

  • useYamlExportDialog.tsx (src/hooks/use-yaml-export-dialog.ts): Manages global dialog state to solve component unmounting issues when dropdown menus close
  • GlobalYamlExportDialog.tsx (src/components/business/GlobalYamlExportDialog.tsx): Listens for export events and renders the dialog
  • Purpose Prevents dialog from disappearing when triggering UI components (dropdowns) unmount

yaml-utils.ts (src/lib/yaml-utils.ts)

  • Core utilities for YAML generation, clipboard operations, and file downloads

Show Pages && List Pages

ShowPage Component (src/components/theme/curds/show/index.tsx)

  • export buttons will be conditionally rendered based on EXPORTABLE-RESOURCES

Comment thread src/lib/yaml-utils.ts
Comment thread src/components/theme/table/columns/metadata-columns.tsx Outdated
Comment thread src/hooks/use-yaml-export-dialog.ts Outdated
}

// Global state for YAML export dialog - ensures only one instance
let globalDialogState: YamlExportDialogState = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this mechanism instead of having each YAML dialog maintain its own state?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the YAML export dialog was being destroyed when dropdown menus closed after clicking so I maintained a global state outside the component tree to ensure the dialog's lifecycle is independent of its parent component(Dropdown menu). I tried to resolve it with React.createPortal but it didn't work, should I keep trying in other ways for this problem?

? globalBreadcrumb
: breadcrumbFromProps;

// YAML export dialog state

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theme show is open to all resources, but not all resources need to be exported as YAML. Therefore, we can pass them in as extras as needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I determined whether to render the ExportButton by conditions below and it worked. Should I keep it this way or determine the rendering only by extraActions?

{resource?.name && EXPORTABLE_RESOURCES.includes(resource.name as any) && (
  <ExportYamlAction
    ...
  />
)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants