Skip to content

Commit 58b6903

Browse files
committed
fix(web): keep terminology preference title fixed
1 parent 305986a commit 58b6903

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

‎apps/web/src/components/settings/settingsSearch.test.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
makeProviderSettingsSchema,
55
SourceControlProviderKind,
66
} from "@t3tools/contracts";
7-
import { UNKNOWN_SOURCE_CONTROL_CLIENT } from "@t3tools/client-runtime/source-control-clients";
7+
import {
8+
setMergeRequestTerms,
9+
UNKNOWN_SOURCE_CONTROL_CLIENT,
10+
} from "@t3tools/client-runtime/source-control-clients";
811
import * as Schema from "effect/Schema";
912

1013
import {
@@ -14,6 +17,7 @@ import {
1417
isSettingsSearchScopeAvailable,
1518
movedSettingsPath,
1619
searchSettings,
20+
searchableSetting,
1721
SETTINGS_NAV_GROUPS,
1822
SETTINGS_SEARCH_ITEMS,
1923
sourceControlHostSearchItems,
@@ -91,6 +95,20 @@ describe("searchSettings", () => {
9195
localeLowerCase.mockRestore();
9296
}
9397
expect(searchSettings("xyzzy")).toEqual([]);
98+
try {
99+
for (const enabled of [false, true]) {
100+
setMergeRequestTerms(enabled);
101+
expect(searchableSetting("merge-request-terminology").title).toBe(
102+
"Use merge request terminology",
103+
);
104+
expect(
105+
searchSettings("terminology").find((item) => item.id === "merge-request-terminology")
106+
?.title,
107+
).toBe("Use merge request terminology");
108+
}
109+
} finally {
110+
setMergeRequestTerms(false);
111+
}
94112
});
95113

96114
it("matches query words across fields and ranks the strongest result first", () => {

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,15 @@ export function isSettingsSearchScopeAvailable(
14301430
}
14311431
}
14321432

1433+
export function formatSettingsSearchTitle(
1434+
item: Pick<SettingsSearchItem, "id" | "title">,
1435+
terms = currentChangeRequestTerms(),
1436+
): string {
1437+
return item.id === "merge-request-terminology"
1438+
? item.title
1439+
: formatChangeRequestText(item.title, terms);
1440+
}
1441+
14331442
export function searchableSetting(
14341443
id: SettingsSearchItemId,
14351444
terms = currentChangeRequestTerms(),
@@ -1438,7 +1447,7 @@ export function searchableSetting(
14381447
readonly title: string;
14391448
} {
14401449
const { id: anchorId, title } = SEARCH_ITEMS_BY_ID.get(id)!;
1441-
return { id: anchorId, title: formatChangeRequestText(title, terms) };
1450+
return { id: anchorId, title: formatSettingsSearchTitle({ id, title }, terms) };
14421451
}
14431452

14441453
export function filterAvailableSettingsSearchItems(
@@ -1483,7 +1492,7 @@ export function searchSettings(
14831492
const queryTokens = normalizedQuery.split(" ");
14841493

14851494
return settingsForThisPlatform(items)
1486-
.map((item) => ({ ...item, title: formatChangeRequestText(item.title) }))
1495+
.map((item) => ({ ...item, title: formatSettingsSearchTitle(item) }))
14871496
.flatMap((item, index) => {
14881497
const title = normalizeSearchText(item.title);
14891498
const fields = [

‎apps/web/src/components/settings/useAvailableSettingsSearchItems.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AuthEnvironmentMaintainScope } from "@t3tools/contracts";
2-
import { formatChangeRequestText } from "@t3tools/client-runtime/source-control-clients";
32
import { useChangeRequestTerms } from "~/hooks/useSettings";
43

54
import { usePrimaryCloudLinkState } from "~/cloud/cloudLinkState";
@@ -15,6 +14,7 @@ import { isWslSettingsRowVisible } from "./ConnectionsSettings.logic";
1514
import { isProviderSettingsEnvironmentAvailable } from "./ProviderSettingsPanel.logic";
1615
import {
1716
filterAvailableSettingsSearchItems,
17+
formatSettingsSearchTitle,
1818
getThreadAutoSettlementSearchAvailability,
1919
} from "./settingsSearch";
2020

@@ -60,5 +60,5 @@ export function useAvailableSettingsSearchItems() {
6060
hasThreadAutoSettlement,
6161
managedTunnelActive,
6262
hasPeerLinkHost,
63-
}).map((item) => ({ ...item, title: formatChangeRequestText(item.title, terms) }));
63+
}).map((item) => ({ ...item, title: formatSettingsSearchTitle(item, terms) }));
6464
}

0 commit comments

Comments
 (0)