Merge branch '37179-dashboard-project-dropdown' into 'master'
Removes disabled state from projects dropdown in dashboard page Closes #37179 See merge request !13933
This commit is contained in:
commit
6d6223ecdb
3 changed files with 16 additions and 20 deletions
|
@ -14,7 +14,14 @@ export default class ProjectSelectComboButton {
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
this.projectSelectInput.siblings('.new-project-item-select-button')
|
this.projectSelectInput.siblings('.new-project-item-select-button')
|
||||||
.on('click', this.openDropdown);
|
.on('click', e => this.openDropdown(e));
|
||||||
|
|
||||||
|
this.newItemBtn.on('click', (e) => {
|
||||||
|
if (!this.getProjectFromLocalStorage()) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.openDropdown(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.projectSelectInput.on('change', () => this.selectProject());
|
this.projectSelectInput.on('change', () => this.selectProject());
|
||||||
}
|
}
|
||||||
|
@ -28,8 +35,9 @@ export default class ProjectSelectComboButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openDropdown() {
|
// eslint-disable-next-line class-methods-use-this
|
||||||
$(this).siblings('.project-item-select').select2('open');
|
openDropdown(event) {
|
||||||
|
$(event.currentTarget).siblings('.project-item-select').select2('open');
|
||||||
}
|
}
|
||||||
|
|
||||||
selectProject() {
|
selectProject() {
|
||||||
|
@ -56,10 +64,8 @@ export default class ProjectSelectComboButton {
|
||||||
if (project) {
|
if (project) {
|
||||||
this.newItemBtn.attr('href', project.url);
|
this.newItemBtn.attr('href', project.url);
|
||||||
this.newItemBtn.text(`${this.formattedText.defaultTextPrefix} in ${project.name}`);
|
this.newItemBtn.text(`${this.formattedText.defaultTextPrefix} in ${project.name}`);
|
||||||
this.newItemBtn.enable();
|
|
||||||
} else {
|
} else {
|
||||||
this.newItemBtn.text(`Select project to create ${this.formattedText.presetTextSuffix}`);
|
this.newItemBtn.text(`Select project to create ${this.formattedText.presetTextSuffix}`);
|
||||||
this.newItemBtn.disable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Removes disabled state from dashboard project button
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -32,11 +32,6 @@ describe('Project Select Combo Button', function () {
|
||||||
this.comboButton = new ProjectSelectComboButton(this.projectSelectInput);
|
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 () {
|
it('newItemBtn href is null', function () {
|
||||||
expect(this.newItemBtn.getAttribute('href')).toBe('');
|
expect(this.newItemBtn.getAttribute('href')).toBe('');
|
||||||
});
|
});
|
||||||
|
@ -53,11 +48,6 @@ describe('Project Select Combo Button', function () {
|
||||||
this.comboButton = new ProjectSelectComboButton(this.projectSelectInput);
|
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 () {
|
it('newItemBtn href is correctly set', function () {
|
||||||
expect(this.newItemBtn.getAttribute('href')).toBe(this.defaults.projectMeta.url);
|
expect(this.newItemBtn.getAttribute('href')).toBe(this.defaults.projectMeta.url);
|
||||||
});
|
});
|
||||||
|
@ -82,11 +72,6 @@ describe('Project Select Combo Button', function () {
|
||||||
.trigger('change');
|
.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 () {
|
it('newItemBtn href is correctly set', function () {
|
||||||
expect(this.newItemBtn.getAttribute('href'))
|
expect(this.newItemBtn.getAttribute('href'))
|
||||||
.toBe('http://myothercoolproject.com/issues/new');
|
.toBe('http://myothercoolproject.com/issues/new');
|
||||||
|
|
Loading…
Reference in a new issue