Files
chatwoot/app/javascript/dashboard/composables/useMacros.js
T
Sojan JoseandClaude 8aa37907c0 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>
2025-08-12 13:07:19 +02:00

58 lines
1.7 KiB
JavaScript

import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useStoreGetters } from 'dashboard/composables/store';
import { PRIORITY_CONDITION_VALUES } from 'dashboard/constants/automation';
/**
* Composable for handling macro-related functionality
* @returns {Object} An object containing the getMacroDropdownValues function
*/
export const useMacros = () => {
const { t } = useI18n();
const getters = useStoreGetters();
const labels = computed(() => getters['labels/getLabels'].value);
const teams = computed(() => getters['teams/getTeams'].value);
const agents = computed(() => getters['agents/getAgents'].value);
/**
* Get dropdown values based on the specified type
* @param {string} type - The type of dropdown values to retrieve
* @returns {Array} An array of dropdown values
*/
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: 'nil', name: t('AUTOMATION.NONE_OPTION') },
{ id: 'self', name: 'Self' },
...agents.value,
];
case 'add_label':
case 'remove_label':
return labels.value.map(i => ({
id: i.title,
name: i.title,
}));
case 'change_priority':
return PRIORITY_CONDITION_VALUES.map(item => ({
id: item.id,
name: t(`MACROS.PRIORITY_TYPES.${item.i18nKey}`),
}));
default:
return [];
}
};
return {
getMacroDropdownValues,
};
};