Skip to content
Snippets Groups Projects
Commit 07b75407 authored by Miguel Rincon's avatar Miguel Rincon
Browse files

Remove "type" prop from stage.vue

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