Skip to content

Commit 242a6f7

Browse files
[Remove Vuetify from Studio] Deactivate and delete confirmation dialogs in admin user actions (#5426)
* Updated ConfirmationDialog to KModal and also Updated repective unit test file to handle KModal * made some changes * removed i18 strings * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 88dea36 commit 242a6f7

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

contentcuration/contentcuration/frontend/administration/pages/Users/UserActionsDropdown.vue

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
<template>
22

33
<div>
4-
<ConfirmationDialog
5-
v-model="deleteDialog"
4+
<KModal
5+
v-if="deleteDialog"
66
title="Delete user"
7-
:text="`Are you sure you want to permanently delete ${user.name}'s account?`"
8-
confirmButtonText="Delete"
7+
submitText="Delete"
8+
cancelText="Cancel"
99
data-test="confirm-delete"
10-
@confirm="deleteHandler"
11-
/>
12-
<ConfirmationDialog
13-
v-model="deactivateDialog"
10+
@submit="deleteHandler"
11+
@cancel="deleteDialog = false"
12+
>
13+
<p>Are you sure you want to permanently delete {{ user.name }}'s account?</p>
14+
</KModal>
15+
16+
<KModal
17+
v-if="deactivateDialog"
1418
title="Deactivate user"
15-
:text="
16-
`Deactivating ${user.name}'s account will block them from ` +
17-
`accessing their account. Are you sure you want to continue?`
18-
"
19-
confirmButtonText="Deactivate"
19+
submitText="Deactivate"
20+
cancelText="Cancel"
2021
data-test="confirm-deactivate"
21-
@confirm="deactivateHandler"
22-
/>
22+
@submit="deactivateHandler"
23+
@cancel="deactivateDialog = false"
24+
>
25+
<p>
26+
Deactivating {{ user.name }}'s account will block them from accessing their account. Are you
27+
sure you want to continue?
28+
</p>
29+
</KModal>
2330
<UserPrivilegeModal
2431
v-model="addAdminPrivilegeDialog"
2532
header="Add admin privileges"
@@ -106,14 +113,13 @@
106113
<script>
107114
108115
import { mapActions, mapGetters, mapState } from 'vuex';
109-
import ConfirmationDialog from '../../components/ConfirmationDialog';
116+
110117
import EmailUsersDialog from './EmailUsersDialog';
111118
import UserPrivilegeModal from './UserPrivilegeModal';
112119
113120
export default {
114121
name: 'UserActionsDropdown',
115122
components: {
116-
ConfirmationDialog,
117123
EmailUsersDialog,
118124
UserPrivilegeModal,
119125
},

contentcuration/contentcuration/frontend/administration/pages/Users/__tests__/userActionsDropdown.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe('userActionsDropdown', () => {
7171
});
7272

7373
it('confirm delete user should call deleteUser', async () => {
74-
wrapper.find('[data-test="confirm-delete"]').vm.$emit('confirm');
75-
await wrapper.vm.$nextTick();
74+
await wrapper.findComponent('[data-test="delete"]').trigger('click');
75+
wrapper.findComponent('[data-test="confirm-delete"]').vm.$emit('submit');
7676
expect(mocks.deleteUser).toHaveBeenCalledWith(userId);
7777
});
7878

@@ -93,8 +93,8 @@ describe('userActionsDropdown', () => {
9393
});
9494

9595
it('confirm deactivate should call updateUser with is_active = false', async () => {
96-
wrapper.findComponent('[data-test="confirm-deactivate"]').vm.$emit('confirm');
97-
await wrapper.vm.$nextTick();
96+
await wrapper.findComponent('[data-test="deactivate"]').trigger('click');
97+
wrapper.findComponent('[data-test="confirm-deactivate"]').vm.$emit('submit');
9898
expect(mocks.updateUser).toHaveBeenCalledWith({ id: userId, is_active: false });
9999
});
100100

0 commit comments

Comments
 (0)