From 1a1807294ae17eea3637e5797ec75e6eb773f863 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Thu, 21 Dec 2017 15:26:50 +0100 Subject: Maintain modal state internally --- .../javascripts/groups/components/item_actions.vue | 17 +-- .../ide/components/new_dropdown/index.vue | 9 +- .../ide/components/new_dropdown/modal.vue | 14 +-- .../ide/components/repo_commit_section.vue | 8 +- .../ide/components/repo_edit_button.vue | 3 +- .../account/components/delete_account_modal.vue | 22 ++-- .../javascripts/vue_shared/components/modal.vue | 40 +++++-- .../vue_shared/components/recaptcha_modal.vue | 4 +- .../unreleased/winh-modal-internal-state.yml | 5 + .../groups/components/item_actions_spec.js | 32 ++--- .../components/delete_account_modal_spec.js | 4 +- .../repo/components/new_dropdown/index_spec.js | 34 +++--- .../repo/components/new_dropdown/modal_spec.js | 16 ++- .../vue_shared/components/modal_spec.js | 129 ++++++++++++++++++++- 14 files changed, 228 insertions(+), 109 deletions(-) create mode 100644 changelogs/unreleased/winh-modal-internal-state.yml diff --git a/app/assets/javascripts/groups/components/item_actions.vue b/app/assets/javascripts/groups/components/item_actions.vue index 58ba5aff7cf..2238112497d 100644 --- a/app/assets/javascripts/groups/components/item_actions.vue +++ b/app/assets/javascripts/groups/components/item_actions.vue @@ -25,11 +25,6 @@ export default { required: true, }, }, - data() { - return { - modalStatus: false, - }; - }, computed: { leaveBtnTitle() { return COMMON_STR.LEAVE_BTN_TITLE; @@ -43,13 +38,11 @@ export default { }, methods: { onLeaveGroup() { - this.modalStatus = true; + this.$refs.modal.show(); }, - leaveGroup(leaveConfirmed) { - this.modalStatus = false; - if (leaveConfirmed) { - eventHub.$emit('leaveGroup', this.group, this.parentGroup); - } + leaveGroup() { + eventHub.$emit('leaveGroup', this.group, this.parentGroup); + this.$refs.modal.hide(); }, }, }; @@ -83,7 +76,7 @@ export default { aria-hidden="true"/> diff --git a/app/assets/javascripts/ide/components/new_dropdown/modal.vue b/app/assets/javascripts/ide/components/new_dropdown/modal.vue index a0650d37690..eb1495a88c3 100644 --- a/app/assets/javascripts/ide/components/new_dropdown/modal.vue +++ b/app/assets/javascripts/ide/components/new_dropdown/modal.vue @@ -43,10 +43,13 @@ type: this.type, }); - this.toggleModalOpen(); + this.$refs.modal.hide(); }, - toggleModalOpen() { - this.$emit('toggle'); + show() { + this.$refs.modal.show(); + this.$nextTick(() => { + this.$refs.fieldName.focus(); + }); }, }, computed: { @@ -75,18 +78,15 @@ return __('File name'); }, }, - mounted() { - this.$refs.fieldName.focus(); - }, };