| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 1 | <template> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 2 | <b-modal id="modal-user" ref="modal" :title="modalTitle" @hidden="resetForm"> |
| Yoshie Muranaka | 9a9092d | 2020-05-04 08:24:21 -0700 | [diff] [blame] | 3 | <b-form id="form-user" novalidate @submit.prevent="handleSubmit"> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 4 | <b-container> |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 5 | <!-- Manual unlock form control --> |
| 6 | <b-row v-if="!newUser && manualUnlockPolicy && user.Locked"> |
| 7 | <b-col sm="9"> |
| 8 | <alert :show="true" variant="warning" small> |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 9 | <template v-if="!v$.form.manualUnlock.$dirty"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 10 | {{ i18n.t('pageUserManagement.modal.accountLocked') }} |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 11 | </template> |
| 12 | <template v-else> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 13 | {{ |
| 14 | i18n.t('pageUserManagement.modal.clickSaveToUnlockAccount') |
| 15 | }} |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 16 | </template> |
| 17 | </alert> |
| 18 | </b-col> |
| 19 | <b-col sm="3"> |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 20 | <input |
| 21 | v-model="form.manualUnlock" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 22 | data-test-id="userManagement-input-manualUnlock" |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 23 | type="hidden" |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 24 | /> |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 25 | <b-button |
| 26 | variant="primary" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 27 | :disabled="v$.form.manualUnlock.$dirty" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 28 | data-test-id="userManagement-button-manualUnlock" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 29 | @click="v$.form.manualUnlock.$touch()" |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 30 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 31 | {{ i18n.t('pageUserManagement.modal.unlock') }} |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 32 | </b-button> |
| 33 | </b-col> |
| 34 | </b-row> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 35 | <b-row> |
| 36 | <b-col> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 37 | <b-form-group |
| 38 | :label="i18n.t('pageUserManagement.modal.accountStatus')" |
| 39 | > |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 40 | <b-form-radio |
| 41 | v-model="form.status" |
| 42 | name="user-status" |
| 43 | :value="true" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 44 | data-test-id="userManagement-radioButton-statusEnabled" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 45 | @input="v$.form.status.$touch()" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 46 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 47 | {{ i18n.t('global.status.enabled') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 48 | </b-form-radio> |
| 49 | <b-form-radio |
| 50 | v-model="form.status" |
| 51 | name="user-status" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 52 | data-test-id="userManagement-radioButton-statusDisabled" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 53 | :value="false" |
| Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 54 | :disabled="!newUser && originalUsername === disabled" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 55 | @input="v$.form.status.$touch()" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 56 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 57 | {{ i18n.t('global.status.disabled') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 58 | </b-form-radio> |
| 59 | </b-form-group> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 60 | <b-form-group |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 61 | :label="i18n.t('pageUserManagement.modal.username')" |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 62 | label-for="username" |
| 63 | > |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 64 | <b-form-text id="username-help-block"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 65 | {{ i18n.t('pageUserManagement.modal.cannotStartWithANumber') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 66 | <br /> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 67 | {{ |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 68 | i18n.t( |
| Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 69 | 'pageUserManagement.modal.noSpecialCharactersExceptUnderscore', |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 70 | ) |
| 71 | }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 72 | </b-form-text> |
| 73 | <b-form-input |
| Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 74 | id="username" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 75 | v-model="form.username" |
| 76 | type="text" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 77 | aria-describedby="username-help-block" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 78 | data-test-id="userManagement-input-username" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 79 | :state="getValidationState(v$.form.username)" |
| Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 80 | :disabled="!newUser && originalUsername === disabled" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 81 | @input="v$.form.username.$touch()" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 82 | /> |
| 83 | <b-form-invalid-feedback role="alert"> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 84 | <template v-if="v$.form.username.required.$invalid"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 85 | {{ i18n.t('global.form.fieldRequired') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 86 | </template> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 87 | <template v-else-if="v$.form.username.maxLength.$invalid"> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 88 | {{ |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 89 | i18n.t('global.form.lengthMustBeBetween', { |
| 90 | min: 1, |
| 91 | max: 16, |
| 92 | }) |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 93 | }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 94 | </template> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 95 | <template v-else-if="v$.form.username.pattern.$invalid"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 96 | {{ i18n.t('global.form.invalidFormat') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 97 | </template> |
| 98 | </b-form-invalid-feedback> |
| 99 | </b-form-group> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 100 | <b-form-group |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 101 | :label="i18n.t('pageUserManagement.modal.privilege')" |
| Yoshie Muranaka | a4b9e40 | 2020-03-06 14:59:46 -0800 | [diff] [blame] | 102 | label-for="privilege" |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 103 | > |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 104 | <b-form-select |
| Yoshie Muranaka | a4b9e40 | 2020-03-06 14:59:46 -0800 | [diff] [blame] | 105 | id="privilege" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 106 | v-model="form.privilege" |
| 107 | :options="privilegeTypes" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 108 | data-test-id="userManagement-select-privilege" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 109 | :state="getValidationState(v$.form.privilege)" |
| aravinths1 | 2b02103 | 2024-05-22 21:29:50 +0530 | [diff] [blame] | 110 | :disabled="!newUser && originalUsername === 'root'" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 111 | @input="v$.form.privilege.$touch()" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 112 | > |
| Yoshie Muranaka | bc0d61b | 2020-11-02 14:36:27 -0800 | [diff] [blame] | 113 | <template #first> |
| 114 | <b-form-select-option :value="null" disabled> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 115 | {{ i18n.t('global.form.selectAnOption') }} |
| Yoshie Muranaka | bc0d61b | 2020-11-02 14:36:27 -0800 | [diff] [blame] | 116 | </b-form-select-option> |
| 117 | </template> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 118 | </b-form-select> |
| 119 | <b-form-invalid-feedback role="alert"> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 120 | <template v-if="v$.form.privilege.required.$invalid"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 121 | {{ i18n.t('global.form.fieldRequired') }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 122 | </template> |
| 123 | </b-form-invalid-feedback> |
| 124 | </b-form-group> |
| 125 | </b-col> |
| 126 | <b-col> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 127 | <b-form-group |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 128 | :label="i18n.t('pageUserManagement.modal.userPassword')" |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 129 | label-for="password" |
| 130 | > |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 131 | <b-form-text id="password-help-block"> |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 132 | {{ |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 133 | i18n.t('pageUserManagement.modal.passwordMustBeBetween', { |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 134 | min: passwordRequirements.minLength, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 135 | max: passwordRequirements.maxLength, |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 136 | }) |
| 137 | }} |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 138 | </b-form-text> |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 139 | <input-password-toggle> |
| 140 | <b-form-input |
| 141 | id="password" |
| 142 | v-model="form.password" |
| 143 | type="password" |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 144 | autocomplete="new-password" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 145 | data-test-id="userManagement-input-password" |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 146 | aria-describedby="password-help-block" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 147 | :state="getValidationState(v$.form.password)" |
| Dixsie Wolmers | 5ea1678 | 2020-07-27 17:50:43 -0500 | [diff] [blame] | 148 | class="form-control-with-button" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 149 | @input="v$.form.password.$touch()" |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 150 | /> |
| 151 | <b-form-invalid-feedback role="alert"> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 152 | <template v-if="v$.form.password.required.$invalid"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 153 | {{ i18n.t('global.form.fieldRequired') }} |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 154 | </template> |
| 155 | <template |
| 156 | v-if=" |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 157 | v$.form.password.minLength.$invalid || |
| 158 | v$.form.password.maxLength.$invalid |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 159 | " |
| 160 | > |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 161 | {{ |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 162 | i18n.t('pageUserManagement.modal.passwordMustBeBetween', { |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 163 | min: passwordRequirements.minLength, |
| 164 | max: passwordRequirements.maxLength, |
| 165 | }) |
| Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 166 | }} |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 167 | </template> |
| 168 | </b-form-invalid-feedback> |
| 169 | </input-password-toggle> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 170 | </b-form-group> |
| 171 | <b-form-group |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 172 | :label="i18n.t('pageUserManagement.modal.confirmUserPassword')" |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 173 | label-for="password-confirmation" |
| 174 | > |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 175 | <input-password-toggle> |
| 176 | <b-form-input |
| 177 | id="password-confirmation" |
| 178 | v-model="form.passwordConfirmation" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 179 | data-test-id="userManagement-input-passwordConfirmation" |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 180 | type="password" |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 181 | autocomplete="new-password" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 182 | :state="getValidationState(v$.form.passwordConfirmation)" |
| Dixsie Wolmers | 5ea1678 | 2020-07-27 17:50:43 -0500 | [diff] [blame] | 183 | class="form-control-with-button" |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 184 | @input="v$.form.passwordConfirmation.$touch()" |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 185 | /> |
| 186 | <b-form-invalid-feedback role="alert"> |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 187 | <template |
| 188 | v-if="v$.form.passwordConfirmation.required.$invalid" |
| 189 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 190 | {{ i18n.t('global.form.fieldRequired') }} |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 191 | </template> |
| 192 | <template |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 193 | v-else-if=" |
| 194 | v$.form.passwordConfirmation.sameAsPassword.$invalid |
| 195 | " |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 196 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 197 | {{ i18n.t('pageUserManagement.modal.passwordsDoNotMatch') }} |
| Yoshie Muranaka | 4ee8d29 | 2020-02-20 07:29:58 -0800 | [diff] [blame] | 198 | </template> |
| 199 | </b-form-invalid-feedback> |
| 200 | </input-password-toggle> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 201 | </b-form-group> |
| 202 | </b-col> |
| 203 | </b-row> |
| 204 | </b-container> |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 205 | </b-form> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 206 | <template #footer="{ cancel }"> |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 207 | <b-button |
| 208 | variant="secondary" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 209 | data-test-id="userManagement-button-cancel" |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 210 | @click="cancel()" |
| 211 | > |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 212 | {{ i18n.t('global.action.cancel') }} |
| Yoshie Muranaka | 9a9092d | 2020-05-04 08:24:21 -0700 | [diff] [blame] | 213 | </b-button> |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 214 | <b-button |
| 215 | form="form-user" |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 216 | data-test-id="userManagement-button-submit" |
| Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 217 | type="submit" |
| 218 | variant="primary" |
| 219 | @click="onOk" |
| 220 | > |
| Yoshie Muranaka | 9a9092d | 2020-05-04 08:24:21 -0700 | [diff] [blame] | 221 | <template v-if="newUser"> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 222 | {{ i18n.t('pageUserManagement.addUser') }} |
| Yoshie Muranaka | 9a9092d | 2020-05-04 08:24:21 -0700 | [diff] [blame] | 223 | </template> |
| 224 | <template v-else> |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 225 | {{ i18n.t('global.action.save') }} |
| Yoshie Muranaka | 9a9092d | 2020-05-04 08:24:21 -0700 | [diff] [blame] | 226 | </template> |
| 227 | </b-button> |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 228 | </template> |
| 229 | </b-modal> |
| 230 | </template> |
| 231 | |
| 232 | <script> |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 233 | import { |
| 234 | required, |
| 235 | maxLength, |
| 236 | minLength, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 237 | requiredIf, |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 238 | } from '@vuelidate/validators'; |
| Surya Venkatesan | 90300e9 | 2024-08-01 12:40:20 +0530 | [diff] [blame] | 239 | import { helpers, sameAs } from 'vuelidate/lib/validators'; |
| SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 240 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 241 | import { useVuelidate } from '@vuelidate/core'; |
| 242 | |
| SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 243 | import InputPasswordToggle from '@/components/Global/InputPasswordToggle'; |
| 244 | import Alert from '@/components/Global/Alert'; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 245 | import { useI18n } from 'vue-i18n'; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 246 | |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 247 | export default { |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 248 | components: { Alert, InputPasswordToggle }, |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 249 | mixins: [VuelidateMixin], |
| Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 250 | props: { |
| 251 | user: { |
| 252 | type: Object, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 253 | default: null, |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 254 | }, |
| 255 | passwordRequirements: { |
| 256 | type: Object, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 257 | required: true, |
| 258 | }, |
| Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 259 | }, |
| Hariharan Rangasamy | c5d60f5 | 2025-10-31 12:58:56 +0530 | [diff] [blame] | 260 | emits: ['ok', 'hidden'], |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 261 | setup() { |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 262 | const i18n = useI18n(); |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 263 | return { |
| 264 | v$: useVuelidate(), |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 265 | i18n, |
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 266 | }; |
| 267 | }, |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 268 | data() { |
| 269 | return { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 270 | originalUsername: '', |
| 271 | form: { |
| 272 | status: true, |
| 273 | username: '', |
| Yoshie Muranaka | bc0d61b | 2020-11-02 14:36:27 -0800 | [diff] [blame] | 274 | privilege: null, |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 275 | password: '', |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 276 | passwordConfirmation: '', |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 277 | manualUnlock: false, |
| 278 | }, |
| Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 279 | disabled: this.$store.getters['global/username'], |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 280 | }; |
| 281 | }, |
| 282 | computed: { |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 283 | modalTitle() { |
| 284 | return this.newUser |
| 285 | ? this.i18n.t('pageUserManagement.addUser') |
| 286 | : this.i18n.t('pageUserManagement.editUser'); |
| 287 | }, |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 288 | newUser() { |
| 289 | return this.user ? false : true; |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 290 | }, |
| 291 | accountSettings() { |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 292 | return this.$store.getters['userManagement/accountSettings']; |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 293 | }, |
| 294 | manualUnlockPolicy() { |
| 295 | return !this.accountSettings.accountLockoutDuration; |
| Yoshie Muranaka | 038a9da | 2020-04-17 11:22:56 -0700 | [diff] [blame] | 296 | }, |
| 297 | privilegeTypes() { |
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 298 | return this.$store.getters['userManagement/accountRoles']; |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 299 | }, |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 300 | }, |
| 301 | watch: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 302 | user: function (value) { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 303 | if (value === null) return; |
| 304 | this.originalUsername = value.username; |
| 305 | this.form.username = value.username; |
| 306 | this.form.status = value.Enabled; |
| 307 | this.form.privilege = value.privilege; |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 308 | }, |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 309 | }, |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 310 | validations() { |
| 311 | return { |
| 312 | form: { |
| 313 | status: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 314 | required, |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 315 | }, |
| 316 | username: { |
| 317 | required, |
| 318 | maxLength: maxLength(16), |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 319 | pattern: helpers.regex('pattern', /^([a-zA-Z_][a-zA-Z0-9_]*)/), |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 320 | }, |
| 321 | privilege: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 322 | required, |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 323 | }, |
| 324 | password: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 325 | required: requiredIf(function () { |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 326 | return this.requirePassword(); |
| 327 | }), |
| 328 | minLength: minLength(this.passwordRequirements.minLength), |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 329 | maxLength: maxLength(this.passwordRequirements.maxLength), |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 330 | }, |
| 331 | passwordConfirmation: { |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 332 | required: requiredIf(function () { |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 333 | return this.requirePassword(); |
| 334 | }), |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 335 | sameAsPassword: sameAs('password'), |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 336 | }, |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 337 | manualUnlock: {}, |
| 338 | }, |
| Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 339 | }; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 340 | }, |
| 341 | methods: { |
| 342 | handleSubmit() { |
| 343 | let userData = {}; |
| 344 | |
| 345 | if (this.newUser) { |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 346 | this.v$.$touch(); |
| 347 | if (this.v$.$invalid) return; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 348 | userData.username = this.form.username; |
| 349 | userData.status = this.form.status; |
| 350 | userData.privilege = this.form.privilege; |
| 351 | userData.password = this.form.password; |
| 352 | } else { |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 353 | if (this.v$.$invalid) return; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 354 | userData.originalUsername = this.originalUsername; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 355 | if (this.v$.form.status.$dirty) { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 356 | userData.status = this.form.status; |
| 357 | } |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 358 | if (this.v$.form.username.$dirty) { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 359 | userData.username = this.form.username; |
| 360 | } |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 361 | if (this.v$.form.privilege.$dirty) { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 362 | userData.privilege = this.form.privilege; |
| 363 | } |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 364 | if (this.v$.form.password.$dirty) { |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 365 | userData.password = this.form.password; |
| 366 | } |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 367 | if (this.v$.form.manualUnlock.$dirty) { |
| Yoshie Muranaka | 1f9ed4c | 2020-03-26 16:59:54 -0700 | [diff] [blame] | 368 | // If form manualUnlock control $dirty then |
| 369 | // set user Locked property to false |
| 370 | userData.locked = false; |
| 371 | } |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 372 | if (Object.entries(userData).length === 1) { |
| 373 | this.closeModal(); |
| 374 | return; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | this.$emit('ok', { isNewUser: this.newUser, userData }); |
| 379 | this.closeModal(); |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 380 | }, |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 381 | closeModal() { |
| 382 | this.$nextTick(() => { |
| 383 | this.$refs.modal.hide(); |
| 384 | }); |
| 385 | }, |
| 386 | resetForm() { |
| 387 | this.form.originalUsername = ''; |
| 388 | this.form.status = true; |
| 389 | this.form.username = ''; |
| Yoshie Muranaka | bc0d61b | 2020-11-02 14:36:27 -0800 | [diff] [blame] | 390 | this.form.privilege = null; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 391 | this.form.password = ''; |
| 392 | this.form.passwordConfirmation = ''; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 393 | this.v$.$reset(); |
| Yoshie Muranaka | 791622b | 2020-04-17 13:55:16 -0700 | [diff] [blame] | 394 | this.$emit('hidden'); |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 395 | }, |
| 396 | requirePassword() { |
| 397 | if (this.newUser) return true; |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 398 | if (this.v$.form.password.$dirty) return true; |
| 399 | if (this.v$.form.passwordConfirmation.$dirty) return true; |
| Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 400 | return false; |
| 401 | }, |
| 402 | onOk(bvModalEvt) { |
| 403 | // prevent modal close |
| 404 | bvModalEvt.preventDefault(); |
| 405 | this.handleSubmit(); |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 406 | }, |
| 407 | }, |
| Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 408 | }; |
| 409 | </script> |