From 0b50c9226c0ce152be90d269db867bd3c750dfe5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 31 Aug 2017 10:48:16 +0000 Subject: Revert "Merge branch '37179-dashboard-project-dropdown' into 'master'" This reverts commit 6d6223ecdb3b87a061aecf7b2c586cadc0f29695, reversing changes made to cc7811707424ebd58b71428c9fe27c444dd6169d. --- app/assets/javascripts/project_select_combo_button.js | 16 +++++----------- .../unreleased/37179-dashboard-project-dropdown.yml | 5 ----- spec/javascripts/project_select_combo_button_spec.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 changelogs/unreleased/37179-dashboard-project-dropdown.yml diff --git a/app/assets/javascripts/project_select_combo_button.js b/app/assets/javascripts/project_select_combo_button.js index 6820148ad19..822ca41a574 100644 --- a/app/assets/javascripts/project_select_combo_button.js +++ b/app/assets/javascripts/project_select_combo_button.js @@ -14,14 +14,7 @@ export default class ProjectSelectComboButton { bindEvents() { this.projectSelectInput.siblings('.new-project-item-select-button') - .on('click', e => this.openDropdown(e)); - - this.newItemBtn.on('click', (e) => { - if (!this.getProjectFromLocalStorage()) { - e.preventDefault(); - this.openDropdown(e); - } - }); + .on('click', this.openDropdown); this.projectSelectInput.on('change', () => this.selectProject()); } @@ -37,9 +30,8 @@ export default class ProjectSelectComboButton { } } - // eslint-disable-next-line class-methods-use-this - openDropdown(event) { - $(event.currentTarget).siblings('.project-item-select').select2('open'); + openDropdown() { + $(this).siblings('.project-item-select').select2('open'); } selectProject() { @@ -66,8 +58,10 @@ export default class ProjectSelectComboButton { if (project) { this.newItemBtn.attr('href', project.url); this.newItemBtn.text(`${this.formattedText.defaultTextPrefix} in ${project.name}`); + this.newItemBtn.enable(); } else { this.newItemBtn.text(`Select project to create ${this.formattedText.presetTextSuffix}`); + this.newItemBtn.disable(); } } diff --git a/changelogs/unreleased/37179-dashboard-project-dropdown.yml b/changelogs/unreleased/37179-dashboard-project-dropdown.yml deleted file mode 100644 index 3ef080b8eae..00000000000 --- a/changelogs/unreleased/37179-dashboard-project-dropdown.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Removes disabled state from dashboard project button -merge_request: -author: -type: fixed diff --git a/spec/javascripts/project_select_combo_button_spec.js b/spec/javascripts/project_select_combo_button_spec.js index bd838559556..e10a5a3bef6 100644 --- a/spec/javascripts/project_select_combo_button_spec.js +++ b/spec/javascripts/project_select_combo_button_spec.js @@ -32,6 +32,11 @@ describe('Project Select Combo Button', function () { this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); }); + it('newItemBtn is disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(true); + expect(this.newItemBtn.classList.contains('disabled')).toBe(true); + }); + it('newItemBtn href is null', function () { expect(this.newItemBtn.getAttribute('href')).toBe(''); }); @@ -48,6 +53,11 @@ describe('Project Select Combo Button', function () { this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); }); + it('newItemBtn is not disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(false); + expect(this.newItemBtn.classList.contains('disabled')).toBe(false); + }); + it('newItemBtn href is correctly set', function () { expect(this.newItemBtn.getAttribute('href')).toBe(this.defaults.projectMeta.url); }); @@ -72,6 +82,11 @@ describe('Project Select Combo Button', function () { .trigger('change'); }); + it('newItemBtn is not disabled', function () { + expect(this.newItemBtn.hasAttribute('disabled')).toBe(false); + expect(this.newItemBtn.classList.contains('disabled')).toBe(false); + }); + it('newItemBtn href is correctly set', function () { expect(this.newItemBtn.getAttribute('href')) .toBe('http://myothercoolproject.com/issues/new'); -- cgit v1.2.3