diff --git a/app/javascript/dashboard/api/helpCenter/portals.js b/app/javascript/dashboard/api/helpCenter/portals.js index ec9528f73..a71f18f5c 100644 --- a/app/javascript/dashboard/api/helpCenter/portals.js +++ b/app/javascript/dashboard/api/helpCenter/portals.js @@ -9,6 +9,10 @@ class PortalsAPI extends ApiClient { updatePortal({ portalSlug, params }) { return axios.patch(`${this.url}/${portalSlug}`, params); } + + deletePortal(portalSlug) { + return axios.delete(`${this.url}/${portalSlug}`); + } } export default PortalsAPI; diff --git a/app/javascript/dashboard/assets/scss/widgets/_modal.scss b/app/javascript/dashboard/assets/scss/widgets/_modal.scss index 68ea09589..fc497f069 100644 --- a/app/javascript/dashboard/assets/scss/widgets/_modal.scss +++ b/app/javascript/dashboard/assets/scss/widgets/_modal.scss @@ -85,7 +85,7 @@ .modal-footer { @include flex; - @include flex-align($x: flex-start, $y: middle); + @include flex-align($x: flex-end, $y: middle); padding: $space-small $zero; button { diff --git a/app/javascript/dashboard/components/ModalHeader.vue b/app/javascript/dashboard/components/ModalHeader.vue index 0f8d8931c..b60f5d851 100644 --- a/app/javascript/dashboard/components/ModalHeader.vue +++ b/app/javascript/dashboard/components/ModalHeader.vue @@ -6,6 +6,9 @@

{{ headerContent }} + + {{ headerContentValue }} +

@@ -22,6 +25,10 @@ export default { type: String, default: '', }, + headerContentValue: { + type: String, + default: '', + }, headerImage: { type: String, default: '', @@ -32,5 +39,8 @@ export default { diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue b/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue index 861805589..319aa5fc1 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue @@ -5,9 +5,10 @@ {{ $t(`SIDEBAR.${menuItem.label}`) }}
@@ -126,7 +147,9 @@ 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.SUB_TEXT' ) }} - {{ portal.header_text }} + + {{ portal.header_text }} +
@@ -148,6 +171,16 @@ + @@ -155,12 +188,14 @@ import thumbnail from 'dashboard/components/widgets/Thumbnail'; import Label from 'dashboard/components/ui/Label'; import LocaleItemTable from './PortalListItemTable'; +import alertMixin from 'shared/mixins/alertMixin'; export default { components: { thumbnail, Label, LocaleItemTable, }, + mixins: [alertMixin], props: { portal: { type: Object, @@ -172,6 +207,13 @@ export default { values: ['archived', 'draft', 'published'], }, }, + data() { + return { + showDeleteConfirmationPopup: false, + alertMessage: '', + selectedPortalForDelete: {}, + }; + }, computed: { labelColor() { switch (this.status) { @@ -181,6 +223,10 @@ export default { return 'success'; } }, + // Delete portal modal + deleteMessageValue() { + return ` ${this.selectedPortalForDelete.name}?`; + }, locales() { return this.portal ? this.portal.config.allowed_locales : []; @@ -196,6 +242,34 @@ export default { openSettings() { this.navigateToPortalEdit(); }, + onClickOpenDeleteModal(portal) { + this.selectedPortalForDelete = portal; + this.showDeleteConfirmationPopup = true; + }, + closeDeletePopup() { + this.showDeleteConfirmationPopup = false; + }, + async onClickDeletePortal() { + const { slug } = this.selectedPortalForDelete; + try { + await this.$store.dispatch('portals/delete', { + portalSlug: slug, + }); + this.selectedPortalForDelete = {}; + this.closeDeletePopup(); + this.alertMessage = this.$t( + 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.API.DELETE_SUCCESS' + ); + } catch (error) { + this.alertMessage = + error?.message || + this.$t( + 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.API.DELETE_ERROR' + ); + } finally { + this.showAlert(this.alertMessage); + } + }, swapLocale() { this.$emit('swap'); }, diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/portals/ListAllPortals.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/portals/ListAllPortals.vue index 88501c9bc..9d7d09ae7 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/portals/ListAllPortals.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/portals/ListAllPortals.vue @@ -33,6 +33,7 @@