feat: Add 'None' option to remove assigned agents/teams in macros and automations

- Add 'None' option (with id: 'nil') to agent and team assignment dropdowns in macros
- Deprecate remove_assigned_team action in favor of assign_team with 'None' option
- Update helper functions to properly display 'None' for unassignment
- Add comprehensive test coverage for the new functionality
- Maintain backward compatibility with existing remove_assigned_team action

Fixes #7551

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sojan Jose
2025-08-12 13:07:19 +02:00
co-authored by Claude
parent b4f758f644
commit 8aa37907c0
6 changed files with 53 additions and 11 deletions
@@ -119,24 +119,27 @@ describe('useMacros', () => {
const { getMacroDropdownValues } = useMacros();
expect(getMacroDropdownValues('add_label')).toHaveLength(mockLabels.length);
expect(getMacroDropdownValues('assign_team')).toHaveLength(
mockTeams.length
);
mockTeams.length + 1
); // +1 for "None"
expect(getMacroDropdownValues('assign_agent')).toHaveLength(
mockAgents.length + 1
); // +1 for "Self"
mockAgents.length + 2
); // +2 for "None" and "Self"
});
it('returns teams for assign_team and send_email_to_team types', () => {
it('returns teams with "None" option for assign_team and teams only for send_email_to_team', () => {
const { getMacroDropdownValues } = useMacros();
expect(getMacroDropdownValues('assign_team')).toEqual(mockTeams);
const assignTeamResult = getMacroDropdownValues('assign_team');
expect(assignTeamResult[0]).toEqual({ id: 'nil', name: 'AUTOMATION.NONE_OPTION' });
expect(assignTeamResult.slice(1)).toEqual(mockTeams);
expect(getMacroDropdownValues('send_email_to_team')).toEqual(mockTeams);
});
it('returns agents with "Self" option for assign_agent type', () => {
it('returns agents with "None" and "Self" options for assign_agent type', () => {
const { getMacroDropdownValues } = useMacros();
const result = getMacroDropdownValues('assign_agent');
expect(result[0]).toEqual({ id: 'self', name: 'Self' });
expect(result.slice(1)).toEqual(mockAgents);
expect(result[0]).toEqual({ id: 'nil', name: 'AUTOMATION.NONE_OPTION' });
expect(result[1]).toEqual({ id: 'self', name: 'Self' });
expect(result.slice(2)).toEqual(mockAgents);
});
it('returns formatted labels for add_label and remove_label types', () => {
@@ -172,8 +175,11 @@ describe('useMacros', () => {
const { getMacroDropdownValues } = useMacros();
expect(getMacroDropdownValues('add_label')).toEqual([]);
expect(getMacroDropdownValues('assign_team')).toEqual([]);
expect(getMacroDropdownValues('assign_team')).toEqual([
{ id: 'nil', name: 'AUTOMATION.NONE_OPTION' },
]);
expect(getMacroDropdownValues('assign_agent')).toEqual([
{ id: 'nil', name: 'AUTOMATION.NONE_OPTION' },
{ id: 'self', name: 'Self' },
]);
});
@@ -23,10 +23,18 @@ export const useMacros = () => {
const getMacroDropdownValues = type => {
switch (type) {
case 'assign_team':
return [
{ id: 'nil', name: t('AUTOMATION.NONE_OPTION') },
...teams.value,
];
case 'send_email_to_team':
return teams.value;
case 'assign_agent':
return [{ id: 'self', name: 'Self' }, ...agents.value];
return [
{ id: 'nil', name: t('AUTOMATION.NONE_OPTION') },
{ id: 'self', name: 'Self' },
...agents.value,
];
case 'add_label':
case 'remove_label':
return labels.value.map(i => ({
@@ -19,6 +19,8 @@ export const MACRO_ACTION_TYPES = [
label: 'REMOVE_LABEL',
inputType: 'multi_select',
},
// @deprecated: Use assign_team with 'None' option instead
// Kept for backward compatibility
{
key: 'remove_assigned_team',
label: 'REMOVE_ASSIGNED_TEAM',
@@ -17,6 +17,7 @@ export const resolveActionName = key => {
export const resolveTeamIds = (teams, ids) => {
return ids
.map(id => {
if (id === 'nil') return 'None';
const team = teams.find(i => i.id === id);
return team ? team.name : '';
})
@@ -35,6 +36,8 @@ export const resolveLabels = (labels, ids) => {
export const resolveAgents = (agents, ids) => {
return ids
.map(id => {
if (id === 'nil') return 'None';
if (id === 'self') return 'Self';
const agent = agents.find(i => i.id === id);
return agent ? agent.name : '';
})