feat: Ask to confirm with name before inbox/team deletion (#2370)

This commit is contained in:
Muhsin Keloth
2021-06-04 13:17:44 +05:30
committed by GitHub
parent 562a65a70d
commit 8a283a7783
6 changed files with 118 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ import Button from './ui/WootButton';
import Code from './Code'; import Code from './Code';
import ColorPicker from './widgets/ColorPicker'; import ColorPicker from './widgets/ColorPicker';
import DeleteModal from './widgets/modal/DeleteModal.vue'; import DeleteModal from './widgets/modal/DeleteModal.vue';
import ConfirmDeleteModal from './widgets/modal/ConfirmDeleteModal.vue';
import DropdownItem from 'shared/components/ui/dropdown/DropdownItem'; import DropdownItem from 'shared/components/ui/dropdown/DropdownItem';
import DropdownMenu from 'shared/components/ui/dropdown/DropdownMenu'; import DropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
import Input from './widgets/forms/Input.vue'; import Input from './widgets/forms/Input.vue';
@@ -42,6 +43,7 @@ const WootUIKit = {
Tabs, Tabs,
TabsItem, TabsItem,
Thumbnail, Thumbnail,
ConfirmDeleteModal,
install(Vue) { install(Vue) {
const keys = Object.keys(this); const keys = Object.keys(this);
keys.pop(); // remove 'install' from keys keys.pop(); // remove 'install' from keys

View File

@@ -0,0 +1,86 @@
<template>
<modal :show.sync="show" :on-close="closeModal">
<woot-modal-header :header-title="title" :header-content="message" />
<form @submit.prevent="onConfirm">
<woot-input
v-model="value"
type="text"
:class="{ error: $v.value.$error }"
:placeholder="confirmPlaceHolderText"
@blur="$v.value.$touch"
/>
<div class="button-wrapper">
<woot-button color-scheme="alert" :is-disabled="$v.value.$invalid">
{{ confirmText }}
</woot-button>
<woot-button class="clear" @click.prevent="closeModal">
{{ rejectText }}
</woot-button>
</div>
</form>
</modal>
</template>
<script>
import { required } from 'vuelidate/lib/validators';
import Modal from '../../Modal';
export default {
components: {
Modal,
},
props: {
show: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
message: {
type: String,
default: '',
},
confirmText: {
type: String,
default: '',
},
rejectText: {
type: String,
default: '',
},
confirmValue: {
type: String,
default: '',
},
confirmPlaceHolderText: {
type: String,
default: '',
},
},
data() {
return {
value: '',
};
},
validations: {
value: {
required,
isEqual(value) {
return value === this.confirmValue;
},
},
},
methods: {
closeModal() {
this.value = '';
this.$emit('on-close');
},
onConfirm() {
this.$emit('on-confirm');
},
},
};
</script>

View File

@@ -215,6 +215,7 @@
"CONFIRM": { "CONFIRM": {
"TITLE": "Confirm Deletion", "TITLE": "Confirm Deletion",
"MESSAGE": "Are you sure to delete ", "MESSAGE": "Are you sure to delete ",
"PLACE_HOLDER": "Please type {inboxName} to confirm",
"YES": "Yes, Delete ", "YES": "Yes, Delete ",
"NO": "No, Keep " "NO": "No, Keep "
}, },

View File

@@ -17,7 +17,8 @@
"TITLE": "Add agents to team - %{teamName}", "TITLE": "Add agents to team - %{teamName}",
"DESC": "Add Agents to your newly created team. This lets you collaborate as a team on conversations, get notified on new events in the same conversation." "DESC": "Add Agents to your newly created team. This lets you collaborate as a team on conversations, get notified on new events in the same conversation."
}, },
"WIZARD": [{ "WIZARD": [
{
"title": "Create", "title": "Create",
"route": "settings_teams_new", "route": "settings_teams_new",
"body": "Create a new team of agents." "body": "Create a new team of agents."
@@ -45,7 +46,8 @@
"TITLE": "Add agents to team - %{teamName}", "TITLE": "Add agents to team - %{teamName}",
"DESC": "Add Agents to your newly created team. All the added agents will be notified when a conversation is assigned to this team." "DESC": "Add Agents to your newly created team. All the added agents will be notified when a conversation is assigned to this team."
}, },
"WIZARD": [{ "WIZARD": [
{
"title": "Team details", "title": "Team details",
"route": "settings_teams_edit", "route": "settings_teams_edit",
"body": "Change name, description and other details." "body": "Change name, description and other details."
@@ -97,6 +99,7 @@
}, },
"CONFIRM": { "CONFIRM": {
"TITLE": "Are you sure want to delete - %{teamName}", "TITLE": "Are you sure want to delete - %{teamName}",
"PLACE_HOLDER": "Please type {teamName} to confirm",
"MESSAGE": "Deleting the team will remove the team assignment from the conversations assigned to this team.", "MESSAGE": "Deleting the team will remove the team assignment from the conversations assigned to this team.",
"YES": "Delete ", "YES": "Delete ",
"NO": "Cancel" "NO": "Cancel"

View File

@@ -106,14 +106,16 @@
:inbox="selectedInbox" :inbox="selectedInbox"
/> />
<woot-delete-modal <woot-confirm-delete-modal
:show.sync="showDeletePopup" :show.sync="showDeletePopup"
:on-close="closeDelete"
:on-confirm="confirmDeletion"
:title="$t('INBOX_MGMT.DELETE.CONFIRM.TITLE')" :title="$t('INBOX_MGMT.DELETE.CONFIRM.TITLE')"
:message="deleteMessage" :message="confirmDeleteMessage"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
:confirm-value="selectedInbox.name"
:confirm-place-holder-text="confirmPlaceHolderText"
@on-confirm="confirmDeletion"
@on-close="closeDelete"
/> />
</div> </div>
</template> </template>
@@ -153,11 +155,16 @@ export default {
this.selectedInbox.name this.selectedInbox.name
}`; }`;
}, },
deleteMessage() { confirmDeleteMessage() {
return `${this.$t('INBOX_MGMT.DELETE.CONFIRM.MESSAGE')} ${ return `${this.$t('INBOX_MGMT.DELETE.CONFIRM.MESSAGE')} ${
this.selectedInbox.name this.selectedInbox.name
} ?`; } ?`;
}, },
confirmPlaceHolderText() {
return `${this.$t('INBOX_MGMT.DELETE.CONFIRM.PLACE_HOLDER', {
inboxName: this.selectedInbox.name,
})}`;
},
}, },
methods: { methods: {
openSettings(inbox) { openSettings(inbox) {

View File

@@ -63,15 +63,16 @@
/> />
</div> </div>
</div> </div>
<woot-confirm-delete-modal
<woot-delete-modal
:show.sync="showDeletePopup" :show.sync="showDeletePopup"
:on-close="closeDelete" :title="confirmDeleteTitle"
:on-confirm="confirmDeletion"
:title="deleteTitle"
:message="$t('TEAMS_SETTINGS.DELETE.CONFIRM.MESSAGE')" :message="$t('TEAMS_SETTINGS.DELETE.CONFIRM.MESSAGE')"
:confirm-text="deleteConfirmText" :confirm-text="deleteConfirmText"
:reject-text="deleteRejectText" :reject-text="deleteRejectText"
:confirm-value="selectedTeam.name"
:confirm-place-holder-text="confirmPlaceHolderText"
@on-confirm="confirmDeletion"
@on-close="closeDelete"
/> />
</div> </div>
</template> </template>
@@ -105,11 +106,16 @@ export default {
deleteRejectText() { deleteRejectText() {
return this.$t('TEAMS_SETTINGS.DELETE.CONFIRM.NO'); return this.$t('TEAMS_SETTINGS.DELETE.CONFIRM.NO');
}, },
deleteTitle() { confirmDeleteTitle() {
return this.$t('TEAMS_SETTINGS.DELETE.CONFIRM.TITLE', { return this.$t('TEAMS_SETTINGS.DELETE.CONFIRM.TITLE', {
teamName: this.selectedTeam.name, teamName: this.selectedTeam.name,
}); });
}, },
confirmPlaceHolderText() {
return `${this.$t('TEAMS_SETTINGS.DELETE.CONFIRM.PLACE_HOLDER', {
teamName: this.selectedTeam.name,
})}`;
},
}, },
methods: { methods: {
async deleteTeam({ id }) { async deleteTeam({ id }) {