Skip to content

Commit 7e09862

Browse files
Kiryousclaude
andcommitted
[One Workflow] Hide Add step group when search has no matching actions
Per designer feedback, the "Add step" group label should only appear when there are matching actions to show under it. The Commands and Jump-to-a-step groups already follow this rule — apply the same gate to Add step in both normal search and Steps: prefix mode. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 303a78b commit 7e09862

2 files changed

Lines changed: 43 additions & 24 deletions

File tree

src/platform/plugins/shared/workflows_management/public/features/actions_menu_popover/lib/use_display_options.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,24 @@ describe('buildDisplayOptions', () => {
4343
};
4444

4545
it('shows Add step + Commands sections when no search is active', () => {
46-
const result = buildDisplayOptions(base);
46+
const result = buildDisplayOptions({ ...base, options: [makeAction('a', 'A')] });
4747
expect(groupLabels(result)).toEqual(['Add step', 'Commands']);
48-
expect(dataKinds(result)).toEqual(['command', 'command']);
48+
expect(dataKinds(result)).toEqual(['action', 'command', 'command']);
49+
});
50+
51+
it('hides Add step section when no actions match the search', () => {
52+
const result = buildDisplayOptions({ ...base, options: [], searchTerm: 'zzz' });
53+
expect(groupLabels(result)).not.toContain('Add step');
54+
});
55+
56+
it('hides Add step section in Steps: mode when no actions match', () => {
57+
const result = buildDisplayOptions({
58+
...base,
59+
options: [],
60+
searchTerm: `${STEPS_PREFIX}zzz`,
61+
});
62+
expect(groupLabels(result)).not.toContain('Add step');
63+
expect(result).toHaveLength(0);
4964
});
5065

5166
it('returns action items directly when inside a sub-group', () => {

src/platform/plugins/shared/workflows_management/public/features/actions_menu_popover/lib/use_display_options.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,37 +91,41 @@ export function buildDisplayOptions({
9191
}
9292

9393
if (isStepsMode) {
94+
if (options.length > 0) {
95+
result.push({
96+
label: i18n.translate('workflows.actionsMenu.addStepGroupLabel', {
97+
defaultMessage: 'Add step',
98+
}),
99+
isGroupLabel: true,
100+
});
101+
for (const opt of options) {
102+
result.push({ label: opt.label, data: { menuItem: { kind: 'action', action: opt } } });
103+
}
104+
}
105+
return result;
106+
}
107+
108+
const visibleOptions = hasSearch ? options.slice(0, MAX_VISIBLE_STEPS) : options;
109+
if (visibleOptions.length > 0) {
94110
result.push({
95111
label: i18n.translate('workflows.actionsMenu.addStepGroupLabel', {
96112
defaultMessage: 'Add step',
97113
}),
98114
isGroupLabel: true,
99115
});
100-
for (const opt of options) {
116+
for (const opt of visibleOptions) {
101117
result.push({ label: opt.label, data: { menuItem: { kind: 'action', action: opt } } });
102118
}
103-
return result;
104-
}
105-
106-
result.push({
107-
label: i18n.translate('workflows.actionsMenu.addStepGroupLabel', {
108-
defaultMessage: 'Add step',
109-
}),
110-
isGroupLabel: true,
111-
});
112-
const visibleOptions = hasSearch ? options.slice(0, MAX_VISIBLE_STEPS) : options;
113-
for (const opt of visibleOptions) {
114-
result.push({ label: opt.label, data: { menuItem: { kind: 'action', action: opt } } });
115-
}
116119

117-
if (hasSearch && options.length > MAX_VISIBLE_STEPS) {
118-
result.push({
119-
label: i18n.translate('workflows.actionsMenu.viewAllSteps', {
120-
defaultMessage: 'View all steps to add',
121-
}),
122-
className: 'compactOption',
123-
data: { menuItem: { kind: 'nav', target: 'viewAll' } },
124-
});
120+
if (hasSearch && options.length > MAX_VISIBLE_STEPS) {
121+
result.push({
122+
label: i18n.translate('workflows.actionsMenu.viewAllSteps', {
123+
defaultMessage: 'View all steps to add',
124+
}),
125+
className: 'compactOption',
126+
data: { menuItem: { kind: 'nav', target: 'viewAll' } },
127+
});
128+
}
125129
}
126130

127131
const filteredCmds = (commands ?? []).filter(

0 commit comments

Comments
 (0)