parent
d037a2e998
commit
5197b011a9
|
@ -45,6 +45,14 @@ export default {
|
||||||
new Flash('An error occured while making the request.');
|
new Flash('An error occured while making the request.');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isActionDisabled(action) {
|
||||||
|
if (action.playable === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !action.playable;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
template: `
|
template: `
|
||||||
|
@ -59,18 +67,23 @@ export default {
|
||||||
:disabled="isLoading">
|
:disabled="isLoading">
|
||||||
<span>
|
<span>
|
||||||
<span v-html="playIconSvg"></span>
|
<span v-html="playIconSvg"></span>
|
||||||
<i class="fa fa-caret-down" aria-hidden="true"></i>
|
<i
|
||||||
<i v-if="isLoading" class="fa fa-spinner fa-spin" aria-hidden="true"></i>
|
class="fa fa-caret-down"
|
||||||
|
aria-hidden="true"/>
|
||||||
|
<i
|
||||||
|
v-if="isLoading"
|
||||||
|
class="fa fa-spinner fa-spin"
|
||||||
|
aria-hidden="true"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<ul class="dropdown-menu dropdown-menu-align-right">
|
<ul class="dropdown-menu dropdown-menu-align-right">
|
||||||
<li v-for="action in actions">
|
<li v-for="action in actions">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@click="onClickAction(action.play_path)"
|
|
||||||
class="js-manual-action-link no-btn btn"
|
class="js-manual-action-link no-btn btn"
|
||||||
:class="{ 'disabled': !action.playable }"
|
@click="onClickAction(action.play_path)"
|
||||||
:disabled="!action.playable">
|
:class="{ 'disabled': isActionDisabled(action) }"
|
||||||
|
:disabled="isActionDisabled(action)">
|
||||||
${playIconSvg}
|
${playIconSvg}
|
||||||
<span>
|
<span>
|
||||||
{{action.name}}
|
{{action.name}}
|
||||||
|
|
|
@ -38,6 +38,14 @@ export default {
|
||||||
new Flash('An error occured while making the request.');
|
new Flash('An error occured while making the request.');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isActionDisabled(action) {
|
||||||
|
if (action.playable === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !action.playable;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
template: `
|
template: `
|
||||||
|
@ -51,8 +59,13 @@ export default {
|
||||||
aria-label="Manual job"
|
aria-label="Manual job"
|
||||||
:disabled="isLoading">
|
:disabled="isLoading">
|
||||||
${playIconSvg}
|
${playIconSvg}
|
||||||
<i class="fa fa-caret-down" aria-hidden="true"></i>
|
<i
|
||||||
<i v-if="isLoading" class="fa fa-spinner fa-spin" aria-hidden="true"></i>
|
class="fa fa-caret-down"
|
||||||
|
aria-hidden="true" />
|
||||||
|
<i
|
||||||
|
v-if="isLoading"
|
||||||
|
class="fa fa-spinner fa-spin"
|
||||||
|
aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<ul class="dropdown-menu dropdown-menu-align-right">
|
<ul class="dropdown-menu dropdown-menu-align-right">
|
||||||
|
@ -60,9 +73,9 @@ export default {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="js-pipeline-action-link no-btn btn"
|
class="js-pipeline-action-link no-btn btn"
|
||||||
:class="{ 'disabled': !action.playable }"
|
|
||||||
@click="onClickAction(action.path)"
|
@click="onClickAction(action.path)"
|
||||||
:disabled="!action.playable">
|
:class="{ 'disabled': isActionDisabled(action) }"
|
||||||
|
:disabled="isActionDisabled(action)">
|
||||||
${playIconSvg}
|
${playIconSvg}
|
||||||
<span>{{action.name}}</span>
|
<span>{{action.name}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -115,21 +115,6 @@ feature 'Environments page', :feature, :js do
|
||||||
.not_to change { Ci::Pipeline.count }
|
.not_to change { Ci::Pipeline.count }
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'when action is non playable', js: true do
|
|
||||||
given(:action) do
|
|
||||||
create(:ci_build, :manual, :non_playable,
|
|
||||||
pipeline: pipeline,
|
|
||||||
name: 'close_app')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has disabled button to the manual action' do
|
|
||||||
find('.js-dropdown-play-icon-container').click
|
|
||||||
|
|
||||||
expect(page).to have_button('close_app', disabled: true)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'does show build name and id' do
|
scenario 'does show build name and id' do
|
||||||
expect(page).to have_link("#{build.name} ##{build.id}")
|
expect(page).to have_link("#{build.name} ##{build.id}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -197,24 +197,6 @@ describe 'Pipelines', :feature, :js do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with non playable manual action' do
|
|
||||||
let!(:manual) do
|
|
||||||
create(:ci_build, :manual, :non_playable,
|
|
||||||
pipeline: pipeline,
|
|
||||||
name: 'manual build',
|
|
||||||
stage: 'test',
|
|
||||||
commands: 'test')
|
|
||||||
end
|
|
||||||
|
|
||||||
before { visit_project_pipelines }
|
|
||||||
|
|
||||||
it 'has disabled button to the manual action' do
|
|
||||||
find('.js-pipeline-dropdown-manual-actions').click
|
|
||||||
|
|
||||||
expect(page).to have_button('manual build', disabled: true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'for generic statuses' do
|
context 'for generic statuses' do
|
||||||
context 'when running' do
|
context 'when running' do
|
||||||
let!(:running) do
|
let!(:running) do
|
||||||
|
|
|
@ -19,6 +19,11 @@ describe('Actions Component', () => {
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
play_path: '#',
|
play_path: '#',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'foo bar',
|
||||||
|
play_path: 'url',
|
||||||
|
playable: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
|
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
|
||||||
|
@ -49,4 +54,14 @@ describe('Actions Component', () => {
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalledWith(actionsMock[0].play_path);
|
expect(spy).toHaveBeenCalledWith(actionsMock[0].play_path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render a disabled action when it\'s not playable', () => {
|
||||||
|
expect(
|
||||||
|
component.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'),
|
||||||
|
).toEqual('disabled');
|
||||||
|
|
||||||
|
expect(
|
||||||
|
component.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'),
|
||||||
|
).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,11 @@ describe('Pipelines Actions dropdown', () => {
|
||||||
name: 'stop_review',
|
name: 'stop_review',
|
||||||
path: '/root/review-app/builds/1893/play',
|
path: '/root/review-app/builds/1893/play',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'foo',
|
||||||
|
path: '#',
|
||||||
|
playable: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
|
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
|
||||||
|
@ -59,4 +64,14 @@ describe('Pipelines Actions dropdown', () => {
|
||||||
|
|
||||||
expect(component.$el.querySelector('.fa-spinner')).toEqual(null);
|
expect(component.$el.querySelector('.fa-spinner')).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render a disabled action when it\'s not playable', () => {
|
||||||
|
expect(
|
||||||
|
component.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'),
|
||||||
|
).toEqual('disabled');
|
||||||
|
|
||||||
|
expect(
|
||||||
|
component.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'),
|
||||||
|
).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue