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 2 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. |
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).