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(mobile/search): group search buttons into split
Elian Doran0e2955b57e6d
diff --git a/apps/client/src/stylesheets/theme-next/pages.css b/apps/client/src/stylesheets/theme-next/pages.cssindex e6125e80e2..a5041cd553 100644--- a/apps/client/src/stylesheets/theme-next/pages.css+++ b/apps/client/src/stylesheets/theme-next/pages.css@@ -57,12 +57,12 @@height: 18px;}-/*+/** SEARCH PAGE*//* Button bar */- .search-definition-widget .search-setting-table tbody:last-child div {+ .search-definition-widget .search-setting-table .search-actions-container {justify-content: flex-end;gap: 8px;}@@ -143,7 +143,7 @@/** OPTIONS PAGES*/-+:root {--options-card-min-width: 500px;--options-card-max-width: 900px;@@ -335,4 +335,4 @@ nav.options-section-tabs + .options-section {.etapi-options-section div {height: auto !important;-}\ No newline at end of file+}diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsxindex c3a54566a7..78694ce57f 100644--- a/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx+++ b/apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx@@ -15,7 +15,7 @@ import tree from "../../services/tree";import { getErrorMessage, isMobile } from "../../services/utils";import ws from "../../services/ws";import RenameNoteBulkAction from "../bulk_actions/note/rename_note";-import Button from "../react/Button";+import Button, { SplitButton } from "../react/Button";import Dropdown from "../react/Dropdown";import { FormListHeader, FormListItem } from "../react/FormList";import { useTriliumEvent } from "../react/hooks";@@ -129,48 +129,7 @@ export default function SearchDefinitionTab({ note, ntxId, hidden }: Pick<TabCon})}</tbody><BulkActionsList note={note} />- <tbody className="search-actions">- <tr>- <td colSpan={3}>- <div className="search-actions-container">- <Button- icon="bx bx-search"- text={t("search_definition.search_button")}- keyboardShortcut="Enter"- onClick={refreshResults}- />-- <Button- icon="bx bxs-zap"- text={t("search_definition.search_execute")}- onClick={async () => {- await server.post(`search-and-execute-note/${note.noteId}`);- refreshResults();- toast.showMessage(t("search_definition.actions_executed"), 3000);- }}- />-- {note.isHiddenCompletely() && <Button- icon="bx bx-save"- text={t("search_definition.save_to_note")}- onClick={async () => {- const { notePath } = await server.post<SaveSearchNoteResponse>("special-notes/save-search-note", { searchNoteId: note.noteId });- if (!notePath) {- return;- }-- await ws.waitForMaxKnownEntityChangeId();- await appContext.tabManager.getActiveContext()?.setNote(notePath);-- // Note the {{- notePathTitle}} in json file is not typo, it's unescaping- // See https://www.i18next.com/translation-function/interpolation#unescape- toast.showMessage(t("search_definition.search_note_saved", { notePathTitle: await tree.getNotePathTitle(notePath) }));- }}- />}- </div>- </td>- </tr>- </tbody>+ <SearchButtonBar note={note} refreshResults={refreshResults} /></table>)}</div>@@ -178,6 +137,56 @@ export default function SearchDefinitionTab({ note, ntxId, hidden }: Pick<TabCon);}+function SearchButtonBar({ note, refreshResults }: {+ note: FNote;+ refreshResults(): void;+}) {+ async function searchAndExecuteActions() {+ await server.post(`search-and-execute-note/${note.noteId}`);+ refreshResults();+ toast.showMessage(t("search_definition.actions_executed"), 3000);+ }++ async function saveSearchNote() {+ const { notePath } = await server.post<SaveSearchNoteResponse>("special-notes/save-search-note", { searchNoteId: note.noteId });+ if (!notePath) return;++ await ws.waitForMaxKnownEntityChangeId();+ await appContext.tabManager.getActiveContext()?.setNote(notePath);++ // Note the {{- notePathTitle}} in json file is not typo, it's unescaping+ // See https://www.i18next.com/translation-function/interpolation#unescape+ toast.showMessage(t("search_definition.search_note_saved", { notePathTitle: await tree.getNotePathTitle(notePath) }));+ }++ return (+ <tbody className="search-actions">+ <tr>+ <td colSpan={3}>+ <ResponsiveContainer+ desktop={+ <div className="search-actions-container">+ <Button icon="bx bx-search" text={t("search_definition.search_button")} keyboardShortcut="Enter" onClick={refreshResults} />+ <Button icon="bx bxs-zap" text={t("search_definition.search_execute")} onClick={searchAndExecuteActions} />+ {note.isHiddenCompletely() && <Button icon="bx bx-save" text={t("search_definition.save_to_note")} onClick={saveSearchNote} />}+ </div>+ }+ mobile={+ <SplitButton+ text={t("search_definition.search_button")} icon="bx bx-search"+ onClick={refreshResults}+ >+ <FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>+ {note.isHiddenCompletely() && <FormListItem icon="bx bx-save" onClick={saveSearchNote}>{t("search_definition.save_to_note")}</FormListItem>}+ </SplitButton>+ }+ />+ </td>+ </tr>+ </tbody>+ );+}+function BulkActionsList({ note }: { note: FNote }) {const [ bulkActions, setBulkActions ] = useState<RenameNoteBulkAction[]>();