feat: add "Import as template" to File Tree context menu#602
feat: add "Import as template" to File Tree context menu#602Adityakk9031 wants to merge 5 commits into
Conversation
|
Why is this being ignored 😭 it's the one thing I've been waiting to use OK |
|
Hey @itsmistermoon, not ignoring it! This one's on me to review. @Adityakk9031 put together a real implementation here, so we want to give it a proper look rather than rush it. Will follow up on the PR shortly. |
Fixups on top of the "Import as template" feature so it compiles and clears CI:
- Restore handleTemplateMove's closing: the new handler splice dropped its
`},` plus `{ handler: 'template-move', method: 'POST' }` options argument,
which broke the parse of api-extension.ts (whole server failed to build).
- Add 'template-import' to checkTemplateConflictGate's handler union (typecheck).
- Register handleTemplateImport in the route meta-tests: REQUIRED in
conflict-gate-coverage (it calls respondDocInConflict), EXEMPT in
attribution-sweep-coverage (single-file-mode guard emits before identity).
- Extract Lingui catalogs for the new UI strings (en + pseudo).
- Add a changeset; tidy the empty catch and name fallback for lint.
Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com>
|
Thanks for this @Adityakk9031 — really useful feature and it maps cleanly onto how folder templates already work. I pushed a few commits to the branch to get it building and through our CI gates (the handler insertion had accidentally dropped the tail of Two design questions before we merge: 1. The source title bakes into every instance. The import copies the source doc's frontmatter into the template's instantiated body, so |
|
2. "Convert (delete original)" deletes the source with no confirmation. It's one click inside a submenu and irreversible from the UI. Could we gate it behind a confirm step (reusing the existing delete-confirmation dialog)? "Keep original" is safe as-is; it's just the convert path that needs the guard. |
|
@tim-inkeep have a look |
Regenerate en/pseudo Lingui catalogs for the new convert-confirmation dialog strings, and apply the formatter to FileTree.tsx. Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com>
|
Your change is now on Because this repository is maintained through an internal mirror, GitHub shows this PR as closed rather than merged, but your commits are on the default branch with your authorship preserved. Closing it here to keep things in sync. |
Narrow-integration coverage for the new import endpoint, since the destructive "Convert (delete original)" path had none: - keep original: template created, source intact - convert: template created AND source doc deleted from disk - regression guard: source title is not baked into the instantiated frontmatter - missing source: 404 + urn:ok:error:doc-not-found Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com>
…ontext menu Commits: [9e6a0e0](9e6a0e0) Author: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> feat: add "Import as template" to File Tree context menu [7dd2d94](7dd2d94) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> fix: make Import-as-template build and pass gates Fixups on top of the "Import as template" feature so it compiles and clears CI: - Restore handleTemplateMove's closing: the new handler splice dropped its `},` plus `{ handler: 'template-move', method: 'POST' }` options argument, which broke the parse of api-extension.ts (whole server failed to build). - Add 'template-import' to checkTemplateConflictGate's handler union (typecheck). - Register handleTemplateImport in the route meta-tests: REQUIRED in conflict-gate-coverage (it calls respondDocInConflict), EXEMPT in attribution-sweep-coverage (single-file-mode guard emits before identity). - Extract Lingui catalogs for the new UI strings (en + pseudo). - Add a changeset; tidy the empty catch and name fallback for lint. Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> [ec73e78](ec73e78) Author: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> fix: address template import PR feedback [e429234](e429234) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> chore: extract i18n catalogs for template-convert dialog + format Regenerate en/pseudo Lingui catalogs for the new convert-confirmation dialog strings, and apply the formatter to FileTree.tsx. Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> [e30c3cf](e30c3cf) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> test: smoke-test /api/template/import (keep + convert + guards) Narrow-integration coverage for the new import endpoint, since the destructive "Convert (delete original)" path had none: - keep original: template created, source intact - convert: template created AND source doc deleted from disk - regression guard: source title is not baked into the instantiated frontmatter - missing source: 404 + urn:ok:error:doc-not-found Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> Co-authored-by: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> Co-authored-by: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> GitOrigin-RevId: 0618805a14d95eda89de74f3434188c29bdfe6ad
…ontext menu Commits: [9e6a0e0](9e6a0e0) Author: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> feat: add "Import as template" to File Tree context menu [7dd2d94](7dd2d94) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> fix: make Import-as-template build and pass gates Fixups on top of the "Import as template" feature so it compiles and clears CI: - Restore handleTemplateMove's closing: the new handler splice dropped its `},` plus `{ handler: 'template-move', method: 'POST' }` options argument, which broke the parse of api-extension.ts (whole server failed to build). - Add 'template-import' to checkTemplateConflictGate's handler union (typecheck). - Register handleTemplateImport in the route meta-tests: REQUIRED in conflict-gate-coverage (it calls respondDocInConflict), EXEMPT in attribution-sweep-coverage (single-file-mode guard emits before identity). - Extract Lingui catalogs for the new UI strings (en + pseudo). - Add a changeset; tidy the empty catch and name fallback for lint. Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> [ec73e78](ec73e78) Author: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> fix: address template import PR feedback [e429234](e429234) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> chore: extract i18n catalogs for template-convert dialog + format Regenerate en/pseudo Lingui catalogs for the new convert-confirmation dialog strings, and apply the formatter to FileTree.tsx. Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> [e30c3cf](e30c3cf) Author: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> test: smoke-test /api/template/import (keep + convert + guards) Narrow-integration coverage for the new import endpoint, since the destructive "Convert (delete original)" path had none: - keep original: template created, source intact - convert: template created AND source doc deleted from disk - regression guard: source title is not baked into the instantiated frontmatter - missing source: 404 + urn:ok:error:doc-not-found Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> Co-authored-by: Adityakk9031 <143548997+Adityakk9031@users.noreply.github.com> Co-authored-by: tim-inkeep <132074086+tim-inkeep@users.noreply.github.com> Co-authored-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> GitOrigin-RevId: 0618805a14d95eda89de74f3434188c29bdfe6ad
Resolves #590
Description
This PR addresses the feature request to easily convert existing documents into templates. It adds an Import as template option directly to the right-click context menu of standard markdown files in the File Tree.
Users can now choose to:
.ok/templates/.Changes Made
POST /api/template/importendpoint (handleTemplateImport) which atomically extracts the source file's frontmatter, manages potential disk/sync conflicts, and persists the new template.FileTree.tsx& Client API): Added the nested context menu items using the LucideFileKeyicon, bound them to a newimportTemplateclient wrapper, and handled immediate UI state cleanups (closing open tabs and removing deleted source files from the view).