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 {
:key="pipeline.id"
:class="{
'flat-connector-before': index === 0 && graphPosition === 'right',
active: !pipeline.isCollapsed || pipeline.isLoading,
'left-connector': !pipeline.isCollapsed && graphPosition === 'left',
active: pipeline.isExpanded || pipeline.isLoading,
'left-connector': pipeline.isExpanded && graphPosition === 'left',
}"
:pipeline-id="pipeline.id"
:project-name="pipeline.project.name"
......
......@@ -14,7 +14,7 @@ export default {
* @param {Object} pipeline The clicked pipeline
*/
clickPipeline(method, storeKey, resetStoreKey, pipeline, pollKey) {
if (pipeline.isCollapsed) {
if (!pipeline.isExpanded) {
this.mediator[method](pipeline);
} else {
this.mediator.resetPipeline(storeKey, pipeline, resetStoreKey, pollKey);
......
......@@ -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
*
* @param {Object} pipeline
......@@ -40,7 +40,7 @@ export default class PipelineStore extends CePipelineStore {
);
return Object.assign({}, triggered, {
isCollapsed: oldPipeline ? oldPipeline.isCollapsed : true,
isExpanded: oldPipeline ? oldPipeline.isExpanded : false,
isLoading: oldPipeline ? oldPipeline.isLoading : false,
});
});
......@@ -49,9 +49,9 @@ export default class PipelineStore extends CePipelineStore {
if (pipeline.triggered_by) {
this.state.triggeredByPipelines = [
Object.assign({}, pipeline.triggered_by, {
isCollapsed: this.state.triggeredByPipelines.length
? this.state.triggeredByPipelines[0].isCollapsed
: true,
isExpanded: this.state.triggeredByPipelines.length
? this.state.triggeredByPipelines[0].isExpanded
: false,
isLoading: this.state.triggeredByPipelines.length
? this.state.triggeredByPipelines[0].isLoading
: false,
......@@ -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.
*
* 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.
*
* @param {Object} pipeline
......@@ -89,7 +89,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline(
pipelinesKeys.triggeredPipelines,
pipeline,
{ isLoading: false, isCollapsed: false },
{ isLoading: false, isExpanded: true },
pipelinesKeys.triggered,
response,
);
......@@ -106,7 +106,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline(
pipelinesKeys.triggeredPipelines,
pipeline,
{ isLoading: false, isCollapsed: true },
{ isLoading: false, isExpanded: false },
pipelinesKeys.triggered,
{},
);
......@@ -120,7 +120,7 @@ export default class PipelineStore extends CePipelineStore {
* Called when the user clicks on the pipeline that triggered the main one.
*
* 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
*/
......@@ -138,7 +138,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline(
pipelinesKeys.triggeredByPipelines,
pipeline,
{ isLoading: false, isCollapsed: false },
{ isLoading: false, isExpanded: true },
pipelinesKeys.triggeredBy,
response,
);
......@@ -152,7 +152,7 @@ export default class PipelineStore extends CePipelineStore {
this.updatePipeline(
pipelinesKeys.triggeredByPipelines,
pipeline,
{ isLoading: false, isCollapsed: true },
{ isLoading: false, isExpanded: false },
pipelinesKeys.triggeredBy,
{},
);
......@@ -173,7 +173,7 @@ export default class PipelineStore extends CePipelineStore {
*/
static parsePipeline(pipeline) {
return Object.assign({}, pipeline, {
isCollapsed: true,
isExpanded: false,
isLoading: false,
});
}
......@@ -190,7 +190,7 @@ export default class PipelineStore extends CePipelineStore {
/**
* 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 {Object} pipeline the requested pipeline
......@@ -198,7 +198,7 @@ export default class PipelineStore extends CePipelineStore {
updateStoreOnRequest(storeKey, pipeline) {
this.state[storeKey] = this.state[storeKey].map(triggered => {
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
return PipelineStore.parsePipeline(triggered);
......@@ -238,7 +238,7 @@ export default class PipelineStore extends CePipelineStore {
pipeline,
{
isLoading: false,
isCollapsed: true,
isExpanded: false,
},
visiblePipelineKey,
{},
......
......@@ -73,16 +73,16 @@ describe('EE Pipeline store', () => {
expect(store.triggeredPipelines[0].isLoading).toEqual(true);
});
it('sets isCollapsed to false for the requested pipeline', () => {
expect(store.triggeredPipelines[0].isCollapsed).toEqual(false);
it('sets isExpanded to true for the requested pipeline', () => {
expect(store.triggeredPipelines[0].isExpanded).toEqual(true);
});
it('sets isLoading to false for the other pipelines', () => {
expect(store.triggeredPipelines[1].isLoading).toEqual(false);
});
it('sets isCollapsed to true for the other pipelines', () => {
expect(store.triggeredPipelines[1].isCollapsed).toEqual(true);
it('sets isExpanded to false for the other pipelines', () => {
expect(store.triggeredPipelines[1].isExpanded).toEqual(false);
});
});
......@@ -104,7 +104,7 @@ describe('EE Pipeline store', () => {
store.receiveTriggeredPipelineError(receivedPipeline);
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({});
});
......@@ -121,8 +121,8 @@ describe('EE Pipeline store', () => {
expect(store.triggeredByPipelines[0].isLoading).toEqual(true);
});
it('sets isCollapsed to false for the requested pipeline', () => {
expect(store.triggeredByPipelines[0].isCollapsed).toEqual(false);
it('sets isExpanded to true for the requested pipeline', () => {
expect(store.triggeredByPipelines[0].isExpanded).toEqual(true);
});
});
......@@ -144,7 +144,7 @@ describe('EE Pipeline store', () => {
store.receiveTriggeredByPipelineError(receivedPipeline);
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({});
});
......@@ -162,8 +162,8 @@ describe('EE Pipeline store', () => {
expect(parsed.isLoading).toEqual(false);
});
it('adds isCollapsed key set to true', () => {
expect(parsed.isCollapsed).toEqual(true);
it('adds isExpanded key set to false', () => {
expect(parsed.isExpanded).toEqual(false);
});
});
......@@ -188,10 +188,10 @@ describe('EE Pipeline store', () => {
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]);
expect(store.triggeredPipelines[1].isCollapsed).isLoading(false);
expect(store.triggeredPipelines[1].isExpanded).isLoading(true);
});
});
......@@ -225,12 +225,12 @@ describe('EE Pipeline store', () => {
const clickedPipeline = store.triggeredPipelines[1];
// open it first
clickedPipeline.isCollapsed = false;
clickedPipeline.isExpanded = true;
store.triggered = clickedPipeline;
store.closePipeline('triggeredPipelines', clickedPipeline, 'triggered');
expect(store.triggeredPipelines[1].isCollapsed).toEqual(false);
expect(store.triggeredPipelines[1].isExpanded).toEqual(true);
expect(store.triggered).toEqual({});
});
});
......
......@@ -122,7 +122,7 @@ describe('graph component', () => {
isLoading: false,
pipeline: graphJSON,
triggeredByPipelines: [
Object.assign({}, linkedPipelineJSON.triggered_by, { isCollapsed: false }),
Object.assign({}, linkedPipelineJSON.triggered_by, { isExpanded: true }),
],
triggeredPipelines: linkedPipelineJSON.triggered,
triggeredBy: linkedPipelineJSON.triggered_by,
......@@ -151,7 +151,7 @@ describe('graph component', () => {
pipeline: graphJSON,
triggeredByPipelines: [linkedPipelineJSON.triggered_by],
triggeredPipelines: [
Object.assign({}, linkedPipelineJSON.triggered[0], { isCollapsed: false }),
Object.assign({}, linkedPipelineJSON.triggered[0], { isExpanded: true }),
],
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