diff --git a/src/dispatch/static/dispatch/src/case/ResourcesTab.vue b/src/dispatch/static/dispatch/src/case/ResourcesTab.vue index 7e8d01d637c4..604c5dbb9465 100644 --- a/src/dispatch/static/dispatch/src/case/ResourcesTab.vue +++ b/src/dispatch/static/dispatch/src/case/ResourcesTab.vue @@ -74,7 +74,7 @@ (!documents && documentPluginEnabled) " > - + Recreate Missing Resources + + + Creating resources... + Initiate a retry for creating any missing or unsuccesfully created + resource(s). + + @@ -117,22 +126,22 @@ export default { "selected.storage", "selected.ticket", "selected.conversation", + "selected.loading", ]), }, - async mounted() { - this.ticketPluginEnabled = await this.isPluginEnabled("ticket") - this.groupPluginEnabled = await this.isPluginEnabled("group") - this.conversationPluginEnabled = - (await this.isPluginEnabled("conversation")) && - this.selected.case_type && - this.selected.case_type.conversation_target - this.storagePluginEnabled = await this.isPluginEnabled("storage") - this.documentPluginEnabled = await this.isPluginEnabled("document") + async mounted() { + let enabledPlugins = await this.getEnabledPlugins() + + this.ticketPluginEnabled = enabledPlugins.includes("ticket") + this.conferencePluginEnabled = enabledPlugins.includes("conference") + this.groupPluginEnabled = enabledPlugins.includes("participant-group") + this.storagePluginEnabled = enabledPlugins.includes("storage") + this.documentPluginEnabled = enabledPlugins.includes("document") }, methods: { - ...mapActions("case_management", ["createAllResources", "isPluginEnabled"]), + ...mapActions("case_management", ["createAllResources", "getEnabledPlugins"]), }, } diff --git a/src/dispatch/static/dispatch/src/case/store.js b/src/dispatch/static/dispatch/src/case/store.js index 1f4624ec8941..786318001b9e 100644 --- a/src/dispatch/static/dispatch/src/case/store.js +++ b/src/dispatch/static/dispatch/src/case/store.js @@ -258,7 +258,6 @@ const actions = { commit("SET_SELECTED_LOADING", true) return CaseApi.createAllResources(state.selected.id) .then(function () { - dispatch("get") commit( "notification_backend/addBeNotification", { text: "Case resource(s) created successfully.", type: "success" }, @@ -273,6 +272,7 @@ const actions = { ) }) .finally(() => { + dispatch("get") commit("SET_SELECTED_LOADING", false) }) }, @@ -353,7 +353,7 @@ const actions = { ) }) }, - isPluginEnabled(_, type) { + getEnabledPlugins() { if (!state.selected.project) { return false } @@ -372,16 +372,15 @@ const actions = { op: "==", value: state.selected.project.name, }, - { - model: "Plugin", - field: "type", - op: "like", - value: String(type), - }, ], }), }).then((response) => { - return response.data.items.length > 0 + return response.data.items.reduce((result, item) => { + if (item.plugin) { + result.push(item.plugin.type) + } + return result + }, []) }) }, } diff --git a/src/dispatch/static/dispatch/src/incident/ResourcesTab.vue b/src/dispatch/static/dispatch/src/incident/ResourcesTab.vue index de277d88417f..014ae8415e42 100644 --- a/src/dispatch/static/dispatch/src/incident/ResourcesTab.vue +++ b/src/dispatch/static/dispatch/src/incident/ResourcesTab.vue @@ -71,7 +71,7 @@ (!documents && documentPluginEnabled) " > - + Recreate Missing Resources + + + Creating resources... + Initiate a retry for creating any missing or unsuccesfully created + resource(s). + + @@ -113,19 +122,23 @@ export default { "selected.documents", "selected.conference", "selected.conversation", + "selected.loading", ]), }, - async mounted() { - this.ticketPluginEnabled = await this.isPluginEnabled("ticket") - this.conferencePluginEnabled = await this.isPluginEnabled("conference") - this.conversationPluginEnabled = await this.isPluginEnabled("conversation") - this.storagePluginEnabled = await this.isPluginEnabled("storage") - this.documentPluginEnabled = await this.isPluginEnabled("document") + async mounted() { + let enabledPlugins = await this.getEnabledPlugins() + + this.ticketPluginEnabled = enabledPlugins.includes("ticket") + this.conferencePluginEnabled = enabledPlugins.includes("conference") + this.conversationPluginEnabled = enabledPlugins.includes("conversation") + this.storagePluginEnabled = enabledPlugins.includes("storage") + this.documentPluginEnabled = enabledPlugins.includes("document") }, + methods: { - ...mapActions("incident", ["createAllResources", "isPluginEnabled"]), + ...mapActions("incident", ["createAllResources", "getEnabledPlugins"]), }, } diff --git a/src/dispatch/static/dispatch/src/incident/store.js b/src/dispatch/static/dispatch/src/incident/store.js index b99ff21e81da..f461181142a3 100644 --- a/src/dispatch/static/dispatch/src/incident/store.js +++ b/src/dispatch/static/dispatch/src/incident/store.js @@ -350,7 +350,6 @@ const actions = { commit("SET_SELECTED_LOADING", true) return IncidentApi.createAllResources(state.selected.id) .then(function () { - dispatch("get") commit( "notification_backend/addBeNotification", { text: "Incident resource(s) created successfully.", type: "success" }, @@ -365,6 +364,7 @@ const actions = { ) }) .finally(() => { + dispatch("get") commit("SET_SELECTED_LOADING", false) }) }, @@ -392,7 +392,7 @@ const actions = { ) }) }, - isPluginEnabled(_, type) { + getEnabledPlugins() { if (!state.selected.project) { return false } @@ -411,16 +411,15 @@ const actions = { op: "==", value: state.selected.project.name, }, - { - model: "Plugin", - field: "type", - op: "==", - value: String(type), - }, ], }), }).then((response) => { - return response.data.items.length > 0 + return response.data.items.reduce((result, item) => { + if (item.plugin) { + result.push(item.plugin.type) + } + return result + }, []) }) }, }