Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(import): single-page service picker for import dialog
Elian Doran6acaba6121c7
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex c053030b87..8a29e0cf86 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -230,12 +230,11 @@},"import_provider": {"title": "Import from a service",- "choose_provider": "Choose a service to import from:",- "back": "Back"+ "choose_provider": "Choose a service above to import from."},"onenote_import": {"name": "Microsoft OneNote",- "description": "Import notebooks, sections and pages from your OneNote account.",+ "description": "From your OneNote account","connect_description": "Sign in with your Microsoft account to import your OneNote notebooks.","connect": "Sign in with Microsoft","connecting": "Waiting for sign-in to complete…",@@ -252,28 +251,28 @@},"notion_import": {"name": "Notion",- "description": "Import pages from a Notion HTML export (.zip).",+ "description": "From an HTML export","description_long": "In Notion, export your workspace or a page as HTML with subpages included, then choose the resulting .zip file here.","choose_file": "Notion export (.zip)","import": "Import"},"keep_import": {"name": "Google Keep",- "description": "Import notes from a Google Keep export (.zip).",+ "description": "From a Takeout export","description_long": "In Google Takeout, export your Keep data as a .zip, then choose the resulting file here.","choose_file": "Google Keep export (.zip)","import": "Import"},"anytype_import": {"name": "Anytype",- "description": "Import pages from an Anytype JSON export (.zip).",+ "description": "From a JSON export","description_long": "In Anytype, export your space using the \"Any-Block\" format with \"JSON\" selected, then choose the resulting .zip file here. Only pages and their text are imported for now.","choose_file": "Anytype export (.zip)","import": "Import"},"evernote_import": {"name": "Evernote",- "description": "Import notes from an Evernote export (.enex).",+ "description": "From .enex files","description_long": "In Evernote, export a notebook (or up to 100 notes at a time) as an ENEX file, then choose one or more .enex files here. Each file is imported as a separate notebook.","choose_file": "Evernote export (.enex)","import": "Import"diff --git a/apps/client/src/widgets/dialogs/import_provider.css b/apps/client/src/widgets/dialogs/import_provider.cssindex 9de94df76a..df07efda9e 100644--- a/apps/client/src/widgets/dialogs/import_provider.css+++ b/apps/client/src/widgets/dialogs/import_provider.css@@ -1,16 +1,17 @@.modal.import-provider-dialog {.import-provider-picker {- display: flex;- flex-direction: column;+ display: grid;+ grid-template-columns: repeat(3, 1fr);gap: 0.75em;+ margin-bottom: 1.5em;}.import-provider-card {display: flex;align-items: center;- gap: 1em;+ gap: 0.75em;width: 100%;- padding: 1em;+ padding: 0.75em;text-align: left;border: 1px solid var(--main-border-color);border-radius: 8px;@@ -22,10 +23,16 @@border-color: var(--main-text-color);}+ .import-provider-card.selected {+ border-color: var(--main-text-color);+ background: var(--active-item-background-color);+ color: var(--active-item-text-color);+ }+.import-provider-card-icon {flex-shrink: 0;- width: 1.8em;- height: 1.8em;+ width: 1.5em;+ height: 1.5em;background-color: currentColor;-webkit-mask: var(--provider-icon) center / contain no-repeat;mask: var(--provider-icon) center / contain no-repeat;@@ -34,6 +41,7 @@.import-provider-card-text {display: flex;flex-direction: column;+ min-width: 0;}.import-provider-card-name {@@ -42,7 +50,23 @@.import-provider-card-description {color: var(--muted-text-color);- font-size: 0.9em;+ font-size: 0.85em;+ }++ .import-provider-card.selected .import-provider-card-description {+ color: inherit;+ opacity: 0.8;+ }++ .import-provider-panel {+ border-top: 1px solid var(--main-border-color);+ padding-top: 1.25em;+ }++ .import-provider-hint {+ color: var(--muted-text-color);+ text-align: center;+ margin: 1.5em 0;}.onenote-account {diff --git a/apps/client/src/widgets/dialogs/import_provider.tsx b/apps/client/src/widgets/dialogs/import_provider.tsxindex e94117f13f..bea96102a9 100644--- a/apps/client/src/widgets/dialogs/import_provider.tsx+++ b/apps/client/src/widgets/dialogs/import_provider.tsx@@ -4,15 +4,15 @@ import type { ComponentChildren } from "preact";import { useCallback, useState } from "preact/hooks";import { t } from "../../services/i18n.js";-import Button from "../react/Button.js";import { useTriliumEvent } from "../react/hooks.js";import Modal from "../react/Modal.js";import { importProviders } from "./import_providers/index.js";/**- * Generic "import from a service" dialog. It is provider-agnostic: it shows a picker of registered- * {@link importProviders} and then hands off to the chosen provider's panel, which drives its own- * flow (auth, selection, progress). Add new sources by registering them in `import_providers`.+ * Generic "import from a service" dialog. It is provider-agnostic: the top of the dialog shows a picker+ * of registered {@link importProviders} as selectable cards, and the chosen provider's panel renders+ * directly below it, driving its own flow (auth, selection, progress). Add new sources by registering+ * them in `import_providers`.*/export default function ImportProviderDialog() {const [parentNoteId, setParentNoteId] = useState<string>();@@ -38,29 +38,34 @@ export default function ImportProviderDialog() {className="import-provider-dialog"size="lg"scrollable- title={provider ? provider.name : t("import_provider.title")}- header={provider && <Button text={t("import_provider.back")} kind="lowProfile" size="small" icon="bx-arrow-back" onClick={() => { setProviderId(undefined); setFooter(null); }} />}+ title={t("import_provider.title")}footer={footer}footerAlignment="between"onHidden={() => setShown(false)}show={shown}>- {!provider && (- <div className="import-provider-picker">- <p>{t("import_provider.choose_provider")}</p>- {importProviders.map((p) => (- <button type="button" className="import-provider-card" key={p.id} onClick={() => setProviderId(p.id)}>- <span className="import-provider-card-icon" style={{ "--provider-icon": `url("${p.iconUrl}")` }} />- <span className="import-provider-card-text">- <span className="import-provider-card-name">{p.name}</span>- <span className="import-provider-card-description">{p.description}</span>- </span>- </button>- ))}- </div>- )}+ <div className="import-provider-picker">+ {importProviders.map((p) => (+ <button+ type="button"+ className={`import-provider-card ${p.id === providerId ? "selected" : ""}`}+ key={p.id}+ onClick={() => setProviderId(p.id)}+ >+ <span className="import-provider-card-icon" style={{ "--provider-icon": `url("${p.iconUrl}")` }} />+ <span className="import-provider-card-text">+ <span className="import-provider-card-name">{p.name}</span>+ <span className="import-provider-card-description">{p.description}</span>+ </span>+ </button>+ ))}+ </div>- {provider && parentNoteId && <provider.Panel parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />}+ <div className="import-provider-panel">+ {provider && parentNoteId+ ? <provider.Panel key={provider.id} parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />+ : <p className="import-provider-hint">{t("import_provider.choose_provider")}</p>}+ </div></Modal>);}