summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-05-17 13:50:42 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-05-17 13:50:42 +0000
commit4693aa9c9c67bc65145bb92d0476ad1a259cf7ca (patch)
tree720c0a9efa73595d2c9d185f68febb044687b76e
parent4fcff0bfa2f0d8b0a9f60e93bee807334557918f (diff)
parente713c68aa7c198e0ceb2e6eae5ffc9bbcf3558f2 (diff)
downloadgitlab-ce-4693aa9c9c67bc65145bb92d0476ad1a259cf7ca.tar.gz
Merge branch 'issue-edit-inline-title-validation' into 'issue-edit-inline'
Disable inline submit button when title is blank See merge request !11409
-rw-r--r--app/assets/javascripts/issue_show/components/edit_actions.vue13
-rw-r--r--app/assets/javascripts/issue_show/components/form.vue1
-rw-r--r--spec/javascripts/issue_show/components/edit_actions_spec.js20
3 files changed, 32 insertions, 2 deletions
diff --git a/app/assets/javascripts/issue_show/components/edit_actions.vue b/app/assets/javascripts/issue_show/components/edit_actions.vue
index 4cefb236d32..e57b867f93b 100644
--- a/app/assets/javascripts/issue_show/components/edit_actions.vue
+++ b/app/assets/javascripts/issue_show/components/edit_actions.vue
@@ -7,6 +7,10 @@
type: Boolean,
required: true,
},
+ formState: {
+ type: Object,
+ required: true,
+ },
},
data() {
return {
@@ -14,6 +18,11 @@
updateLoading: false,
};
},
+ computed: {
+ isSubmitEnabled() {
+ return this.formState.title.trim() !== '';
+ },
+ },
methods: {
updateIssuable() {
this.updateLoading = true;
@@ -38,9 +47,9 @@
<div class="prepend-top-default append-bottom-default clearfix">
<button
class="btn btn-save pull-left"
- :class="{ disabled: updateLoading }"
+ :class="{ disabled: updateLoading || !isSubmitEnabled }"
type="submit"
- :disabled="updateLoading"
+ :disabled="updateLoading || !isSubmitEnabled"
@click="updateIssuable">
Save changes
<i
diff --git a/app/assets/javascripts/issue_show/components/form.vue b/app/assets/javascripts/issue_show/components/form.vue
index 7732a1c194a..cba3c0830a7 100644
--- a/app/assets/javascripts/issue_show/components/form.vue
+++ b/app/assets/javascripts/issue_show/components/form.vue
@@ -39,6 +39,7 @@
:markdown-preview-url="markdownPreviewUrl"
:markdown-docs="markdownDocs" />
<edit-actions
+ :form-state="formState"
:can-destroy="canDestroy" />
</form>
</template>
diff --git a/spec/javascripts/issue_show/components/edit_actions_spec.js b/spec/javascripts/issue_show/components/edit_actions_spec.js
index 8fbaf6cfb2b..f6625b748b6 100644
--- a/spec/javascripts/issue_show/components/edit_actions_spec.js
+++ b/spec/javascripts/issue_show/components/edit_actions_spec.js
@@ -1,18 +1,26 @@
import Vue from 'vue';
import editActions from '~/issue_show/components/edit_actions.vue';
import eventHub from '~/issue_show/event_hub';
+import Store from '~/issue_show/stores';
describe('Edit Actions components', () => {
let vm;
beforeEach((done) => {
const Component = Vue.extend(editActions);
+ const store = new Store({
+ titleHtml: '',
+ descriptionHtml: '',
+ issuableRef: '',
+ });
+ store.formState.title = 'test';
spyOn(eventHub, '$emit');
vm = new Component({
propsData: {
canDestroy: true,
+ formState: store.formState,
},
}).$mount();
@@ -41,6 +49,18 @@ describe('Edit Actions components', () => {
});
});
+ it('disables submit button when title is blank', (done) => {
+ vm.formState.title = '';
+
+ Vue.nextTick(() => {
+ expect(
+ vm.$el.querySelector('.btn-save').getAttribute('disabled'),
+ ).toBe('disabled');
+
+ done();
+ });
+ });
+
describe('updateIssuable', () => {
it('sends update.issauble event when clicking save button', () => {
vm.$el.querySelector('.btn-save').click();