Commit e8bb227d authored by Mike Greiling's avatar Mike Greiling

Merge branch '300403-remove-type-from-minipipeline-stage' into 'master'

Replace "type"  prop with events in stage.vue

See merge request gitlab-org/gitlab!54962
parents bccf4627 07b75407
...@@ -3,7 +3,6 @@ import { GlButton, GlTooltipDirective, GlModalDirective } from '@gitlab/ui'; ...@@ -3,7 +3,6 @@ import { GlButton, GlTooltipDirective, GlModalDirective } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import CiBadge from '~/vue_shared/components/ci_badge_link.vue'; import CiBadge from '~/vue_shared/components/ci_badge_link.vue';
import CommitComponent from '~/vue_shared/components/commit.vue'; import CommitComponent from '~/vue_shared/components/commit.vue';
import { PIPELINES_TABLE } from '../../constants';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
import PipelineTriggerer from './pipeline_triggerer.vue'; import PipelineTriggerer from './pipeline_triggerer.vue';
import PipelineUrl from './pipeline_url.vue'; import PipelineUrl from './pipeline_url.vue';
...@@ -57,7 +56,6 @@ export default { ...@@ -57,7 +56,6 @@ export default {
default: null, default: null,
}, },
}, },
pipelinesTable: PIPELINES_TABLE,
data() { data() {
return { return {
isRetrying: false, isRetrying: false,
...@@ -173,6 +171,10 @@ export default { ...@@ -173,6 +171,10 @@ export default {
this.isRetrying = true; this.isRetrying = true;
eventHub.$emit('retryPipeline', this.pipeline.retry_path); eventHub.$emit('retryPipeline', this.pipeline.retry_path);
}, },
handlePipelineActionRequestComplete() {
// warn the pipelines table to update
eventHub.$emit('refreshPipelinesTable');
},
}, },
}; };
</script> </script>
...@@ -220,9 +222,9 @@ export default { ...@@ -220,9 +222,9 @@ export default {
data-testid="widget-mini-pipeline-graph" data-testid="widget-mini-pipeline-graph"
> >
<pipeline-stage <pipeline-stage
:type="$options.pipelinesTable"
:stage="stage" :stage="stage"
:update-dropdown="updateGraphDropdown" :update-dropdown="updateGraphDropdown"
@pipelineActionRequestComplete="handlePipelineActionRequestComplete"
/> />
</div> </div>
</template> </template>
......
...@@ -15,7 +15,6 @@ import { GlDropdown, GlLoadingIcon, GlTooltipDirective, GlIcon } from '@gitlab/u ...@@ -15,7 +15,6 @@ import { GlDropdown, GlLoadingIcon, GlTooltipDirective, GlIcon } from '@gitlab/u
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { PIPELINES_TABLE } from '../../constants';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
import JobItem from '../graph/job_item.vue'; import JobItem from '../graph/job_item.vue';
...@@ -39,11 +38,6 @@ export default { ...@@ -39,11 +38,6 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
type: {
type: String,
required: false,
default: '',
},
}, },
data() { data() {
return { return {
...@@ -90,13 +84,11 @@ export default { ...@@ -90,13 +84,11 @@ export default {
return this.$el.classList.contains('show'); return this.$el.classList.contains('show');
}, },
pipelineActionRequestComplete() { pipelineActionRequestComplete() {
if (this.type === PIPELINES_TABLE) {
// warn the pipelines table to update
eventHub.$emit('refreshPipelinesTable');
return;
}
// close the dropdown in MR widget // close the dropdown in MR widget
this.$refs.stageGlDropdown.hide(); this.$refs.stageGlDropdown.hide();
// warn the pipelines table to update
this.$emit('pipelineActionRequestComplete');
}, },
}, },
}; };
......
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export const CANCEL_REQUEST = 'CANCEL_REQUEST'; export const CANCEL_REQUEST = 'CANCEL_REQUEST';
export const PIPELINES_TABLE = 'PIPELINES_TABLE';
export const LAYOUT_CHANGE_DELAY = 300; export const LAYOUT_CHANGE_DELAY = 300;
export const FILTER_PIPELINES_SEARCH_DELAY = 200; export const FILTER_PIPELINES_SEARCH_DELAY = 200;
export const ANY_TRIGGER_AUTHOR = 'Any'; export const ANY_TRIGGER_AUTHOR = 'Any';
......
...@@ -142,6 +142,8 @@ describe('Pipelines stage component', () => { ...@@ -142,6 +142,8 @@ describe('Pipelines stage component', () => {
beforeEach(() => { beforeEach(() => {
mock.onGet(dropdownPath).reply(200, stageReply); mock.onGet(dropdownPath).reply(200, stageReply);
mock.onPost(`${stageReply.latest_statuses[0].status.action.path}.json`).reply(200); mock.onPost(`${stageReply.latest_statuses[0].status.action.path}.json`).reply(200);
createComponent();
}); });
const clickCiAction = async () => { const clickCiAction = async () => {
...@@ -152,34 +154,22 @@ describe('Pipelines stage component', () => { ...@@ -152,34 +154,22 @@ describe('Pipelines stage component', () => {
await axios.waitForAll(); await axios.waitForAll();
}; };
describe('within pipeline table', () => { it('closes dropdown when job item action is clicked', async () => {
beforeEach(() => { const hidden = jest.fn();
createComponent({ type: 'PIPELINES_TABLE' });
});
it('emits `refreshPipelinesTable` event when `pipelineActionRequestComplete` is triggered', async () => {
await clickCiAction();
expect(eventHub.$emit).toHaveBeenCalledWith('refreshPipelinesTable');
});
});
describe('in MR widget', () => { wrapper.vm.$root.$on('bv::dropdown::hide', hidden);
beforeEach(() => {
createComponent();
});
it('closes the dropdown when `pipelineActionRequestComplete` is triggered', async () => { expect(hidden).toHaveBeenCalledTimes(0);
const hidden = jest.fn();
wrapper.vm.$root.$on('bv::dropdown::hide', hidden); await clickCiAction();
expect(hidden).toHaveBeenCalledTimes(0); expect(hidden).toHaveBeenCalledTimes(1);
});
await clickCiAction(); it('emits `pipelineActionRequestComplete` when job item action is clicked', async () => {
await clickCiAction();
expect(hidden).toHaveBeenCalledTimes(1); expect(wrapper.emitted('pipelineActionRequestComplete')).toHaveLength(1);
});
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment