Commit 3b1de17e authored by Phil Hughes's avatar Phil Hughes

Merge branch '8688-recursive-pipelines-rename-variable' into 'master'

Renames isCollapsed to isExpanded to simplify pipelines code

See merge request gitlab-org/gitlab-ee!9076
parents e2e0226b 191d7c67
...@@ -37,8 +37,8 @@ export default { ...@@ -37,8 +37,8 @@ export default {
:key="pipeline.id" :key="pipeline.id"
:class="{ :class="{
'flat-connector-before': index === 0 && graphPosition === 'right', 'flat-connector-before': index === 0 && graphPosition === 'right',
active: !pipeline.isCollapsed || pipeline.isLoading, active: pipeline.isExpanded || pipeline.isLoading,
'left-connector': !pipeline.isCollapsed && graphPosition === 'left', 'left-connector': pipeline.isExpanded && graphPosition === 'left',
}" }"
:pipeline-id="pipeline.id" :pipeline-id="pipeline.id"
:project-name="pipeline.project.name" :project-name="pipeline.project.name"
......
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
* @param {Object} pipeline The clicked pipeline * @param {Object} pipeline The clicked pipeline
*/ */
clickPipeline(method, storeKey, resetStoreKey, pipeline, pollKey) { clickPipeline(method, storeKey, resetStoreKey, pipeline, pollKey) {
if (pipeline.isCollapsed) { if (!pipeline.isExpanded) {
this.mediator[method](pipeline); this.mediator[method](pipeline);
} else { } else {
this.mediator.resetPipeline(storeKey, pipeline, resetStoreKey, pollKey); this.mediator.resetPipeline(storeKey, pipeline, resetStoreKey, pollKey);
......
...@@ -22,9 +22,9 @@ export default class PipelineStore extends CePipelineStore { ...@@ -22,9 +22,9 @@ export default class PipelineStore extends CePipelineStore {
} }
/** /**
* For the triggered pipelines, parses them to add `isLoading` and `isCollapsed` keys * For the triggered pipelines, parses them to add `isLoading` and `isExpanded` keys
* *
* For the triggered_by pipeline, parsed the object to add `isLoading` and `isCollapsed` keys * For the triggered_by pipeline, parsed the object to add `isLoading` and `isExpanded` keys
* and saves it as an array * and saves it as an array
* *
* @param {Object} pipeline * @param {Object} pipeline
...@@ -40,7 +40,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -40,7 +40,7 @@ export default class PipelineStore extends CePipelineStore {
); );
return Object.assign({}, triggered, { return Object.assign({}, triggered, {
isCollapsed: oldPipeline ? oldPipeline.isCollapsed : true, isExpanded: oldPipeline ? oldPipeline.isExpanded : false,
isLoading: oldPipeline ? oldPipeline.isLoading : false, isLoading: oldPipeline ? oldPipeline.isLoading : false,
}); });
}); });
...@@ -49,9 +49,9 @@ export default class PipelineStore extends CePipelineStore { ...@@ -49,9 +49,9 @@ export default class PipelineStore extends CePipelineStore {
if (pipeline.triggered_by) { if (pipeline.triggered_by) {
this.state.triggeredByPipelines = [ this.state.triggeredByPipelines = [
Object.assign({}, pipeline.triggered_by, { Object.assign({}, pipeline.triggered_by, {
isCollapsed: this.state.triggeredByPipelines.length isExpanded: this.state.triggeredByPipelines.length
? this.state.triggeredByPipelines[0].isCollapsed ? this.state.triggeredByPipelines[0].isExpanded
: true, : false,
isLoading: this.state.triggeredByPipelines.length isLoading: this.state.triggeredByPipelines.length
? this.state.triggeredByPipelines[0].isLoading ? this.state.triggeredByPipelines[0].isLoading
: false, : false,
...@@ -67,7 +67,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -67,7 +67,7 @@ export default class PipelineStore extends CePipelineStore {
/** /**
* Called when the user clicks on a pipeline that was triggered by the main one. * Called when the user clicks on a pipeline that was triggered by the main one.
* *
* Resets isCollapsed and isLoading props for all triggered (downstream) pipelines * Resets isExpanded and isLoading props for all triggered (downstream) pipelines
* Sets isLoading to true for the requested one. * Sets isLoading to true for the requested one.
* *
* @param {Object} pipeline * @param {Object} pipeline
...@@ -89,7 +89,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -89,7 +89,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline( this.updatePipeline(
pipelinesKeys.triggeredPipelines, pipelinesKeys.triggeredPipelines,
pipeline, pipeline,
{ isLoading: false, isCollapsed: false }, { isLoading: false, isExpanded: true },
pipelinesKeys.triggered, pipelinesKeys.triggered,
response, response,
); );
...@@ -106,7 +106,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -106,7 +106,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline( this.updatePipeline(
pipelinesKeys.triggeredPipelines, pipelinesKeys.triggeredPipelines,
pipeline, pipeline,
{ isLoading: false, isCollapsed: true }, { isLoading: false, isExpanded: false },
pipelinesKeys.triggered, pipelinesKeys.triggered,
{}, {},
); );
...@@ -120,7 +120,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -120,7 +120,7 @@ export default class PipelineStore extends CePipelineStore {
* Called when the user clicks on the pipeline that triggered the main one. * Called when the user clicks on the pipeline that triggered the main one.
* *
* Handle the request for the upstream pipeline * Handle the request for the upstream pipeline
* Updates the given pipeline with isLoading: true and iscollapsed: false * Updates the given pipeline with isLoading: true and isExpanded: true
* *
* @param {Object} pipeline * @param {Object} pipeline
*/ */
...@@ -138,7 +138,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -138,7 +138,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline( this.updatePipeline(
pipelinesKeys.triggeredByPipelines, pipelinesKeys.triggeredByPipelines,
pipeline, pipeline,
{ isLoading: false, isCollapsed: false }, { isLoading: false, isExpanded: true },
pipelinesKeys.triggeredBy, pipelinesKeys.triggeredBy,
response, response,
); );
...@@ -152,7 +152,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -152,7 +152,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline( this.updatePipeline(
pipelinesKeys.triggeredByPipelines, pipelinesKeys.triggeredByPipelines,
pipeline, pipeline,
{ isLoading: false, isCollapsed: true }, { isLoading: false, isExpanded: false },
pipelinesKeys.triggeredBy, pipelinesKeys.triggeredBy,
{}, {},
); );
...@@ -173,7 +173,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -173,7 +173,7 @@ export default class PipelineStore extends CePipelineStore {
*/ */
static parsePipeline(pipeline) { static parsePipeline(pipeline) {
return Object.assign({}, pipeline, { return Object.assign({}, pipeline, {
isCollapsed: true, isExpanded: false,
isLoading: false, isLoading: false,
}); });
} }
...@@ -190,7 +190,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -190,7 +190,7 @@ export default class PipelineStore extends CePipelineStore {
/** /**
* Updates the pipelines to reflect which one was requested. * Updates the pipelines to reflect which one was requested.
* It sets isLoading to true and isCollapsed to false * It sets isLoading to true and isExpanded to false
* *
* @param {String} storeKey which property to update: `triggeredPipelines|triggeredByPipelines` * @param {String} storeKey which property to update: `triggeredPipelines|triggeredByPipelines`
* @param {Object} pipeline the requested pipeline * @param {Object} pipeline the requested pipeline
...@@ -198,7 +198,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -198,7 +198,7 @@ export default class PipelineStore extends CePipelineStore {
updateStoreOnRequest(storeKey, pipeline) { updateStoreOnRequest(storeKey, pipeline) {
this.state[storeKey] = this.state[storeKey].map(triggered => { this.state[storeKey] = this.state[storeKey].map(triggered => {
if (triggered.id === pipeline.id) { if (triggered.id === pipeline.id) {
return Object.assign({}, triggered, { isLoading: true, isCollapsed: false }); return Object.assign({}, triggered, { isLoading: true, isExpanded: true });
} }
// reset the others, in case another was one opened // reset the others, in case another was one opened
return PipelineStore.parsePipeline(triggered); return PipelineStore.parsePipeline(triggered);
...@@ -238,7 +238,7 @@ export default class PipelineStore extends CePipelineStore { ...@@ -238,7 +238,7 @@ export default class PipelineStore extends CePipelineStore {
pipeline, pipeline,
{ {
isLoading: false, isLoading: false,
isCollapsed: true, isExpanded: false,
}, },
visiblePipelineKey, visiblePipelineKey,
{}, {},
......
...@@ -73,16 +73,16 @@ describe('EE Pipeline store', () => { ...@@ -73,16 +73,16 @@ describe('EE Pipeline store', () => {
expect(store.triggeredPipelines[0].isLoading).toEqual(true); expect(store.triggeredPipelines[0].isLoading).toEqual(true);
}); });
it('sets isCollapsed to false for the requested pipeline', () => { it('sets isExpanded to true for the requested pipeline', () => {
expect(store.triggeredPipelines[0].isCollapsed).toEqual(false); expect(store.triggeredPipelines[0].isExpanded).toEqual(true);
}); });
it('sets isLoading to false for the other pipelines', () => { it('sets isLoading to false for the other pipelines', () => {
expect(store.triggeredPipelines[1].isLoading).toEqual(false); expect(store.triggeredPipelines[1].isLoading).toEqual(false);
}); });
it('sets isCollapsed to true for the other pipelines', () => { it('sets isExpanded to false for the other pipelines', () => {
expect(store.triggeredPipelines[1].isCollapsed).toEqual(true); expect(store.triggeredPipelines[1].isExpanded).toEqual(false);
}); });
}); });
...@@ -104,7 +104,7 @@ describe('EE Pipeline store', () => { ...@@ -104,7 +104,7 @@ describe('EE Pipeline store', () => {
store.receiveTriggeredPipelineError(receivedPipeline); store.receiveTriggeredPipelineError(receivedPipeline);
expect(store.triggeredPipelines[0].isLoading).toEqual(false); expect(store.triggeredPipelines[0].isLoading).toEqual(false);
expect(store.triggeredPipelines[0].isCollapsed).toEqual(true); expect(store.triggeredPipelines[0].isExpanded).toEqual(false);
expect(store.triggered).toEqual({}); expect(store.triggered).toEqual({});
}); });
...@@ -121,8 +121,8 @@ describe('EE Pipeline store', () => { ...@@ -121,8 +121,8 @@ describe('EE Pipeline store', () => {
expect(store.triggeredByPipelines[0].isLoading).toEqual(true); expect(store.triggeredByPipelines[0].isLoading).toEqual(true);
}); });
it('sets isCollapsed to false for the requested pipeline', () => { it('sets isExpanded to true for the requested pipeline', () => {
expect(store.triggeredByPipelines[0].isCollapsed).toEqual(false); expect(store.triggeredByPipelines[0].isExpanded).toEqual(true);
}); });
}); });
...@@ -144,7 +144,7 @@ describe('EE Pipeline store', () => { ...@@ -144,7 +144,7 @@ describe('EE Pipeline store', () => {
store.receiveTriggeredByPipelineError(receivedPipeline); store.receiveTriggeredByPipelineError(receivedPipeline);
expect(store.triggeredByPipelines[0].isLoading).toEqual(false); expect(store.triggeredByPipelines[0].isLoading).toEqual(false);
expect(store.triggeredByPipelines[0].isCollapsed).toEqual(true); expect(store.triggeredByPipelines[0].isExpanded).toEqual(false);
expect(store.triggeredBy).toEqual({}); expect(store.triggeredBy).toEqual({});
}); });
...@@ -162,8 +162,8 @@ describe('EE Pipeline store', () => { ...@@ -162,8 +162,8 @@ describe('EE Pipeline store', () => {
expect(parsed.isLoading).toEqual(false); expect(parsed.isLoading).toEqual(false);
}); });
it('adds isCollapsed key set to true', () => { it('adds isExpanded key set to false', () => {
expect(parsed.isCollapsed).toEqual(true); expect(parsed.isExpanded).toEqual(false);
}); });
}); });
...@@ -188,10 +188,10 @@ describe('EE Pipeline store', () => { ...@@ -188,10 +188,10 @@ describe('EE Pipeline store', () => {
expect(store.triggeredPipelines[1].isLoading).isLoading(true); expect(store.triggeredPipelines[1].isLoading).isLoading(true);
}); });
it('sets clicked pipeline isCollapsed to false', () => { it('sets clicked pipeline isExpanded to true', () => {
store.updateStoreOnRequest('triggeredPipelines', store.triggeredPipelines[1]); store.updateStoreOnRequest('triggeredPipelines', store.triggeredPipelines[1]);
expect(store.triggeredPipelines[1].isCollapsed).isLoading(false); expect(store.triggeredPipelines[1].isExpanded).isLoading(true);
}); });
}); });
...@@ -225,12 +225,12 @@ describe('EE Pipeline store', () => { ...@@ -225,12 +225,12 @@ describe('EE Pipeline store', () => {
const clickedPipeline = store.triggeredPipelines[1]; const clickedPipeline = store.triggeredPipelines[1];
// open it first // open it first
clickedPipeline.isCollapsed = false; clickedPipeline.isExpanded = true;
store.triggered = clickedPipeline; store.triggered = clickedPipeline;
store.closePipeline('triggeredPipelines', clickedPipeline, 'triggered'); store.closePipeline('triggeredPipelines', clickedPipeline, 'triggered');
expect(store.triggeredPipelines[1].isCollapsed).toEqual(false); expect(store.triggeredPipelines[1].isExpanded).toEqual(true);
expect(store.triggered).toEqual({}); expect(store.triggered).toEqual({});
}); });
}); });
......
...@@ -122,7 +122,7 @@ describe('graph component', () => { ...@@ -122,7 +122,7 @@ describe('graph component', () => {
isLoading: false, isLoading: false,
pipeline: graphJSON, pipeline: graphJSON,
triggeredByPipelines: [ triggeredByPipelines: [
Object.assign({}, linkedPipelineJSON.triggered_by, { isCollapsed: false }), Object.assign({}, linkedPipelineJSON.triggered_by, { isExpanded: true }),
], ],
triggeredPipelines: linkedPipelineJSON.triggered, triggeredPipelines: linkedPipelineJSON.triggered,
triggeredBy: linkedPipelineJSON.triggered_by, triggeredBy: linkedPipelineJSON.triggered_by,
...@@ -151,7 +151,7 @@ describe('graph component', () => { ...@@ -151,7 +151,7 @@ describe('graph component', () => {
pipeline: graphJSON, pipeline: graphJSON,
triggeredByPipelines: [linkedPipelineJSON.triggered_by], triggeredByPipelines: [linkedPipelineJSON.triggered_by],
triggeredPipelines: [ triggeredPipelines: [
Object.assign({}, linkedPipelineJSON.triggered[0], { isCollapsed: false }), Object.assign({}, linkedPipelineJSON.triggered[0], { isExpanded: true }),
], ],
triggered: linkedPipelineJSON.triggered[0], triggered: linkedPipelineJSON.triggered[0],
}); });
......
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