blob: e59ffbc6f4c0156bd8d76f1f0ac27748dcbfccf8 [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
Yoshie Muranaka3111b6f2020-04-21 19:48:38 -07002 <b-container fluid="xl">
Derick Montague09e45cd2020-01-23 15:45:57 -06003 <page-title />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -06004 <b-row>
jason westoverd36ac8a2025-11-03 20:58:59 -06005 <b-col xl="9" class="text-end">
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -08006 <b-button variant="link" @click="initModalSettings">
Yoshie Muranaka996d2d52019-12-30 09:06:45 -08007 <icon-settings />
Sandeepa Singhb4406162021-07-26 15:05:39 +05308 {{ $t('pageUserManagement.accountPolicySettings') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -08009 </b-button>
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050010 <b-button
11 variant="primary"
Sandeepa Singhb4406162021-07-26 15:05:39 +053012 data-test-id="userManagement-button-addUser"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050013 @click="initModalUser(null)"
14 >
Yoshie Muranaka996d2d52019-12-30 09:06:45 -080015 <icon-add />
Sandeepa Singhb4406162021-07-26 15:05:39 +053016 {{ $t('pageUserManagement.addUser') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -080017 </b-button>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060018 </b-col>
19 </b-row>
20 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080021 <b-col xl="9">
Yoshie Muranaka183c2752020-02-12 11:30:49 -080022 <table-toolbar
23 ref="toolbar"
jason westoverd36ac8a2025-11-03 20:58:59 -060024 :selected-items-count="
25 Array.isArray(selectedRows) ? selectedRows.length : 0
26 "
Yoshie Muranaka183c2752020-02-12 11:30:49 -080027 :actions="tableToolbarActions"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053028 @clear-selected="clearSelectedRows($refs.table)"
29 @batch-action="onBatchAction"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080030 />
31 <b-table
32 ref="table"
SurenNeware5e25e282020-07-08 15:57:23 +053033 responsive="md"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080034 selectable
SurenNeware307382e2020-07-27 20:45:14 +053035 show-empty
Yoshie Muranaka183c2752020-02-12 11:30:49 -080036 no-select-on-click
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053037 hover
jason westoverd36ac8a2025-11-03 20:58:59 -060038 thead-class="table-light"
Kenneth Fullbright41057852021-12-27 16:19:37 -060039 :busy="isBusy"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080040 :fields="fields"
41 :items="tableItems"
SurenNeware307382e2020-07-27 20:45:14 +053042 :empty-text="$t('global.table.emptyMessage')"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080043 @row-selected="onRowSelected($event, tableItems.length)"
44 >
45 <!-- Checkbox column -->
Derick Montague602e98a2020-10-21 16:20:00 -050046 <template #head(checkbox)>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080047 <b-form-checkbox
48 v-model="tableHeaderCheckboxModel"
Sandeepa Singhb4406162021-07-26 15:05:39 +053049 data-test-id="userManagement-checkbox-tableHeaderCheckbox"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080050 :indeterminate="tableHeaderCheckboxIndeterminate"
jason westoverd36ac8a2025-11-03 20:58:59 -060051 @change="onChangeHeaderCheckbox($refs.table, $event)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060052 >
jason westoverd36ac8a2025-11-03 20:58:59 -060053 <span class="visually-hidden-focusable">
54 {{ $t('global.table.selectAll') }}
55 </span>
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060056 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080057 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050058 <template #cell(checkbox)="row">
Yoshie Muranaka183c2752020-02-12 11:30:49 -080059 <b-form-checkbox
60 v-model="row.rowSelected"
Sandeepa Singhb4406162021-07-26 15:05:39 +053061 data-test-id="userManagement-checkbox-toggleSelectRow"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080062 @change="toggleSelectRow($refs.table, row.index)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060063 >
jason westoverd36ac8a2025-11-03 20:58:59 -060064 <span class="visually-hidden-focusable">
65 {{ $t('global.table.selectItem') }}
66 </span>
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060067 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080068 </template>
69
70 <!-- table actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -050071 <template #cell(actions)="{ item }">
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080072 <table-row-action
73 v-for="(action, index) in item.actions"
74 :key="index"
75 :value="action.value"
76 :enabled="action.enabled"
Yoshie Muranakaeaa04802020-02-28 13:21:27 -080077 :title="action.title"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053078 @click-table-action="onTableRowAction($event, item)"
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060079 >
Derick Montague602e98a2020-10-21 16:20:00 -050080 <template #icon>
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050081 <icon-edit
82 v-if="action.value === 'edit'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053083 :data-test-id="`userManagement-tableRowAction-edit-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050084 />
85 <icon-trashcan
86 v-if="action.value === 'delete'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053087 :data-test-id="`userManagement-tableRowAction-delete-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050088 />
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080089 </template>
90 </table-row-action>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060091 </template>
92 </b-table>
93 </b-col>
94 </b-row>
95 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080096 <b-col xl="8">
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050097 <b-button
Sandeepa Singhb4406162021-07-26 15:05:39 +053098 data-test-id="userManagement-button-viewPrivilegeRoleDescriptions"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050099 variant="link"
100 class="mt-3"
jason westoverd36ac8a2025-11-03 20:58:59 -0600101 @click="showRoles = !showRoles"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -0500102 >
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800103 <icon-chevron />
Sandeepa Singhb4406162021-07-26 15:05:39 +0530104 {{ $t('pageUserManagement.viewPrivilegeRoleDescriptions') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800105 </b-button>
jason westoverd36ac8a2025-11-03 20:58:59 -0600106 <b-collapse id="collapse-role-table" :visible="showRoles" class="mt-3">
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800107 <table-roles />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600108 </b-collapse>
109 </b-col>
110 </b-row>
111 <!-- Modals -->
jason westoverd36ac8a2025-11-03 20:58:59 -0600112 <modal-settings
113 v-model="showSettingsModal"
114 :settings="setting"
115 @ok="saveAccountSettings"
116 />
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800117 <modal-user
jason westoverd36ac8a2025-11-03 20:58:59 -0600118 v-model="showUserModal"
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800119 :user="activeUser"
120 :password-requirements="passwordRequirements"
121 @ok="saveUser"
Yoshie Muranaka791622b2020-04-17 13:55:16 -0700122 @hidden="activeUser = null"
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800123 />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600124 </b-container>
Derick Montaguea2988f42020-01-17 13:46:30 -0600125</template>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600126
127<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -0600128import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
129import IconEdit from '@carbon/icons-vue/es/edit/20';
130import IconAdd from '@carbon/icons-vue/es/add--alt/20';
131import IconSettings from '@carbon/icons-vue/es/settings/20';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800132import IconChevron from '@carbon/icons-vue/es/chevron--up/20';
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800133
Derick Montaguee2fd1562019-12-20 13:26:53 -0600134import ModalUser from './ModalUser';
135import ModalSettings from './ModalSettings';
SurenNeware5e25e282020-07-08 15:57:23 +0530136import PageTitle from '@/components/Global/PageTitle';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800137import TableRoles from './TableRoles';
SurenNeware5e25e282020-07-08 15:57:23 +0530138import TableToolbar from '@/components/Global/TableToolbar';
139import TableRowAction from '@/components/Global/TableRowAction';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800140
SurenNewareba91c492020-10-27 14:18:54 +0530141import BVTableSelectableMixin, {
142 selectedRows,
143 tableHeaderCheckboxModel,
144 tableHeaderCheckboxIndeterminate,
145} from '@/components/Mixins/BVTableSelectableMixin';
SurenNeware5e25e282020-07-08 15:57:23 +0530146import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700147import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Surya Vde23ea22024-07-11 15:19:46 +0530148import { useI18n } from 'vue-i18n';
149import i18n from '@/i18n';
jason westoverd36ac8a2025-11-03 20:58:59 -0600150import { useModal } from 'bootstrap-vue-next';
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600151
152export default {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530153 name: 'UserManagement',
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600154 components: {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800155 IconAdd,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800156 IconChevron,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800157 IconEdit,
158 IconSettings,
159 IconTrashcan,
160 ModalSettings,
161 ModalUser,
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800162 PageTitle,
Yoshie Muranaka8d129102019-12-19 09:51:55 -0800163 TableRoles,
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800164 TableRowAction,
Derick Montague602e98a2020-10-21 16:20:00 -0500165 TableToolbar,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800166 },
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700167 mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500168 beforeRouteLeave(to, from, next) {
169 this.hideLoader();
170 next();
171 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600172 setup() {
173 const bvModal = useModal();
174 return { bvModal };
175 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800176 data() {
177 return {
Surya Vde23ea22024-07-11 15:19:46 +0530178 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600179 isBusy: true,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800180 activeUser: null,
kirankumarb076ad19aa2023-03-21 19:19:02 +0530181 setting: {},
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800182 fields: [
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800183 {
Derick Montague602e98a2020-10-21 16:20:00 -0500184 key: 'checkbox',
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800185 },
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800186 {
187 key: 'username',
Surya Vde23ea22024-07-11 15:19:46 +0530188 label: i18n.global.t('pageUserManagement.table.username'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800189 },
190 {
191 key: 'privilege',
Surya Vde23ea22024-07-11 15:19:46 +0530192 label: i18n.global.t('pageUserManagement.table.privilege'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800193 },
194 {
195 key: 'status',
Surya Vde23ea22024-07-11 15:19:46 +0530196 label: i18n.global.t('pageUserManagement.table.status'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800197 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800198 {
199 key: 'actions',
200 label: '',
jason westoverd36ac8a2025-11-03 20:58:59 -0600201 tdClass: 'text-end text-nowrap',
Derick Montague602e98a2020-10-21 16:20:00 -0500202 },
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800203 ],
204 tableToolbarActions: [
205 {
206 value: 'delete',
Surya Vde23ea22024-07-11 15:19:46 +0530207 label: i18n.global.t('global.action.delete'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800208 },
209 {
210 value: 'enable',
Surya Vde23ea22024-07-11 15:19:46 +0530211 label: i18n.global.t('global.action.enable'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800212 },
213 {
214 value: 'disable',
Surya Vde23ea22024-07-11 15:19:46 +0530215 label: i18n.global.t('global.action.disable'),
Derick Montague602e98a2020-10-21 16:20:00 -0500216 },
217 ],
SurenNewareba91c492020-10-27 14:18:54 +0530218 selectedRows: selectedRows,
219 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
220 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
jason westoverd36ac8a2025-11-03 20:58:59 -0600221 showUserModal: false,
222 showSettingsModal: false,
223 showRoles: false,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800224 };
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600225 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600226 computed: {
227 allUsers() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530228 return this.$store.getters['userManagement/allUsers'];
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600229 },
230 tableItems() {
231 // transform user data to table data
Derick Montague602e98a2020-10-21 16:20:00 -0500232 return this.allUsers.map((user) => {
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600233 return {
234 username: user.UserName,
235 privilege: user.RoleId,
236 status: user.Locked
Derick Montaguee2fd1562019-12-20 13:26:53 -0600237 ? 'Locked'
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600238 : user.Enabled
Ed Tanous81323992024-02-27 11:26:24 -0800239 ? 'Enabled'
240 : 'Disabled',
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800241 actions: [
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800242 {
243 value: 'edit',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530244 enabled: this.editEnable(user),
Surya Vde23ea22024-07-11 15:19:46 +0530245 title: i18n.global.t('pageUserManagement.editUser'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800246 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800247 {
248 value: 'delete',
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530249 enabled:
250 user.UserName === this.$store.getters['global/username']
251 ? false
252 : true && user.UserName === 'root'
Ed Tanous81323992024-02-27 11:26:24 -0800253 ? false
254 : true,
Surya Vde23ea22024-07-11 15:19:46 +0530255 title: i18n.global.t('pageUserManagement.deleteUser'),
Derick Montague602e98a2020-10-21 16:20:00 -0500256 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800257 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500258 ...user,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600259 };
260 });
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800261 },
262 settings() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530263 return this.$store.getters['userManagement/accountSettings'];
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800264 },
265 passwordRequirements() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530266 return this.$store.getters['userManagement/accountPasswordRequirements'];
Derick Montague602e98a2020-10-21 16:20:00 -0500267 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600268 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600269 created() {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700270 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600271 this.$store.dispatch('userManagement/getUsers').finally(() => {
272 this.endLoader();
273 this.isBusy = false;
274 });
Sandeepa Singhb4406162021-07-26 15:05:39 +0530275 this.$store.dispatch('userManagement/getAccountSettings');
276 this.$store.dispatch('userManagement/getAccountRoles');
Derick Montague09e45cd2020-01-23 15:45:57 -0600277 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600278 methods: {
Sivaprabu Ganesan28974472023-01-05 18:52:51 +0530279 editEnable(user) {
280 if ('root' === this.$store.getters['global/username']) {
281 return true;
282 } else {
283 return user.UserName === 'root' ? false : true;
284 }
285 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800286 initModalUser(user) {
287 this.activeUser = user;
jason westoverd36ac8a2025-11-03 20:58:59 -0600288 this.showUserModal = true;
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800289 },
290 initModalDelete(user) {
jason westoverd36ac8a2025-11-03 20:58:59 -0600291 this.confirmDialog(
292 i18n.global.t('pageUserManagement.modal.deleteConfirmMessage', {
293 user: user.username,
294 }),
295 {
296 title: i18n.global.t('pageUserManagement.deleteUser'),
297 okTitle: i18n.global.t('pageUserManagement.deleteUser'),
298 cancelTitle: i18n.global.t('global.action.cancel'),
299 autoFocusButton: 'ok',
300 },
301 ).then((deleteConfirmed) => {
302 if (deleteConfirmed) {
303 this.deleteUser(user);
304 }
305 });
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800306 },
307 initModalSettings() {
kirankumarb076ad19aa2023-03-21 19:19:02 +0530308 this.setting = this.settings;
jason westoverd36ac8a2025-11-03 20:58:59 -0600309 this.showSettingsModal = true;
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800310 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800311 saveUser({ isNewUser, userData }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700312 this.startLoader();
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800313 if (isNewUser) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800314 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530315 .dispatch('userManagement/createUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500316 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700317 .catch(({ message }) => this.errorToast(message))
318 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800319 } else {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800320 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530321 .dispatch('userManagement/updateUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500322 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700323 .catch(({ message }) => this.errorToast(message))
324 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800325 }
326 },
327 deleteUser({ username }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700328 this.startLoader();
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800329 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530330 .dispatch('userManagement/deleteUser', username)
Derick Montague602e98a2020-10-21 16:20:00 -0500331 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700332 .catch(({ message }) => this.errorToast(message))
333 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800334 },
335 onBatchAction(action) {
jason westoverd36ac8a2025-11-03 20:58:59 -0600336 const count = this.selectedRows.length;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800337 switch (action) {
338 case 'delete':
jason westoverd36ac8a2025-11-03 20:58:59 -0600339 this.confirmDialog(
340 i18n.global.t(
341 'pageUserManagement.modal.batchDeleteConfirmMessage',
342 count,
343 ),
344 {
345 title: i18n.global.t('pageUserManagement.deleteUser', count),
346 okTitle: i18n.global.t('pageUserManagement.deleteUser', count),
347 cancelTitle: i18n.global.t('global.action.cancel'),
348 autoFocusButton: 'ok',
349 },
350 ).then((deleteConfirmed) => {
351 if (deleteConfirmed) {
352 this.startLoader();
353 this.$store
354 .dispatch('userManagement/deleteUsers', this.selectedRows)
355 .then((messages) => {
356 messages.forEach(({ type, message }) => {
357 if (type === 'success') this.successToast(message);
358 if (type === 'error') this.errorToast(message);
359 });
360 })
361 .finally(() => this.endLoader());
362 }
363 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800364 break;
365 case 'enable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700366 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800367 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530368 .dispatch('userManagement/enableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500369 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800370 messages.forEach(({ type, message }) => {
371 if (type === 'success') this.successToast(message);
372 if (type === 'error') this.errorToast(message);
373 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700374 })
375 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800376 break;
377 case 'disable':
jason westoverd36ac8a2025-11-03 20:58:59 -0600378 this.confirmDialog(
379 i18n.global.t(
380 'pageUserManagement.modal.batchDisableConfirmMessage',
381 count,
382 ),
383 {
384 title: i18n.global.t('pageUserManagement.disableUser', count),
385 okTitle: i18n.global.t('pageUserManagement.disableUser', count),
386 cancelTitle: i18n.global.t('global.action.cancel'),
387 autoFocusButton: 'ok',
388 },
389 ).then((disableConfirmed) => {
390 if (disableConfirmed) {
391 this.startLoader();
392 this.$store
393 .dispatch('userManagement/disableUsers', this.selectedRows)
394 .then((messages) => {
395 messages.forEach(({ type, message }) => {
396 if (type === 'success') this.successToast(message);
397 if (type === 'error') this.errorToast(message);
398 });
399 })
400 .finally(() => this.endLoader());
401 }
402 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800403 break;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800404 }
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800405 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600406 confirmDialog(message, options = {}) {
407 return this.$confirm({ message, ...options });
408 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800409 onTableRowAction(action, row) {
410 switch (action) {
411 case 'edit':
412 this.initModalUser(row);
413 break;
414 case 'delete':
415 this.initModalDelete(row);
416 break;
417 default:
418 break;
419 }
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800420 },
421 saveAccountSettings(settings) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700422 this.startLoader();
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800423 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530424 .dispatch('userManagement/saveAccountSettings', settings)
Derick Montague602e98a2020-10-21 16:20:00 -0500425 .then((message) => this.successToast(message))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700426 .catch(({ message }) => this.errorToast(message))
427 .finally(() => this.endLoader());
Derick Montague602e98a2020-10-21 16:20:00 -0500428 },
429 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600430};
431</script>
432
433<style lang="scss" scoped>
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800434.btn.collapsed {
435 svg {
436 transform: rotate(180deg);
437 }
438}
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600439</style>