Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/client/src/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
"workspace_template": "This note will appear in the selection of available template when creating new note, but only when hoisted into a workspace containing this template",
"search_home": "new search notes will be created as children of this note",
"workspace_search_home": "new search notes will be created as children of this note when hoisted to some ancestor of this workspace note",
"auto_execute_search": "Automatically executes the search defined in a saved search note and switches to the Collection Properties tab if any notes match the query",
"inbox": "default inbox location for new notes - when you create a note using \"new note\" button in the sidebar, notes will be created as child notes in the note marked as with <code>#inbox</code> label.",
"workspace_inbox": "default inbox location for new notes when hoisted to some ancestor of this workspace note",
"sql_console_home": "default location of SQL console notes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const ATTR_HELP: Record<string, Record<string, string>> = {
workspaceTemplate: t("attribute_detail.workspace_template"),
searchHome: t("attribute_detail.search_home"),
workspaceSearchHome: t("attribute_detail.workspace_search_home"),
autoExecuteSearch: t("attribute_detail.auto_execute_search"),
inbox: t("attribute_detail.inbox"),
workspaceInbox: t("attribute_detail.workspace_inbox"),
sqlConsoleHome: t("attribute_detail.sql_console_home"),
Expand Down
31 changes: 30 additions & 1 deletion apps/client/src/widgets/ribbon/SearchDefinitionTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import RenameNoteBulkAction from "../bulk_actions/note/rename_note";
import { getErrorMessage } from "../../services/utils";
import "./SearchDefinitionTab.css";

export default function SearchDefinitionTab({ note, ntxId, hidden }: TabContext) {
export default function SearchDefinitionTab({ note, ntxId, hidden, noteContext }: TabContext) {
const parentComponent = useContext(ParentComponent);
const [ searchOptions, setSearchOptions ] = useState<{ availableOptions: SearchOption[], activeOptions: SearchOption[] }>();
const [ error, setError ] = useState<{ message: string }>();
Expand Down Expand Up @@ -73,6 +73,27 @@ export default function SearchDefinitionTab({ note, ntxId, hidden }: TabContext)
}
});

useEffect(() => {
async function autoExecute() {
if (!note || note.type !== "search" || !note.hasLabel("autoExecuteSearch")) {
executionState.save("");
return;
}

const lastExecutedNoteId = executionState.load();
if (lastExecutedNoteId !== note.noteId) {
executionState.save(note.noteId);

await refreshResults();

if (noteContext?.viewScope?.viewMode === "default" && note.children.length > 0) {
parentComponent?.triggerCommand("toggleRibbonTabBookProperties", {});
}
}
}
autoExecute();
}, [note]);

return (
<div className="search-definition-widget">
<div className="search-settings">
Expand Down Expand Up @@ -160,6 +181,14 @@ export default function SearchDefinitionTab({ note, ntxId, hidden }: TabContext)
)
}

const executionState = function() {
let lastAutoExecutedSearchNoteId = "";
return {
load: () => lastAutoExecutedSearchNoteId,
save: (noteId: string) => lastAutoExecutedSearchNoteId = noteId,
};
}();

function BulkActionsList({ note }: { note: FNote }) {
const [ bulkActions, setBulkActions ] = useState<RenameNoteBulkAction[]>();

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/commons/src/lib/attribute_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Labels = {
ancestorDepth: string;
orderBy: string;
orderDirection: string;
autoExecuteSearch: boolean;

// Collection-specific
viewType: string;
Expand Down
Loading