-
Notifications
You must be signed in to change notification settings - Fork 256
[Remove Vuetify from Studio] Add / remove admin privileges dialogs #5469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Changes from 7 commits
690f40f
147ad0a
ab01071
13d1fbe
41cb016
a0a7653
3f4788f
ac8ab08
cde2bac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1,83 @@ | ||
| <template> | ||
|
|
||
| <MessageDialog | ||
| v-model="dialog" | ||
| :header="header" | ||
| :text="text" | ||
| <KModal | ||
| v-if="dialog" | ||
| :title="title" | ||
| :submitText="confirmText" | ||
| :cancelText="$tr('cancelAction')" | ||
| data-test="user-privilege-modal" | ||
| @submit="submit" | ||
| @cancel="close" | ||
| > | ||
| <VForm | ||
| <p>{{ text }}</p> | ||
|
|
||
| <form | ||
| ref="form" | ||
| lazy-validation | ||
| @submit.prevent="confirm" | ||
| > | ||
| <p>Enter your email address to continue</p> | ||
| <VTextField | ||
| <p>{{ $tr('confirmEmailPrompt') }}</p> | ||
|
|
||
| <KTextbox | ||
| v-model="emailConfirm" | ||
| box | ||
| maxlength="100" | ||
| :maxlength="100" | ||
| counter | ||
| required | ||
| :rules="emailRules" | ||
| label="Email address" | ||
| @input="resetValidation" | ||
| :label="$tr('emailLabel')" | ||
| :invalid="errors.emailConfirm" | ||
| :invalidText="$tr('emailValidationMessage')" | ||
| :showInvalidText="true" | ||
| data-test="email-input" | ||
| /> | ||
| </VForm> | ||
| <template #buttons> | ||
| <VBtn | ||
| </form> | ||
|
|
||
| <template #actions> | ||
| <KButton | ||
| flat | ||
| data-test="cancel" | ||
| type="button" | ||
| class="mr-2" | ||
| @click="close" | ||
| > | ||
| Cancel | ||
| </VBtn> | ||
| <VBtn | ||
| color="primary" | ||
| @click="confirm" | ||
| {{ $tr('cancelAction') }} | ||
| </KButton> | ||
|
|
||
| <KButton | ||
| data-test="confirm" | ||
| primary | ||
| type="button" | ||
| @click="submit" | ||
| > | ||
| {{ confirmText }} | ||
| </VBtn> | ||
| </KButton> | ||
| </template> | ||
| </MessageDialog> | ||
| </KModal> | ||
|
|
||
| </template> | ||
|
|
||
|
|
||
| <script> | ||
| import { mapState } from 'vuex'; | ||
| import MessageDialog from 'shared/views/MessageDialog'; | ||
| import { generateFormMixin } from 'shared/mixins'; | ||
| const formMixin = generateFormMixin({ | ||
| emailConfirm: { | ||
| required: true, | ||
| validator: (value, vm) => { | ||
| return value === vm.currentEmail; | ||
| }, | ||
| }, | ||
| }); | ||
| export default { | ||
| name: 'UserPrivilegeModal', | ||
| components: { | ||
| MessageDialog, | ||
| }, | ||
| mixins: [formMixin], | ||
| props: { | ||
| value: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| header: { | ||
| title: { | ||
| type: String, | ||
| required: true, | ||
| }, | ||
|
|
@@ -74,47 +94,71 @@ | |
| required: true, | ||
| }, | ||
| }, | ||
| data() { | ||
| return { | ||
| emailConfirm: '', | ||
| }; | ||
| }, | ||
| computed: { | ||
| ...mapState({ | ||
| // eslint-disable-next-line kolibri/vue-no-unused-vuex-properties, vue/no-unused-properties | ||
| currentEmail: state => state.session.currentUser.email, | ||
| }), | ||
| dialog: { | ||
| get() { | ||
| return this.value; | ||
| }, | ||
| set(value) { | ||
| this.$emit('input', value); | ||
| set(v) { | ||
| this.$emit('input', v); | ||
| }, | ||
| }, | ||
| emailRules() { | ||
| return [ | ||
| v => Boolean(v) || 'Field is required', | ||
| v => v === this.currentEmail || 'Email does not match your account email', | ||
| ]; | ||
| }, | ||
| watch: { | ||
| value(val) { | ||
| if (val) { | ||
| this.reset(); | ||
| } | ||
| }, | ||
| }, | ||
| methods: { | ||
| close() { | ||
| this.emailConfirm = ''; | ||
| this.resetValidation(); | ||
| this.dialog = false; | ||
| }, | ||
| resetValidation() { | ||
| this.$refs.form.resetValidation(); | ||
| if (typeof this.reset === 'function') { | ||
| this.reset(); | ||
| } else { | ||
| this.emailConfirm = ''; | ||
| if (this.errors) { | ||
|
||
| Object.keys(this.errors).forEach(k => (this.errors[k] = false)); | ||
| } | ||
| } | ||
| this.$emit('input', false); | ||
| }, | ||
| // eslint-disable-next-line vue/no-unused-properties | ||
| confirm() { | ||
| if (this.$refs.form.validate()) { | ||
| return this.confirmAction(); | ||
| } else { | ||
| return Promise.resolve(); | ||
| if (typeof this.submit === 'function') { | ||
| return this.submit(); | ||
| } | ||
| return Promise.resolve(); | ||
| }, | ||
| // eslint-disable-next-line vue/no-unused-properties | ||
| onSubmit(formData) { | ||
| try { | ||
| const res = this.confirmAction(formData); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the function that the prop
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it takes formData as an argument @marcellamaki |
||
| if (res && typeof res.then === 'function') { | ||
| return res.then(val => { | ||
| this.dialog = false; | ||
| return val; | ||
| }); | ||
| } | ||
| this.dialog = false; | ||
| return Promise.resolve(res); | ||
| } catch (err) { | ||
| return Promise.reject(err); | ||
| } | ||
| }, | ||
| }, | ||
| $trs: { | ||
| emailLabel: 'Email address', | ||
| emailValidationMessage: 'Email must match your account email', | ||
| cancelAction: 'Cancel', | ||
| confirmEmailPrompt: 'Enter your email address to continue', | ||
| }, | ||
| }; | ||
| </script> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to edit this from 'value' to
v