Skip to content

Commit c3b8282

Browse files
Updated ConfirmationDialog to KModal and also Updated repective unit test file to handle KModal
1 parent eea9a89 commit c3b8282

File tree

2 files changed

+56
-25
lines changed

2 files changed

+56
-25
lines changed

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

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
<template>
22

33
<div>
4-
<ConfirmationDialog
5-
v-model="deleteDialog"
6-
title="Delete user"
7-
:text="`Are you sure you want to permanently delete ${user.name}'s account?`"
8-
confirmButtonText="Delete"
4+
<KModal
5+
v-if="deleteDialog"
6+
:title="$tr('deleteUserTitle')"
7+
:submitText="$tr('deleteAction')"
8+
:cancelText="$tr('cancelAction')"
99
data-test="confirm-delete"
10-
@confirm="deleteHandler"
11-
/>
12-
<ConfirmationDialog
13-
v-model="deactivateDialog"
14-
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"
10+
@submit="deleteHandler"
11+
@cancel="deleteDialog = false"
12+
>
13+
<div class="kmodal-confirmation-content">
14+
<p>{{ $tr('deleteUserMessage', { name: user.name }) }}</p>
15+
</div>
16+
</KModal>
17+
18+
<KModal
19+
v-if="deactivateDialog"
20+
:title="$tr('deactivateUserTitle')"
21+
:submitText="$tr('deactivateAction')"
22+
:cancelText="$tr('cancelAction')"
2023
data-test="confirm-deactivate"
21-
@confirm="deactivateHandler"
22-
/>
24+
@submit="deactivateHandler"
25+
@cancel="deactivateDialog = false"
26+
>
27+
<div class="kmodal-confirmation-content">
28+
<p>{{ $tr('deactivateUserMessage', { name: user.name }) }}</p>
29+
</div>
30+
</KModal>
2331
<UserPrivilegeModal
2432
v-model="addAdminPrivilegeDialog"
2533
header="Add admin privileges"
@@ -106,14 +114,14 @@
106114
<script>
107115
108116
import { mapActions, mapGetters, mapState } from 'vuex';
109-
import ConfirmationDialog from '../../components/ConfirmationDialog';
117+
110118
import EmailUsersDialog from './EmailUsersDialog';
111119
import UserPrivilegeModal from './UserPrivilegeModal';
112120
113121
export default {
114122
name: 'UserActionsDropdown',
115123
components: {
116-
ConfirmationDialog,
124+
117125
EmailUsersDialog,
118126
UserPrivilegeModal,
119127
},
@@ -174,9 +182,32 @@
174182
});
175183
},
176184
},
185+
$trs: {
186+
deleteUserTitle: 'Delete user',
187+
deleteAction: 'Delete',
188+
deleteUserMessage: "Are you sure you want to permanently delete {name}'s account?",
189+
deactivateUserTitle: 'Deactivate user',
190+
deactivateAction: 'Deactivate',
191+
deactivateUserMessage: "Deactivating {name}'s account will block them from accessing their account. Are you sure you want to continue?",
192+
cancelAction: 'Cancel',
193+
},
177194
};
178195
179196
</script>
180197

181198

182-
<style lang="scss" scoped></style>
199+
<style lang="scss" scoped>
200+
201+
.kmodal-confirmation-content {
202+
color: #212121;
203+
white-space: normal;
204+
text-align: left;
205+
}
206+
207+
::v-deep .title {
208+
color: #212121;
209+
text-align: left;
210+
font-weight: bold;
211+
}
212+
213+
</style>

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

Lines changed: 5 additions & 5 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

@@ -119,4 +119,4 @@ describe('userActionsDropdown', () => {
119119
expect(mocks.updateUser).toHaveBeenCalledWith({ id: userId, is_admin: false });
120120
});
121121
});
122-
});
122+
});

0 commit comments

Comments
 (0)