Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8459 refactor(issues): drop redundant text from the advanced filter panel (#9779)

Jiayuan Zhangc321e49098cd
diff --git a/e2e/issue-filter-advanced.spec.ts b/e2e/issue-filter-advanced.spec.ts
index afa8bf8a01..d53a6f99a7 100644
--- a/e2e/issue-filter-advanced.spec.ts
+++ b/e2e/issue-filter-advanced.spec.ts
@@ -114,9 +114,14 @@ test.describe("Issue filter: search, due date, advanced", () => {
await expect(panel).toBeVisible();
await expect.poll(() => visibleIssueTitles(page, all)).toEqual([lowLate, urgentLate].sort());
- await expect(panel.getByRole("button", { name: "Switch to simple filter" })).toBeDisabled();
- await expect(panel.getByText(/Simple filters can't show groups/)).toBeVisible();
+ const toSimple = panel.getByRole("button", { name: "Switch to simple filter" });
+ await expect(toSimple).toBeDisabled();
await shot(page, "03-advanced");
+ await toSimple.locator("..").hover();
+ const blockedReason = page.getByText(/Simple filters can't show groups/);
+ await expect(blockedReason).toBeVisible();
+ await panel.getByText("Advanced filter").hover();
+ await expect(blockedReason).toBeHidden();
// The trigger names the mode; the chip bar carries the tree as one chip.
await page.keyboard.press("Escape");
diff --git a/packages/views/issues/components/advanced-filter-panel.tsx b/packages/views/issues/components/advanced-filter-panel.tsx
index e7e302bfc5..58089aec1f 100644
--- a/packages/views/issues/components/advanced-filter-panel.tsx
+++ b/packages/views/issues/components/advanced-filter-panel.tsx
@@ -24,6 +24,7 @@ import {
SelectTrigger,
SelectValue,
} from "@multica/ui/components/ui/select";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@multica/ui/components/ui/tooltip";
import {
ADVANCED_FILTER_MAX_CONDITIONS,
advancedFilterConditionSlots,
@@ -33,7 +34,6 @@ import {
isPropertyCondition,
propertyFilterField,
propertyIdOfField,
- pruneAdvancedFilter,
simpleFromAdvancedFilter,
type AdvancedFilterCondition,
type AdvancedFilterField,
@@ -647,48 +647,6 @@ function AddButton({ children, ...props }: React.ComponentProps<typeof Button>)
);
}
-/** A condition as a phrase: "Label includes any of Bug +1". */
-function useConditionPhrase(fields: ConditionFields, catalog: Catalog) {
- const operatorLabel = useOperatorLabel();
- const wsId = useWorkspaceId();
- const { data: members = [] } = useQuery(memberListOptions(wsId));
- const actorName = useMemo(() => buildChipActorNames(members, [], []), [members]);
- const valueName = usePropertyValueName(actorName);
- return (condition: AdvancedFilterCondition): string => {
- const property = isPropertyCondition(condition)
- ? fields.propertyById.get(propertyIdOfField(condition.field) ?? "")
- : undefined;
- const spec = filterFieldSpec(condition, property?.type);
- const op = conditionOperator(condition, spec);
- const head = `${fields.describe(condition.field).label} ${operatorLabel(op, spec.kind)}`;
- if (isEmptinessOperator(op)) return head;
- let value: string;
- if (isTypedValueKind(spec.kind)) {
- value = conditionText(condition);
- } else if (isPropertyCondition(condition)) {
- value = summarize(condition.values.map((v) => (property ? valueName(property, v) : undefined)));
- } else {
- const options = catalog(condition.field);
- value = summarize(condition.values.map((v) => options.find((option) => option.value === v)?.label));
- }
- return `${head} ${value}`;
- };
-}
-
-/** A pruned tree as one sentence, a group in parentheses. */
-function describeGroup(
- group: AdvancedFilterGroup,
- phrase: (condition: AdvancedFilterCondition) => string,
- joinWord: (match: "all" | "any") => string,
- nested = false,
-): string {
- const parts = group.children.map((child) =>
- child.type === "group" ? describeGroup(child, phrase, joinWord, true) : phrase(child),
- );
- const text = parts.join(` ${joinWord(group.match)} `);
- return nested && parts.length > 1 ? `(${text})` : text;
-}
-
/** A group under the root: its own match in the header, then its rows. An
* empty group is a slot to add the first condition into. */
function FilterGroupCard({
@@ -816,12 +774,17 @@ export function AdvancedFilterPanel({
// A group is usually the other word: "and" rules holding an "or".
const newGroup = (children: AdvancedFilterNode[] = []) =>
createFilterGroup(root.match === "all" ? "any" : "all", children);
- const phrase = useConditionPhrase(fields, catalog);
- const joinWord = useJoinWord();
- const pruned = pruneAdvancedFilter(root);
- const summary = pruned?.children.some((child) => child.type === "group")
- ? describeGroup(pruned, phrase, joinWord)
- : null;
+ const toSimpleButton = (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 shrink-0 px-2 text-caption"
+ disabled={!representable}
+ onClick={exitAdvancedFilter}
+ >
+ {t(($) => $.filters.advanced_to_simple)}
+ </Button>
+ );
return (
<div className="flex flex-col">
@@ -873,11 +836,6 @@ export function AdvancedFilterPanel({
)}
</div>
))}
- {summary && (
- <p className="pt-1 text-caption text-pretty text-muted-foreground" data-testid="advanced-filter-summary">
- {t(($) => $.filters.advanced_summary, { summary })}
- </p>
- )}
</div>
<div className="flex items-center gap-1 px-2 py-1.5">
@@ -899,19 +857,16 @@ export function AdvancedFilterPanel({
</div>
<div className="flex items-center gap-2 border-t border-border px-2 py-1.5">
- <Button
- variant="ghost"
- size="sm"
- className="h-7 shrink-0 px-2 text-caption"
- disabled={!representable}
- onClick={exitAdvancedFilter}
- >
- {t(($) => $.filters.advanced_to_simple)}
- </Button>
- {!representable && (
- <span className="min-w-0 truncate text-caption text-muted-foreground" title={t(($) => $.filters.advanced_to_simple_blocked)}>
- {t(($) => $.filters.advanced_to_simple_blocked)}
- </span>
+ {representable ? (
+ toSimpleButton
+ ) : (
+ // A disabled button gets no pointer events, so the wrapper carries the reason.
+ <Tooltip>
+ <TooltipTrigger render={<span tabIndex={0} className="shrink-0 rounded-lg outline-none" />}>
+ {toSimpleButton}
+ </TooltipTrigger>
+ <TooltipContent side="top">{t(($) => $.filters.advanced_to_simple_blocked)}</TooltipContent>
+ </Tooltip>
)}
<Button
variant="ghost"
diff --git a/packages/views/issues/components/issues-header.advanced-filter.test.tsx b/packages/views/issues/components/issues-header.advanced-filter.test.tsx
index 2b07b72520..005b207168 100644
--- a/packages/views/issues/components/issues-header.advanced-filter.test.tsx
+++ b/packages/views/issues/components/issues-header.advanced-filter.test.tsx
@@ -198,7 +198,7 @@ describe("IssueFilterMenu advanced mode", () => {
});
});
- it("turns a row into a group and reads the tree as a sentence", async () => {
+ it("turns a row into a group", async () => {
const store = renderFilterMenu((s) =>
s.getState().setAdvancedFilter(
createFilterGroup("all", [
@@ -209,7 +209,6 @@ describe("IssueFilterMenu advanced mode", () => {
);
fireEvent.click(screen.getByRole("button", { name: "Filter" }));
await screen.findByTestId("advanced-filter-panel");
- expect(screen.queryByTestId("advanced-filter-summary")).not.toBeInTheDocument();
const rows = screen.getAllByTestId("advanced-filter-row");
fireEvent.click(within(rows[1]!).getByRole("button", { name: "Condition actions" }));
@@ -219,11 +218,7 @@ describe("IssueFilterMenu advanced mode", () => {
match: "any",
children: [{ field: "priority", values: ["urgent"] }],
});
- await waitFor(() =>
- expect(screen.getByTestId("advanced-filter-summary")).toHaveTextContent(
- "Shows issues where Label includes any of Bug and Priority is Urgent",
- ),
- );
+ expect(await screen.findByTestId("advanced-filter-group")).toBeInTheDocument();
});
it("switches to advanced with the current filters and opens the panel", async () => {
@@ -243,7 +238,7 @@ describe("IssueFilterMenu advanced mode", () => {
expect(screen.getByRole("button", { name: "Switch to simple filter" })).toBeEnabled();
});
- it("disables switching back with the reason when the tree has a group", async () => {
+ it("disables switching back when the tree has a group", async () => {
renderFilterMenu((s) =>
s.getState().setAdvancedFilter(
createFilterGroup("all", [
@@ -259,7 +254,7 @@ describe("IssueFilterMenu advanced mode", () => {
await screen.findByTestId("advanced-filter-panel");
expect(screen.getByTestId("advanced-filter-group")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Switch to simple filter" })).toBeDisabled();
- expect(screen.getByText(/Simple filters can't show groups/)).toBeInTheDocument();
+ expect(screen.queryByText(/Simple filters can't show groups/)).not.toBeInTheDocument();
});
it("goes back to the simple menu with the same filters", async () => {
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index affc48a39d..0649615bdc 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -258,8 +258,7 @@
"advanced_group_match_trailing": "of these",
"advanced_group_hint": "Conditions in this group are joined with “{{word}}”",
"advanced_add_to_group": "Add to group",
- "advanced_turn_into_group": "Turn into group",
- "advanced_summary": "Shows issues where {{summary}}"
+ "advanced_turn_into_group": "Turn into group"
},
"display": {
"tooltip": "Display settings",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 411b028963..3e3abbf0ae 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -258,8 +258,7 @@
"advanced_group_match_trailing": "de ces conditions",
"advanced_group_hint": "Les conditions de ce groupe sont reliées par « {{word}} »",
"advanced_add_to_group": "Ajouter au groupe",
- "advanced_turn_into_group": "Transformer en groupe",
- "advanced_summary": "Affiche les tâches où {{summary}}"
+ "advanced_turn_into_group": "Transformer en groupe"
},
"display": {
"tooltip": "Paramètres d'affichage",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 78ab930414..fba4695ee2 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -252,8 +252,7 @@
"advanced_group_match_trailing": "に一致",
"advanced_group_hint": "このグループの条件は「{{word}}」でつながります",
"advanced_add_to_group": "グループに追加",
- "advanced_turn_into_group": "グループに変換",
- "advanced_summary": "条件:{{summary}}"
+ "advanced_turn_into_group": "グループに変換"
},
"display": {
"tooltip": "表示設定",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 69f5f61743..18d09ad9ba 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -252,8 +252,7 @@
"advanced_group_match_trailing": "충족",
"advanced_group_hint": "이 그룹의 조건은 '{{word}}'(으)로 연결됩니다",
"advanced_add_to_group": "그룹에 추가",
- "advanced_turn_into_group": "그룹으로 전환",
- "advanced_summary": "조건: {{summary}}"
+ "advanced_turn_into_group": "그룹으로 전환"
},
"display": {
"tooltip": "보기 설정",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index d8fc80f8c4..54b044cc30 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -252,8 +252,7 @@
"advanced_group_match_trailing": "条件",
"advanced_group_hint": "组内条件之间用「{{word}}」连接",
"advanced_add_to_group": "添加到条件组",
- "advanced_turn_into_group": "转为条件组",
- "advanced_summary": "筛选:{{summary}}"
+ "advanced_turn_into_group": "转为条件组"
},
"display": {
"tooltip": "显示设置",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 7fc38da716..14138de158 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -252,8 +252,7 @@
"advanced_group_match_trailing": "條件",
"advanced_group_hint": "組內條件之間用「{{word}}」連接",
"advanced_add_to_group": "新增到條件組",
- "advanced_turn_into_group": "轉為條件組",
- "advanced_summary": "篩選:{{summary}}"
+ "advanced_turn_into_group": "轉為條件組"
},
"display": {
"tooltip": "顯示設定",