feat: Adds the ability to delete a portal (#5305)

This commit is contained in:
Sivin Varghese 2022-09-01 13:27:08 +05:30 committed by GitHub
parent 6e945dd61e
commit f4fc53b425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 158 additions and 48 deletions

View file

@ -9,6 +9,10 @@ class PortalsAPI extends ApiClient {
updatePortal({ portalSlug, params }) { updatePortal({ portalSlug, params }) {
return axios.patch(`${this.url}/${portalSlug}`, params); return axios.patch(`${this.url}/${portalSlug}`, params);
} }
deletePortal(portalSlug) {
return axios.delete(`${this.url}/${portalSlug}`);
}
} }
export default PortalsAPI; export default PortalsAPI;

View file

@ -85,7 +85,7 @@
.modal-footer { .modal-footer {
@include flex; @include flex;
@include flex-align($x: flex-start, $y: middle); @include flex-align($x: flex-end, $y: middle);
padding: $space-small $zero; padding: $space-small $zero;
button { button {

View file

@ -6,6 +6,9 @@
</h2> </h2>
<p v-if="headerContent" class="small-12 column wrap-content"> <p v-if="headerContent" class="small-12 column wrap-content">
{{ headerContent }} {{ headerContent }}
<span v-if="headerContentValue" class="content-value">
{{ headerContentValue }}
</span>
</p> </p>
<slot /> <slot />
</div> </div>
@ -22,6 +25,10 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
headerContentValue: {
type: String,
default: '',
},
headerImage: { headerImage: {
type: String, type: String,
default: '', default: '',
@ -32,5 +39,8 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.wrap-content { .wrap-content {
word-wrap: break-word; word-wrap: break-word;
.content-value {
font-weight: var(--font-weight-bold);
}
} }
</style> </style>

View file

@ -5,9 +5,10 @@
{{ $t(`SIDEBAR.${menuItem.label}`) }} {{ $t(`SIDEBAR.${menuItem.label}`) }}
</span> </span>
<div v-if="isHelpCenterSidebar" class="submenu-icons"> <div v-if="isHelpCenterSidebar" class="submenu-icons">
<!-- Hidden since this is in V2
<div class="submenu-icon"> <div class="submenu-icon">
<fluent-icon icon="search" size="16" /> <fluent-icon icon="search" size="16" />
</div> </div> -->
<div class="submenu-icon" @click="onClickOpen"> <div class="submenu-icon" @click="onClickOpen">
<fluent-icon icon="add" size="16" /> <fluent-icon icon="add" size="16" />
</div> </div>

View file

@ -14,7 +14,9 @@
:icon="icon" :icon="icon"
:icon-size="iconSize" :icon-size="iconSize"
/> />
<span v-if="$slots.default" class="button__content"><slot /></span> <span v-if="$slots.default" class="button__content">
<slot />
</span>
</button> </button>
</template> </template>
<script> <script>

View file

@ -1,13 +1,22 @@
<template> <template>
<modal :show.sync="show" :on-close="onClose"> <modal :show.sync="show" :on-close="onClose">
<woot-modal-header :header-title="title" :header-content="message" /> <woot-modal-header
:header-title="title"
:header-content="message"
:header-content-value="messageValue"
/>
<div class="modal-footer delete-item"> <div class="modal-footer delete-item">
<button class="alert button nice text-truncate" @click="onConfirm"> <woot-button variant="clear" class="action-button" @click="onClose">
{{ confirmText }}
</button>
<button class="button clear text-truncate" @click="onClose">
{{ rejectText }} {{ rejectText }}
</button> </woot-button>
<woot-button
color-scheme="alert"
class="action-button"
variant="smooth"
@click="onConfirm"
>
{{ confirmText }}
</woot-button>
</div> </div>
</modal> </modal>
</template> </template>
@ -25,8 +34,14 @@ export default {
onConfirm: { type: Function, default: () => {} }, onConfirm: { type: Function, default: () => {} },
title: { type: String, default: '' }, title: { type: String, default: '' },
message: { type: String, default: '' }, message: { type: String, default: '' },
messageValue: { type: String, default: '' },
confirmText: { type: String, default: '' }, confirmText: { type: String, default: '' },
rejectText: { type: String, default: '' }, rejectText: { type: String, default: '' },
}, },
}; };
</script> </script>
<style lang="scss" scoped>
.action-button {
max-width: var(--space-giga);
}
</style>

View file

@ -84,7 +84,8 @@
"COUNT_LABEL": "articles", "COUNT_LABEL": "articles",
"ADD": "Add locale", "ADD": "Add locale",
"VISIT": "Visit site", "VISIT": "Visit site",
"SETTINGS": "Settings" "SETTINGS": "Settings",
"DELETE": "Delete"
}, },
"PORTAL_CONFIG": { "PORTAL_CONFIG": {
"TITLE": "Portal Configurations", "TITLE": "Portal Configurations",
@ -109,6 +110,16 @@
"DEFAULT_LOCALE": "Default" "DEFAULT_LOCALE": "Default"
} }
} }
},
"DELETE_PORTAL": {
"TITLE": "Delete portal",
"MESSAGE": "Are you sure you want to delete this portal",
"YES": "Yes, delete portal",
"NO": "No, keep portal",
"API": {
"DELETE_SUCCESS": "Portal deleted successfully",
"DELETE_ERROR": "Error while deleting portal"
}
} }
}, },
"ADD": { "ADD": {

View file

@ -131,7 +131,8 @@
:on-close="closeDelete" :on-close="closeDelete"
:on-confirm="confirmDeletion" :on-confirm="confirmDeletion"
:title="$t('DELETE_CONTACT.CONFIRM.TITLE')" :title="$t('DELETE_CONTACT.CONFIRM.TITLE')"
:message="confirmDeleteMessage" :message="$t('DELETE_CONTACT.CONFIRM.MESSAGE')"
:message-value="confirmDeleteMessage"
:confirm-text="$t('DELETE_CONTACT.CONFIRM.YES')" :confirm-text="$t('DELETE_CONTACT.CONFIRM.YES')"
:reject-text="$t('DELETE_CONTACT.CONFIRM.NO')" :reject-text="$t('DELETE_CONTACT.CONFIRM.NO')"
/> />
@ -215,9 +216,7 @@ export default {
}, },
// Delete Modal // Delete Modal
confirmDeleteMessage() { confirmDeleteMessage() {
return `${this.$t('DELETE_CONTACT.CONFIRM.MESSAGE')} ${ return ` ${this.contact.name}?`;
this.contact.name
} ?`;
}, },
}, },
methods: { methods: {

View file

@ -6,7 +6,8 @@
:on-close="closeDeletePopup" :on-close="closeDeletePopup"
:on-confirm="deleteSavedCustomViews" :on-confirm="deleteSavedCustomViews"
:title="$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.TITLE')" :title="$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.TITLE')"
:message="deleteMessage" :message="$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
/> />
@ -51,9 +52,7 @@ export default {
return ''; return '';
}, },
deleteMessage() { deleteMessage() {
return `${this.$t( return ` ${this.activeCustomView && this.activeCustomView.name}?`;
'FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.MESSAGE'
)} ${this.activeCustomView && this.activeCustomView.name} ?`;
}, },
deleteConfirmText() { deleteConfirmText() {
return `${this.$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.YES')}`; return `${this.$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.YES')}`;

View file

@ -26,6 +26,7 @@
> >
{{ $t('HELP_CENTER.EDIT_HEADER.PREVIEW') }} {{ $t('HELP_CENTER.EDIT_HEADER.PREVIEW') }}
</woot-button> </woot-button>
<!-- Hidden since this is in V2
<woot-button <woot-button
class-names="article--buttons" class-names="article--buttons"
icon="add" icon="add"
@ -35,7 +36,7 @@
@click="onClickAdd" @click="onClickAdd"
> >
{{ $t('HELP_CENTER.EDIT_HEADER.ADD_TRANSLATION') }} {{ $t('HELP_CENTER.EDIT_HEADER.ADD_TRANSLATION') }}
</woot-button> </woot-button> -->
<woot-button <woot-button
v-if="!isSidebarOpen" v-if="!isSidebarOpen"
v-tooltip.top-end="$t('HELP_CENTER.EDIT_HEADER.OPEN_SIDEBAR')" v-tooltip.top-end="$t('HELP_CENTER.EDIT_HEADER.OPEN_SIDEBAR')"

View file

@ -6,7 +6,9 @@
<header> <header>
<div> <div>
<div class="title-status--wrap"> <div class="title-status--wrap">
<h2 class="portal-title block-title">{{ portal.name }}</h2> <h2 class="portal-title block-title">
{{ portal.name }}
</h2>
<Label <Label
:title="status" :title="status"
:color-scheme="labelColor" :color-scheme="labelColor"
@ -59,6 +61,17 @@
color-scheme="secondary" color-scheme="secondary"
@click="openSettings" @click="openSettings"
/> />
<woot-button
v-tooltip.top-end="
$t('HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.HEADER.DELETE')
"
variant="hollow"
color-scheme="alert"
size="small"
icon="delete"
class="header-action-buttons"
@click="onClickOpenDeleteModal(portal)"
/>
</div> </div>
</header> </header>
<div class="portal-locales"> <div class="portal-locales">
@ -77,7 +90,9 @@
'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.NAME' 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.NAME'
) )
}}</label> }}</label>
<span class="text-block-title">{{ portal.name }}</span> <span class="text-block-title">
{{ portal.name }}
</span>
</div> </div>
<div class="configuration-item"> <div class="configuration-item">
<label>{{ <label>{{
@ -85,7 +100,9 @@
'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.DOMAIN' 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.DOMAIN'
) )
}}</label> }}</label>
<span class="text-block-title">{{ portal.custom_domain }}</span> <span class="text-block-title">
{{ portal.custom_domain }}
</span>
</div> </div>
</div> </div>
<div class="configuration-items"> <div class="configuration-items">
@ -95,7 +112,9 @@
'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.SLUG' 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.SLUG'
) )
}}</label> }}</label>
<span class="text-block-title">{{ portal.slug }}</span> <span class="text-block-title">
{{ portal.slug }}
</span>
</div> </div>
<div class="configuration-item"> <div class="configuration-item">
<label>{{ <label>{{
@ -103,7 +122,9 @@
'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.TITLE' 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.TITLE'
) )
}}</label> }}</label>
<span class="text-block-title">{{ portal.page_title }}</span> <span class="text-block-title">
{{ portal.page_title }}
</span>
</div> </div>
</div> </div>
<div class="configuration-items"> <div class="configuration-items">
@ -126,7 +147,9 @@
'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.SUB_TEXT' 'HELP_CENTER.PORTAL.PORTAL_SETTINGS.LIST_ITEM.PORTAL_CONFIG.ITEMS.SUB_TEXT'
) )
}}</label> }}</label>
<span class="text-block-title">{{ portal.header_text }}</span> <span class="text-block-title">
{{ portal.header_text }}
</span>
</div> </div>
</div> </div>
</div> </div>
@ -148,6 +171,16 @@
</div> </div>
</div> </div>
</div> </div>
<woot-delete-modal
:show.sync="showDeleteConfirmationPopup"
:on-close="closeDeletePopup"
:on-confirm="onClickDeletePortal"
:title="$t('HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.TITLE')"
:message="$t('HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.MESSAGE')"
:message-value="deleteMessageValue"
:confirm-text="$t('HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.YES')"
:reject-text="$t('HELP_CENTER.PORTAL.PORTAL_SETTINGS.DELETE_PORTAL.NO')"
/>
</div> </div>
</template> </template>
@ -155,12 +188,14 @@
import thumbnail from 'dashboard/components/widgets/Thumbnail'; import thumbnail from 'dashboard/components/widgets/Thumbnail';
import Label from 'dashboard/components/ui/Label'; import Label from 'dashboard/components/ui/Label';
import LocaleItemTable from './PortalListItemTable'; import LocaleItemTable from './PortalListItemTable';
import alertMixin from 'shared/mixins/alertMixin';
export default { export default {
components: { components: {
thumbnail, thumbnail,
Label, Label,
LocaleItemTable, LocaleItemTable,
}, },
mixins: [alertMixin],
props: { props: {
portal: { portal: {
type: Object, type: Object,
@ -172,6 +207,13 @@ export default {
values: ['archived', 'draft', 'published'], values: ['archived', 'draft', 'published'],
}, },
}, },
data() {
return {
showDeleteConfirmationPopup: false,
alertMessage: '',
selectedPortalForDelete: {},
};
},
computed: { computed: {
labelColor() { labelColor() {
switch (this.status) { switch (this.status) {
@ -181,6 +223,10 @@ export default {
return 'success'; return 'success';
} }
}, },
// Delete portal modal
deleteMessageValue() {
return ` ${this.selectedPortalForDelete.name}?`;
},
locales() { locales() {
return this.portal ? this.portal.config.allowed_locales : []; return this.portal ? this.portal.config.allowed_locales : [];
@ -196,6 +242,34 @@ export default {
openSettings() { openSettings() {
this.navigateToPortalEdit(); 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() { swapLocale() {
this.$emit('swap'); this.$emit('swap');
}, },

View file

@ -33,6 +33,7 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import alertMixin from 'shared/mixins/alertMixin';
import PortalListItem from '../../components/PortalListItem'; import PortalListItem from '../../components/PortalListItem';
import Spinner from 'shared/components/Spinner.vue'; import Spinner from 'shared/components/Spinner.vue';
import EmptyState from 'dashboard/components/widgets/EmptyState'; import EmptyState from 'dashboard/components/widgets/EmptyState';
@ -44,6 +45,7 @@ export default {
Spinner, Spinner,
AddPortal, AddPortal,
}, },
mixins: [alertMixin],
data() { data() {
return { return {
isAddModalOpen: false, isAddModalOpen: false,

View file

@ -120,9 +120,6 @@ export default {
allowed_locales: ['en'], allowed_locales: ['en'],
}, },
}); });
this.alertMessage = this.$t(
'HELP_CENTER.PORTAL.ADD.API.SUCCESS_MESSAGE_FOR_UPDATE'
);
} catch (error) { } catch (error) {
this.alertMessage = this.alertMessage =
error?.message || error?.message ||

View file

@ -17,6 +17,7 @@
</label> </label>
<div class="logo-container"> <div class="logo-container">
<thumbnail :username="name" size="56" variant="square" /> <thumbnail :username="name" size="56" variant="square" />
<!-- Hidden since this is in V2
<woot-button <woot-button
class="upload-button" class="upload-button"
variant="smooth" variant="smooth"
@ -25,7 +26,7 @@
size="small" size="small"
> >
{{ $t('HELP_CENTER.PORTAL.ADD.LOGO.UPLOAD_BUTTON') }} {{ $t('HELP_CENTER.PORTAL.ADD.LOGO.UPLOAD_BUTTON') }}
</woot-button> </woot-button> -->
</div> </div>
<p class="logo-help--text"> <p class="logo-help--text">
{{ $t('HELP_CENTER.PORTAL.ADD.LOGO.HELP_TEXT') }} {{ $t('HELP_CENTER.PORTAL.ADD.LOGO.HELP_TEXT') }}
@ -145,9 +146,6 @@ export default {
custom_domain: this.domain, custom_domain: this.domain,
}, },
}); });
this.alertMessage = this.$t(
'HELP_CENTER.PORTAL.ADD.API.SUCCESS_MESSAGE_FOR_BASIC'
);
} catch (error) { } catch (error) {
this.alertMessage = this.alertMessage =
error?.message || error?.message ||

View file

@ -117,7 +117,8 @@
:on-close="closeDeletePopup" :on-close="closeDeletePopup"
:on-confirm="confirmDeletion" :on-confirm="confirmDeletion"
:title="$t('AGENT_MGMT.DELETE.CONFIRM.TITLE')" :title="$t('AGENT_MGMT.DELETE.CONFIRM.TITLE')"
:message="deleteMessage" :message="$t('AGENT_MGMT.DELETE.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
/> />
@ -167,9 +168,7 @@ export default {
}`; }`;
}, },
deleteMessage() { deleteMessage() {
return `${this.$t('AGENT_MGMT.DELETE.CONFIRM.MESSAGE')} ${ return ` ${this.currentAgent.name}?`;
this.currentAgent.name
} ?`;
}, },
}, },
mounted() { mounted() {

View file

@ -98,7 +98,8 @@
:on-close="closeDeletePopup" :on-close="closeDeletePopup"
:on-confirm="confirmDeletion" :on-confirm="confirmDeletion"
:title="$t('LABEL_MGMT.DELETE.CONFIRM.TITLE')" :title="$t('LABEL_MGMT.DELETE.CONFIRM.TITLE')"
:message="deleteMessage" :message="$t('AUTOMATION.DELETE.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
/> />
@ -165,9 +166,7 @@ export default {
}`; }`;
}, },
deleteMessage() { deleteMessage() {
return `${this.$t('AUTOMATION.DELETE.CONFIRM.MESSAGE')} ${ return ` ${this.selectedResponse.name}?`;
this.selectedResponse.name
} ?`;
}, },
}, },
mounted() { mounted() {

View file

@ -99,7 +99,8 @@
:on-close="closeDeletePopup" :on-close="closeDeletePopup"
:on-confirm="confirmDeletion" :on-confirm="confirmDeletion"
:title="$t('CANNED_MGMT.DELETE.CONFIRM.TITLE')" :title="$t('CANNED_MGMT.DELETE.CONFIRM.TITLE')"
:message="deleteMessage" :message="$t('CANNED_MGMT.DELETE.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
/> />
@ -144,9 +145,7 @@ export default {
}`; }`;
}, },
deleteMessage() { deleteMessage() {
return `${this.$t('CANNED_MGMT.DELETE.CONFIRM.MESSAGE')} ${ return ` ${this.selectedResponse.short_code}?`;
this.selectedResponse.short_code
} ?`;
}, },
}, },
mounted() { mounted() {

View file

@ -91,7 +91,8 @@
:on-close="closeDeletePopup" :on-close="closeDeletePopup"
:on-confirm="confirmDeletion" :on-confirm="confirmDeletion"
:title="$t('LABEL_MGMT.DELETE.CONFIRM.TITLE')" :title="$t('LABEL_MGMT.DELETE.CONFIRM.TITLE')"
:message="deleteMessage" :message="$t('LABEL_MGMT.DELETE.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
/> />
@ -136,9 +137,7 @@ export default {
}`; }`;
}, },
deleteMessage() { deleteMessage() {
return `${this.$t('LABEL_MGMT.DELETE.CONFIRM.MESSAGE')} ${ return ` ${this.selectedResponse.title}?`;
this.selectedResponse.title
} ?`;
}, },
}, },
mounted() { mounted() {

View file

@ -76,6 +76,7 @@ export const actions = {
}); });
} }
}, },
updatePortal: async ({ commit }, portal) => { updatePortal: async ({ commit }, portal) => {
commit(types.UPDATE_PORTAL_ENTRY, portal); commit(types.UPDATE_PORTAL_ENTRY, portal);
}, },