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(bulk_actions): group the dialog into cards
Elian Doran8e35d97fa881
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex d99ef8c36f..2685060c9d 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -87,7 +87,8 @@"selected_notes": "Selected notes","more_notes": "+{{count}} more","remove_from_selection": "Remove from the selection",- "affected_notes": "Affected notes",+ "affected_note_count_one": "The actions apply to {{count}} note.",+ "affected_note_count_other": "The actions apply to {{count}} notes.","include_descendants": "Include descendants of the selected notes","available_actions": "Available actions","chosen_actions": "Chosen actions",diff --git a/apps/client/src/widgets/dialogs/bulk_actions.css b/apps/client/src/widgets/dialogs/bulk_actions.cssindex adc8cdfc1a..ba98e45341 100644--- a/apps/client/src/widgets/dialogs/bulk_actions.css+++ b/apps/client/src/widgets/dialogs/bulk_actions.css@@ -1,49 +1,71 @@-.bulk-actions-dialog .modal-body h4:not(:first-child) {- margin-top: 20px;-}+.bulk-actions-dialog {+ .tn-card {+ margin-bottom: 16px;+ }-.bulk-actions-dialog .bulk-actions-selected-notes {- display: flex;- flex-wrap: wrap;- align-items: center;- gap: 6px;- max-height: 30vh;- overflow-y: auto;-- .tn-chip {- max-width: 100%;- min-width: 0;+ .tn-card:last-child {+ margin-bottom: 0;}- .bulk-actions-more-notes {- padding-inline: 4px;+ .bulk-actions-selected-notes {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 6px;+ max-height: 30vh;+ overflow-y: auto;++ .tn-chip {+ max-width: 100%;+ min-width: 0;+ }++ .bulk-actions-more-notes {+ padding-inline: 4px;+ }}-}-.bulk-actions-dialog .bulk-available-action-list button {- padding: 2px 7px;- margin-inline-end: 10px;- margin-bottom: 5px;-}+ .bulk-available-action-group {+ display: flex;+ align-items: baseline;+ gap: 12px;+ }-.bulk-actions-dialog .bulk-existing-action-list {- width: 100%;-}+ .bulk-available-action-group-title {+ flex-shrink: 0;+ width: 6rem;+ color: var(--muted-text-color);+ }-.bulk-actions-dialog .bulk-existing-action-list td {- padding: 7px;-}+ .bulk-available-action-group-actions {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+ }-.bulk-actions-dialog .bulk-existing-action-list .button-column {- width: 50px;- white-space: nowrap;- text-align: end;-}+ .bulk-existing-action-list {+ width: 100%;-.bulk-actions-dialog .bulk-existing-action-list .button-column > * {- vertical-align: middle;-}+ tr:not(:last-child) {+ border-bottom: 1px solid var(--main-border-color);+ }++ td {+ padding: 8px 12px;+ }-.bulk-actions-dialog .bulk-existing-action-list .button-column .help-dropdown {- display: inline-block !important;-}\ No newline at end of file+ .button-column {+ width: 50px;+ white-space: nowrap;+ text-align: end;++ > * {+ vertical-align: middle;+ }++ .help-dropdown {+ display: inline-block !important;+ }+ }+ }+}diff --git a/apps/client/src/widgets/dialogs/bulk_actions.spec.tsx b/apps/client/src/widgets/dialogs/bulk_actions.spec.tsxindex a18dc31c91..628fecceee 100644--- a/apps/client/src/widgets/dialogs/bulk_actions.spec.tsx+++ b/apps/client/src/widgets/dialogs/bulk_actions.spec.tsx@@ -65,6 +65,12 @@ describe("BulkActionsDialog", () => {expect(container.querySelector(".bulk-actions-more-notes")).toBeNull();});+ it("says so when no action is chosen yet", async () => {+ await open([ "n1" ]);+ expect(container.querySelector(".bulk-actions-chosen-actions .no-items")?.textContent)+ .toBe("bulk_actions.none_yet");+ });+it("drops a removed chip from the notes the actions apply to, keeping the last one", async () => {await open([ "n1", "n2" ]);expect(lastAffectedNotesRequest()).toStrictEqual({ noteIds: [ "n1", "n2" ], includeDescendants: false });diff --git a/apps/client/src/widgets/dialogs/bulk_actions.tsx b/apps/client/src/widgets/dialogs/bulk_actions.tsxindex d708c4e99c..340f538a2f 100644--- a/apps/client/src/widgets/dialogs/bulk_actions.tsx+++ b/apps/client/src/widgets/dialogs/bulk_actions.tsx@@ -4,8 +4,10 @@ import Modal from "../react/Modal";import "./bulk_actions.css";import { BulkActionAffectedNotes } from "@triliumnext/commons";import server from "../../services/server";-import FormCheckbox from "../react/FormCheckbox";import Button from "../react/Button";+import { Card, CardSection } from "../react/Card";+import NoItems from "../react/NoItems";+import { OptionsRowWithToggle } from "../type_widgets/options/components/OptionsRow";import bulk_action from "../../services/bulk_action";import dialog from "../../services/dialog";import toast from "../../services/toast";@@ -96,24 +98,31 @@ export default function BulkActionsDialog() {}}onHidden={() => setShown(false)}>- <h4>{t("bulk_actions.selected_notes")}</h4>- {selectedOrActiveNoteIds && (- <SelectedNotes noteIds={selectedOrActiveNoteIds} onChange={setSelectedOrActiveNoteIds} />- )}-- <h4>{t("bulk_actions.affected_notes")}: <span>{affectedNoteCount}</span></h4>- <FormCheckbox- name="include-descendants" label={t("bulk_actions.include_descendants")}- currentValue={includeDescendants} onChange={setIncludeDescendants}- />-- <h4>{t("bulk_actions.available_actions")}</h4>- <AvailableActionsList />-- <h4>{t("bulk_actions.chosen_actions")}</h4>- <ExistingActionsList existingActions={existingActions} />+ <Card heading={t("bulk_actions.selected_notes")}>+ {selectedOrActiveNoteIds && (+ <CardSection>+ <SelectedNotes noteIds={selectedOrActiveNoteIds} onChange={setSelectedOrActiveNoteIds} />+ </CardSection>+ )}+ <CardSection>+ <OptionsRowWithToggle+ name="include-descendants"+ label={t("bulk_actions.include_descendants")}+ description={t("bulk_actions.affected_note_count", { count: affectedNoteCount })}+ currentValue={includeDescendants} onChange={setIncludeDescendants}+ />+ </CardSection>+ </Card>++ <Card heading={t("bulk_actions.available_actions")}>+ <AvailableActionsList />+ </Card>++ <Card className="bulk-actions-chosen-actions" heading={t("bulk_actions.chosen_actions")}>+ <ExistingActionsList existingActions={existingActions} />+ </Card></Modal>- )+ );}function SelectedNotes({ noteIds, onChange }: { noteIds: string[]; onChange(noteIds: string[]): void }) {@@ -145,33 +154,41 @@ function SelectedNotes({ noteIds, onChange }: { noteIds: string[]; onChange(note}function AvailableActionsList() {- return <table class="bulk-available-action-list">- {bulk_action.ACTION_GROUPS.map((actionGroup) => {- return (- <tr>- <td>{ actionGroup.title }:</td>- {actionGroup.actions.map(({ actionName, actionTitle }) =>+ return <>+ {bulk_action.ACTION_GROUPS.map((actionGroup) => (+ <CardSection key={actionGroup.title} className="bulk-available-action-group">+ <span className="bulk-available-action-group-title">{actionGroup.title}</span>+ <div className="bulk-available-action-group-actions">+ {actionGroup.actions.map(({ actionName, actionTitle }) => (<Button+ key={actionName}size="small"text={actionTitle}onClick={() => bulk_action.addAction("_bulkAction", actionName)}/>- )}- </tr>- );- })}- </table>;+ ))}+ </div>+ </CardSection>+ ))}+ </>;}-function ExistingActionsList({ existingActions }: { existingActions?: AbstractBulkAction[] }) {+function ExistingActionsList({ existingActions }: { existingActions: AbstractBulkAction[] }) {+ if (!existingActions.length) {+ return (+ <CardSection>+ <NoItems icon="bx bx-list-plus" text={t("bulk_actions.none_yet")} size="small" />+ </CardSection>+ );+ }+return (- <table class="bulk-existing-action-list">- { existingActions- ? existingActions- .map(action => action.doRender())- .filter(renderedAction => renderedAction !== null)- : <p>{t("bulk_actions.none_yet")}</p>- }- </table>+ <CardSection noPadding>+ <table class="bulk-existing-action-list">+ <tbody>+ {existingActions.map((action) => action.doRender())}+ </tbody>+ </table>+ </CardSection>);}diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Bulk Actions.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Bulk Actions.htmlindex 2864dfe13a..194dd57a9f 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Bulk Actions.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Bulk Actions.html@@ -28,8 +28,8 @@</ul></li><li>By default, only the selected notes will be affected. To also include- all the descendants of the notes, check <em>Include descendants of the selected notes</em>.- The number of affected notes at the top of the dialog will update to reflect+ all the descendants of the notes, turn on <em>Include descendants of the selected notes</em>.+ The number of affected notes, shown below that option, updates to reflectthe change.</li><li>Click on which action to apply from the <em>Available actions</em> section.A detailed description of each is available in the next section.diff --git a/docs/User Guide/User Guide/Advanced Usage/Bulk Actions.md b/docs/User Guide/User Guide/Advanced Usage/Bulk Actions.mdindex 132a5e5a82..7bce908dfb 100644--- a/docs/User Guide/User Guide/Advanced Usage/Bulk Actions.md+++ b/docs/User Guide/User Guide/Advanced Usage/Bulk Actions.md@@ -11,7 +11,7 @@ The _Bulk Actions_ dialog makes it easy to apply changes to multiple notes at on* Right click in the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a> and select _Advanced_ → _Apply bulk actions_.* The _Selected notes_ section at the top of the dialog lists the notes the actions apply to. When many notes are selected, only the first few are shown; click _+N more_ to show the rest.* To leave a note out without changing the selection in the note tree, press the X button on its entry. The last remaining note cannot be removed.-* By default, only the selected notes will be affected. To also include all the descendants of the notes, check _Include descendants of the selected notes_. The number of affected notes at the top of the dialog will update to reflect the change.+* By default, only the selected notes will be affected. To also include all the descendants of the notes, turn on _Include descendants of the selected notes_. The number of affected notes, shown below that option, updates to reflect the change.* Click on which action to apply from the _Available actions_ section. A detailed description of each is available in the next section.* For each action selected, the _Chosen actions_ section will update to reveal the entry. Each action will have its own configuration.* To remove an action, simply press the X button to the right of it.