Skip to content

Build your personal knowledge base with Trilium Notes

feat(search): describe the options that configure nothing

Elian Doran61b85f520b52
diff --git a/apps/client/src/widgets/search/SearchDefinition.css b/apps/client/src/widgets/search/SearchDefinition.css
index 3569b14424..82794b1ade 100644
--- a/apps/client/src/widgets/search/SearchDefinition.css
+++ b/apps/client/src/widgets/search/SearchDefinition.css
@@ -53,6 +53,10 @@
min-width: 0;
}
+ .search-option-description {
+ color: var(--muted-text-color);
+ }
+
.search-option-fields :is(.form-control, .form-select, .input-group-text) {
padding-block: 0.25rem;
}
diff --git a/apps/client/src/widgets/search/SearchDefinition.spec.tsx b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
index 0d4bd74751..114420ac41 100644
--- a/apps/client/src/widgets/search/SearchDefinition.spec.tsx
+++ b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
@@ -56,6 +56,21 @@ describe("the search definition", () => {
expect(actionsRow?.querySelector(".tn-split-button")).not.toBeNull();
});
+ it("describes an option that configures nothing instead of offering help", () => {
+ const container = renderDefinition([ "searchString", "fastSearch", "debug" ]);
+
+ for (const [ name, text ] of [
+ [ "fastSearch", "fast_search.description" ],
+ [ "debug", "debug.debug_info" ]
+ ]) {
+ const row = container.querySelector(`.search-option.${name}`);
+ expect(row?.querySelector(".search-option-description")?.textContent).toContain(text);
+ expect(row?.querySelector(".help-dropdown")).toBeNull();
+ }
+
+ expect(container.querySelector(".search-option.searchString .help-dropdown")).not.toBeNull();
+ });
+
it("offers the unused options and the bulk actions from the same menu", async () => {
const container = renderDefinition();
const toggle = container.querySelector<HTMLButtonElement>(".search-definition-add button");
@@ -111,13 +126,13 @@ describe("the search definition", () => {
});
});
-function renderDefinition() {
+function renderDefinition(labels = [ "searchString" ]) {
const note = {
noteId: "search1",
title: "search1",
getLabelValue: (name: string) => (name === "searchString" ? "#book" : null),
getAttribute: (type: string, name: string) =>
- (type === "label" && name === "searchString" ? {} : undefined),
+ (type === "label" && labels.includes(name) ? {} : undefined),
getAttributes: () => [],
isHiddenCompletely: () => false
} as unknown as FNote;
diff --git a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx b/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
index 09ba0da9aa..2e334368b8 100644
--- a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
+++ b/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
@@ -111,12 +111,14 @@ export const SEARCH_OPTIONS: SearchOption[] = [
}
];
-function SearchOption({ note, className, title, titleIcon, children, help, attributeName, attributeType, additionalAttributesToDelete }: {
+function SearchOption({ note, className, title, titleIcon, children, description, help, attributeName, attributeType, additionalAttributesToDelete }: {
note: FNote;
className?: string;
title: string,
titleIcon?: string,
children?: ComponentChildren,
+ /** Shown in place of `children` for an option that configures nothing. */
+ description?: ComponentChildren,
help?: ComponentChildren,
attributeName: string,
attributeType: AttributeType,
@@ -129,6 +131,7 @@ function SearchOption({ note, className, title, titleIcon, children, help, attri
{title}
</span>
<div className="search-option-fields">
+ {description && <span className="search-option-description">{description}</span>}
{children}
</div>
<HelpRemoveButtons
@@ -307,7 +310,7 @@ function AncestorOption({ note, ...restProps}: SearchOptionProps) {
function FastSearchOption({ ...restProps }: SearchOptionProps) {
return <SearchOption
titleIcon="bx bx-run" title={t("fast_search.fast_search")}
- help={t("fast_search.description")}
+ description={t("fast_search.description")}
{...restProps}
/>;
}
@@ -315,10 +318,7 @@ function FastSearchOption({ ...restProps }: SearchOptionProps) {
function DebugOption({ ...restProps }: SearchOptionProps) {
return <SearchOption
titleIcon="bx bx-bug" title={t("debug.debug")}
- help={<>
- <p>{t("debug.debug_info")}</p>
- {t("debug.access_info")}
- </>}
+ description={<>{t("debug.debug_info")} {t("debug.access_info")}</>}
{...restProps}
/>;
}