blob: 015fee91a06b12a8739b3f819d48595833597528 [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>
Yoshie Muranaka74f86872020-02-10 12:28:37 -08005 <b-col xl="9" class="text-right">
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"
24 :selected-items-count="selectedRows.length"
25 :actions="tableToolbarActions"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053026 @clear-selected="clearSelectedRows($refs.table)"
27 @batch-action="onBatchAction"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080028 />
29 <b-table
30 ref="table"
SurenNeware5e25e282020-07-08 15:57:23 +053031 responsive="md"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080032 selectable
SurenNeware307382e2020-07-27 20:45:14 +053033 show-empty
Yoshie Muranaka183c2752020-02-12 11:30:49 -080034 no-select-on-click
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053035 hover
Yoshie Muranaka183c2752020-02-12 11:30:49 -080036 :fields="fields"
37 :items="tableItems"
SurenNeware307382e2020-07-27 20:45:14 +053038 :empty-text="$t('global.table.emptyMessage')"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080039 @row-selected="onRowSelected($event, tableItems.length)"
40 >
41 <!-- Checkbox column -->
Derick Montague602e98a2020-10-21 16:20:00 -050042 <template #head(checkbox)>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080043 <b-form-checkbox
44 v-model="tableHeaderCheckboxModel"
Sandeepa Singhb4406162021-07-26 15:05:39 +053045 data-test-id="userManagement-checkbox-tableHeaderCheckbox"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080046 :indeterminate="tableHeaderCheckboxIndeterminate"
47 @change="onChangeHeaderCheckbox($refs.table)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060048 >
49 <span class="sr-only">{{ $t('global.table.selectAll') }}</span>
50 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080051 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050052 <template #cell(checkbox)="row">
Yoshie Muranaka183c2752020-02-12 11:30:49 -080053 <b-form-checkbox
54 v-model="row.rowSelected"
Sandeepa Singhb4406162021-07-26 15:05:39 +053055 data-test-id="userManagement-checkbox-toggleSelectRow"
Yoshie Muranaka183c2752020-02-12 11:30:49 -080056 @change="toggleSelectRow($refs.table, row.index)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -060057 >
58 <span class="sr-only">{{ $t('global.table.selectItem') }}</span>
59 </b-form-checkbox>
Yoshie Muranaka183c2752020-02-12 11:30:49 -080060 </template>
61
62 <!-- table actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -050063 <template #cell(actions)="{ item }">
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080064 <table-row-action
65 v-for="(action, index) in item.actions"
66 :key="index"
67 :value="action.value"
68 :enabled="action.enabled"
Yoshie Muranakaeaa04802020-02-28 13:21:27 -080069 :title="action.title"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053070 @click-table-action="onTableRowAction($event, item)"
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060071 >
Derick Montague602e98a2020-10-21 16:20:00 -050072 <template #icon>
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050073 <icon-edit
74 v-if="action.value === 'edit'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053075 :data-test-id="`userManagement-tableRowAction-edit-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050076 />
77 <icon-trashcan
78 v-if="action.value === 'delete'"
Sandeepa Singhb4406162021-07-26 15:05:39 +053079 :data-test-id="`userManagement-tableRowAction-delete-${index}`"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050080 />
Yoshie Muranaka0e893f02020-02-18 13:39:45 -080081 </template>
82 </table-row-action>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060083 </template>
84 </b-table>
85 </b-col>
86 </b-row>
87 <b-row>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080088 <b-col xl="8">
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050089 <b-button
90 v-b-toggle.collapse-role-table
Sandeepa Singhb4406162021-07-26 15:05:39 +053091 data-test-id="userManagement-button-viewPrivilegeRoleDescriptions"
Dixsie Wolmersfe1e6582020-07-15 11:18:12 -050092 variant="link"
93 class="mt-3"
94 >
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -080095 <icon-chevron />
Sandeepa Singhb4406162021-07-26 15:05:39 +053096 {{ $t('pageUserManagement.viewPrivilegeRoleDescriptions') }}
Yoshie Muranaka463a5702019-12-04 09:09:36 -080097 </b-button>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060098 <b-collapse id="collapse-role-table" class="mt-3">
Yoshie Muranaka463a5702019-12-04 09:09:36 -080099 <table-roles />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600100 </b-collapse>
101 </b-col>
102 </b-row>
103 <!-- Modals -->
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800104 <modal-settings :settings="settings" @ok="saveAccountSettings" />
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800105 <modal-user
106 :user="activeUser"
107 :password-requirements="passwordRequirements"
108 @ok="saveUser"
Yoshie Muranaka791622b2020-04-17 13:55:16 -0700109 @hidden="activeUser = null"
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800110 />
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600111 </b-container>
Derick Montaguea2988f42020-01-17 13:46:30 -0600112</template>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600113
114<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -0600115import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
116import IconEdit from '@carbon/icons-vue/es/edit/20';
117import IconAdd from '@carbon/icons-vue/es/add--alt/20';
118import IconSettings from '@carbon/icons-vue/es/settings/20';
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800119import IconChevron from '@carbon/icons-vue/es/chevron--up/20';
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800120
Derick Montaguee2fd1562019-12-20 13:26:53 -0600121import ModalUser from './ModalUser';
122import ModalSettings from './ModalSettings';
SurenNeware5e25e282020-07-08 15:57:23 +0530123import PageTitle from '@/components/Global/PageTitle';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800124import TableRoles from './TableRoles';
SurenNeware5e25e282020-07-08 15:57:23 +0530125import TableToolbar from '@/components/Global/TableToolbar';
126import TableRowAction from '@/components/Global/TableRowAction';
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800127
SurenNewareba91c492020-10-27 14:18:54 +0530128import BVTableSelectableMixin, {
129 selectedRows,
130 tableHeaderCheckboxModel,
131 tableHeaderCheckboxIndeterminate,
132} from '@/components/Mixins/BVTableSelectableMixin';
SurenNeware5e25e282020-07-08 15:57:23 +0530133import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700134import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600135
136export default {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530137 name: 'UserManagement',
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600138 components: {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800139 IconAdd,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800140 IconChevron,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800141 IconEdit,
142 IconSettings,
143 IconTrashcan,
144 ModalSettings,
145 ModalUser,
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800146 PageTitle,
Yoshie Muranaka8d129102019-12-19 09:51:55 -0800147 TableRoles,
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800148 TableRowAction,
Derick Montague602e98a2020-10-21 16:20:00 -0500149 TableToolbar,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800150 },
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700151 mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500152 beforeRouteLeave(to, from, next) {
153 this.hideLoader();
154 next();
155 },
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800156 data() {
157 return {
158 activeUser: null,
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800159 fields: [
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800160 {
Derick Montague602e98a2020-10-21 16:20:00 -0500161 key: 'checkbox',
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800162 },
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800163 {
164 key: 'username',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530165 label: this.$t('pageUserManagement.table.username'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800166 },
167 {
168 key: 'privilege',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530169 label: this.$t('pageUserManagement.table.privilege'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800170 },
171 {
172 key: 'status',
Sandeepa Singhb4406162021-07-26 15:05:39 +0530173 label: this.$t('pageUserManagement.table.status'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800174 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800175 {
176 key: 'actions',
177 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500178 tdClass: 'text-right text-nowrap',
179 },
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800180 ],
181 tableToolbarActions: [
182 {
183 value: 'delete',
Derick Montague602e98a2020-10-21 16:20:00 -0500184 label: this.$t('global.action.delete'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800185 },
186 {
187 value: 'enable',
Derick Montague602e98a2020-10-21 16:20:00 -0500188 label: this.$t('global.action.enable'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800189 },
190 {
191 value: 'disable',
Derick Montague602e98a2020-10-21 16:20:00 -0500192 label: this.$t('global.action.disable'),
193 },
194 ],
SurenNewareba91c492020-10-27 14:18:54 +0530195 selectedRows: selectedRows,
196 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
197 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800198 };
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600199 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600200 computed: {
201 allUsers() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530202 return this.$store.getters['userManagement/allUsers'];
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600203 },
204 tableItems() {
205 // transform user data to table data
Derick Montague602e98a2020-10-21 16:20:00 -0500206 return this.allUsers.map((user) => {
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600207 return {
208 username: user.UserName,
209 privilege: user.RoleId,
210 status: user.Locked
Derick Montaguee2fd1562019-12-20 13:26:53 -0600211 ? 'Locked'
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600212 : user.Enabled
Derick Montaguee2fd1562019-12-20 13:26:53 -0600213 ? 'Enabled'
214 : 'Disabled',
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800215 actions: [
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800216 {
217 value: 'edit',
218 enabled: true,
Sandeepa Singhb4406162021-07-26 15:05:39 +0530219 title: this.$t('pageUserManagement.editUser'),
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800220 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800221 {
222 value: 'delete',
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800223 enabled: user.UserName === 'root' ? false : true,
Sandeepa Singhb4406162021-07-26 15:05:39 +0530224 title: this.$tc('pageUserManagement.deleteUser'),
Derick Montague602e98a2020-10-21 16:20:00 -0500225 },
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800226 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500227 ...user,
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600228 };
229 });
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800230 },
231 settings() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530232 return this.$store.getters['userManagement/accountSettings'];
Yoshie Muranaka52b02232020-02-20 08:00:45 -0800233 },
234 passwordRequirements() {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530235 return this.$store.getters['userManagement/accountPasswordRequirements'];
Derick Montague602e98a2020-10-21 16:20:00 -0500236 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600237 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600238 created() {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700239 this.startLoader();
Sandeepa Singhb4406162021-07-26 15:05:39 +0530240 this.$store
241 .dispatch('userManagement/getUsers')
242 .finally(() => this.endLoader());
243 this.$store.dispatch('userManagement/getAccountSettings');
244 this.$store.dispatch('userManagement/getAccountRoles');
Derick Montague09e45cd2020-01-23 15:45:57 -0600245 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600246 methods: {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800247 initModalUser(user) {
248 this.activeUser = user;
Derick Montaguee2fd1562019-12-20 13:26:53 -0600249 this.$bvModal.show('modal-user');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800250 },
251 initModalDelete(user) {
252 this.$bvModal
253 .msgBoxConfirm(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530254 this.$t('pageUserManagement.modal.deleteConfirmMessage', {
Derick Montague602e98a2020-10-21 16:20:00 -0500255 user: user.username,
Yoshie Muranakaeaa04802020-02-28 13:21:27 -0800256 }),
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800257 {
Sandeepa Singhb4406162021-07-26 15:05:39 +0530258 title: this.$tc('pageUserManagement.deleteUser'),
259 okTitle: this.$tc('pageUserManagement.deleteUser'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530260 cancelTitle: this.$t('global.action.cancel'),
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800261 }
262 )
Derick Montague602e98a2020-10-21 16:20:00 -0500263 .then((deleteConfirmed) => {
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800264 if (deleteConfirmed) {
265 this.deleteUser(user);
266 }
267 });
268 },
269 initModalSettings() {
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800270 this.$bvModal.show('modal-settings');
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800271 },
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800272 saveUser({ isNewUser, userData }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700273 this.startLoader();
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800274 if (isNewUser) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800275 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530276 .dispatch('userManagement/createUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500277 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700278 .catch(({ message }) => this.errorToast(message))
279 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800280 } else {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800281 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530282 .dispatch('userManagement/updateUser', userData)
Derick Montague602e98a2020-10-21 16:20:00 -0500283 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700284 .catch(({ message }) => this.errorToast(message))
285 .finally(() => this.endLoader());
Yoshie Muranaka463a5702019-12-04 09:09:36 -0800286 }
287 },
288 deleteUser({ username }) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700289 this.startLoader();
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -0800290 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530291 .dispatch('userManagement/deleteUser', username)
Derick Montague602e98a2020-10-21 16:20:00 -0500292 .then((success) => this.successToast(success))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700293 .catch(({ message }) => this.errorToast(message))
294 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800295 },
296 onBatchAction(action) {
297 switch (action) {
298 case 'delete':
Yoshie Muranaka29321652020-05-04 10:52:36 -0700299 this.$bvModal
300 .msgBoxConfirm(
301 this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530302 'pageUserManagement.modal.batchDeleteConfirmMessage',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700303 this.selectedRows.length
304 ),
305 {
306 title: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530307 'pageUserManagement.deleteUser',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700308 this.selectedRows.length
309 ),
310 okTitle: this.$tc(
Sandeepa Singhb4406162021-07-26 15:05:39 +0530311 'pageUserManagement.deleteUser',
Yoshie Muranaka29321652020-05-04 10:52:36 -0700312 this.selectedRows.length
Derick Montague602e98a2020-10-21 16:20:00 -0500313 ),
Sukanya Pandey38357132020-12-22 13:40:59 +0530314 cancelTitle: this.$t('global.action.cancel'),
Yoshie Muranaka29321652020-05-04 10:52:36 -0700315 }
316 )
Derick Montague602e98a2020-10-21 16:20:00 -0500317 .then((deleteConfirmed) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700318 if (deleteConfirmed) {
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700319 this.startLoader();
Yoshie Muranaka29321652020-05-04 10:52:36 -0700320 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530321 .dispatch('userManagement/deleteUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500322 .then((messages) => {
Yoshie Muranaka29321652020-05-04 10:52:36 -0700323 messages.forEach(({ type, message }) => {
324 if (type === 'success') this.successToast(message);
325 if (type === 'error') this.errorToast(message);
326 });
327 })
328 .finally(() => this.endLoader());
329 }
330 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800331 break;
332 case 'enable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700333 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800334 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530335 .dispatch('userManagement/enableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500336 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800337 messages.forEach(({ type, message }) => {
338 if (type === 'success') this.successToast(message);
339 if (type === 'error') this.errorToast(message);
340 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700341 })
342 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800343 break;
344 case 'disable':
Yoshie Muranaka8e4b5c32020-05-27 14:10:52 -0700345 this.startLoader();
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800346 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530347 .dispatch('userManagement/disableUsers', this.selectedRows)
Derick Montague602e98a2020-10-21 16:20:00 -0500348 .then((messages) => {
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800349 messages.forEach(({ type, message }) => {
350 if (type === 'success') this.successToast(message);
351 if (type === 'error') this.errorToast(message);
352 });
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700353 })
354 .finally(() => this.endLoader());
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800355 break;
Yoshie Muranaka183c2752020-02-12 11:30:49 -0800356 }
Yoshie Muranaka0e893f02020-02-18 13:39:45 -0800357 },
358 onTableRowAction(action, row) {
359 switch (action) {
360 case 'edit':
361 this.initModalUser(row);
362 break;
363 case 'delete':
364 this.initModalDelete(row);
365 break;
366 default:
367 break;
368 }
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800369 },
370 saveAccountSettings(settings) {
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700371 this.startLoader();
Yoshie Muranaka1b1c1002020-02-20 10:18:36 -0800372 this.$store
Sandeepa Singhb4406162021-07-26 15:05:39 +0530373 .dispatch('userManagement/saveAccountSettings', settings)
Derick Montague602e98a2020-10-21 16:20:00 -0500374 .then((message) => this.successToast(message))
Yoshie Muranaka346be2a2020-04-28 11:12:14 -0700375 .catch(({ message }) => this.errorToast(message))
376 .finally(() => this.endLoader());
Derick Montague602e98a2020-10-21 16:20:00 -0500377 },
378 },
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600379};
380</script>
381
382<style lang="scss" scoped>
Yoshie Muranaka4b0fc1d2020-01-06 07:36:16 -0800383.btn.collapsed {
384 svg {
385 transform: rotate(180deg);
386 }
387}
Yoshie Muranaka35080ac2020-01-17 15:38:57 -0600388</style>