From 76a878c0ef04516ca9f595a6ca388bcc430117b3 Mon Sep 17 00:00:00 2001 From: fayazara Date: Tue, 27 Sep 2022 13:19:54 +0530 Subject: [PATCH] Handle Edge cases --- .../AutomationActionTeamMessageInput.vue | 8 +++- .../dashboard/settings/macros/MacroEditor.vue | 38 +++++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/AutomationActionTeamMessageInput.vue b/app/javascript/dashboard/components/widgets/AutomationActionTeamMessageInput.vue index bab416cc9..c2f986164 100644 --- a/app/javascript/dashboard/components/widgets/AutomationActionTeamMessageInput.vue +++ b/app/javascript/dashboard/components/widgets/AutomationActionTeamMessageInput.vue @@ -39,7 +39,13 @@ export default { mounted() { const { team_ids: teamIds } = this.value; if (teamIds) { - this.selectedTeams = this.teams.filter(team => teamIds.includes(team.id)); + if (typeof teamIds[0] !== 'object') { + this.selectedTeams = this.teams.filter(team => + teamIds.includes(team.id) + ); + } else { + this.selectedTeams = teamIds; + } } this.message = this.value.message; }, diff --git a/app/javascript/dashboard/routes/dashboard/settings/macros/MacroEditor.vue b/app/javascript/dashboard/routes/dashboard/settings/macros/MacroEditor.vue index 3c2ffd318..230360af6 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/macros/MacroEditor.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/macros/MacroEditor.vue @@ -231,9 +231,10 @@ export default { uiFlags: 'macros/getUIFlags', }), macroActionTypes() { - // Because we do not support attachments in macros - yet! + // Because we do not support attachments and email transcripts in macros - yet! + const itemsToRemove = ['send_attachment', 'send_email_transcript']; return AUTOMATION_ACTION_TYPES.filter( - obj => obj.key !== 'send_attachment' + item => !itemsToRemove.includes(item.key) ); }, macroId() { @@ -241,10 +242,14 @@ export default { }, }, watch: { - '$route.params.macroId': { + $route: { handler() { this.$v.$reset(); - this.fetchMacro(); + if (this.$route.params.macroId) { + this.fetchMacro(); + } else { + this.initializeMacro(); + } }, immediate: true, }, @@ -363,20 +368,21 @@ export default { this.$store.dispatch('teams/get'); this.$store.dispatch('labels/get'); this.manifestMacro(); - } else { - this.mode = 'CREATE'; - this.macro = { - name: '', - actions: [ - { - action_name: 'assign_team', - action_params: [], - }, - ], - visibility: 'global', - }; } }, + initializeMacro() { + this.mode = 'CREATE'; + this.macro = { + name: '', + actions: [ + { + action_name: 'assign_team', + action_params: [], + }, + ], + visibility: 'global', + }; + }, isActive(key) { return { active: this.macro.visibility === key }; },