Skip to content

Commit

Permalink
Stage sections not properly captured (#28)
Browse files Browse the repository at this point in the history
* JENKINS-41964 show the normal header
* Bug capturing 'unknown' sections on stages
* decouple editor from aggregator
  • Loading branch information
kzantow committed Feb 15, 2017
1 parent c6126e0 commit c7290fa
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 65 deletions.
75 changes: 64 additions & 11 deletions pom.xml
Expand Up @@ -25,7 +25,7 @@
<jenkins.version>2.7.1</jenkins.version>
<node.version>6.2.1</node.version>
<npm.version>3.9.3</npm.version>
<blueocean.version>1.0.0-b21</blueocean.version>
<blueocean.version>1.0.0-b23</blueocean.version>
<declarative.version>1.0</declarative.version>
</properties>

Expand Down Expand Up @@ -80,26 +80,79 @@
<artifactId>blueocean-rest</artifactId>
<version>${blueocean.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-web</artifactId>
<version>${blueocean.version}</version>
</dependency>
<dependency>
<groupId>io.jenkins.blueocean</groupId>
<artifactId>blueocean-commons</artifactId>
<version>${blueocean.version}</version>
</dependency>
<dependency>
<groupId>io.jenkins.blueocean</groupId>
<artifactId>blueocean-pipeline-api-impl</artifactId>
<version>${blueocean.version}</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>${declarative.version}</version>
</dependency>

<!-- test deps for hpi:run -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.6</version>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-dashboard</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.23</version>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-personalization</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>

<!-- test deps for hpi:run -->
<dependency>
<groupId>io.jenkins.blueocean</groupId>
<artifactId>blueocean</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-i18n</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-jwt</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-rest-impl</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-pipeline-api-impl</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-config</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-github-pipeline</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blueocean-git-pipeline</artifactId>
<version>${blueocean.version}</version>
<scope>test</scope>
</dependency>
Expand Down
8 changes: 1 addition & 7 deletions src/main/js/components/EditorPreview.jsx
Expand Up @@ -5,12 +5,6 @@ import { EditorPage } from './editor/EditorPage';
import { EditorMain } from './editor/EditorMain';
import Extensions from '@jenkins-cd/js-extensions';

const pageStyles = {
display: "flex",
width: "100%",
height: "100%"
};

/**
This is basically adapted from the Storybooks entry, for the purposes of connecting a demo into the main appendEvent
*/
Expand All @@ -20,7 +14,7 @@ export class EditorPreview extends Component {
}
render() {
return (
<EditorPage style={pageStyles}>
<EditorPage>
<Extensions.Renderer extensionPoint="pipeline.editor.css"/>
<EditorMain />
</EditorPage>
Expand Down
16 changes: 9 additions & 7 deletions src/main/js/components/editor/EditorPage.jsx
Expand Up @@ -2,6 +2,7 @@

import React, { Component, PropTypes } from 'react';
import { Dialog } from '@jenkins-cd/design-language';
import { ContentPageHeader } from '@jenkins-cd/blueocean-core-js';
import pipelineStore from '../../services/PipelineStore';
import { convertInternalModelToJson, convertJsonToPipeline, convertPipelineToJson, convertJsonToInternalModel } from '../../services/PipelineSyntaxConverter';
import type { PipelineInfo } from '../../services/PipelineStore';
Expand All @@ -14,7 +15,6 @@ const PIPELINE_KEY = 'jenkins.pipeline.editor.workingCopy';
type Props = {
title?: string,
children: Component<*,*,*>[],
style?: ?Object,
};

type State = {
Expand All @@ -34,7 +34,6 @@ export class EditorPage extends Component<DefaultProps, Props, State> {
static propTypes = {
title: PropTypes.string,
children: PropTypes.array,
style: PropTypes.object,
};

pipelineUpdated: Function;
Expand Down Expand Up @@ -137,18 +136,21 @@ export class EditorPage extends Component<DefaultProps, Props, State> {

render() {

let {title = "Create Pipeline", style} = this.props;
let {title = "Create Pipeline"} = this.props;

return (
<div className="pipeline-editor" style={style}>
<div className="editor-page-header">
<h3>{ title }</h3>
<div className="pipeline-editor">
<ContentPageHeader>
<div className="u-flex-grow">
<h1>{ title }</h1>
</div>
<div className="editor-page-header-controls">
{false && <button disabled={this.currentHistoryIndex <= 0} className="btn-secondary inverse" onClick={() => this.undo()}>Undo</button>}
<button className="btn-secondary inverse" onClick={() => this.newPipeline()}>New</button>
<button className="btn inverse" onClick={() => this.showPipelineScriptDialog()}>Load/Save</button>
</div>
</div>
</ContentPageHeader>

{this.props.children}
{this.state.showPipelineScript &&
<Dialog className="editor-pipeline-dialog" onDismiss={() => this.setState({showPipelineScript: false})}
Expand Down
10 changes: 4 additions & 6 deletions src/main/js/services/PipelineSyntaxConverter.js
Expand Up @@ -145,6 +145,8 @@ export function convertJsonToInternalModel(json: PipelineJsonContainer): Pipelin
topStageInfo.agent = topStage.agent;
topStageInfo.environment = convertEnvironmentToInternal(topStage.environment);

captureUnknownSections(topStage, topStageInfo, 'name', 'steps', 'environment', 'agent');

out.children.push(topStageInfo);

for (let j = 0; j < topStage.branches.length; j++) {
Expand All @@ -166,8 +168,6 @@ export function convertJsonToInternalModel(json: PipelineJsonContainer): Pipelin
topStageInfo.children.push(stage);
}

captureUnknownSections(b, stage, 'name', 'steps', 'environment', 'agent');

for (let stepIndex = 0; stepIndex < b.steps.length; stepIndex++) {
const s = b.steps[stepIndex];
const step = convertStepFromJson(s);
Expand Down Expand Up @@ -290,6 +290,8 @@ export function convertStageToJson(stage: StageInfo): PipelineStage {
out.environment = removeExtraMarkers(stage.environment);
}

restoreUnknownSections(stage, out);

if (stage.children && stage.children.length > 0) {
// parallel
out.branches = [];
Expand All @@ -301,8 +303,6 @@ export function convertStageToJson(stage: StageInfo): PipelineStage {
steps: convertStepsToJson(child.steps),
};

restoreUnknownSections(child, outStage);

out.branches.push(outStage);
}
} else {
Expand All @@ -313,8 +313,6 @@ export function convertStageToJson(stage: StageInfo): PipelineStage {
};

out.branches = [ outBranch ];

restoreUnknownSections(stage, outBranch);
}

return out;
Expand Down
34 changes: 5 additions & 29 deletions src/main/less/editor.less
Expand Up @@ -21,13 +21,12 @@
.pipeline-editor {
display:flex;
flex-direction: column;
width:100%;
height:100%;


min-width: 640px; // avoid flow issues when resizing dialogs very small
position: fixed;
top: 0;
top: 48px;
right: 0;
bottom: 0;
left: 0;
background-color: #fff;
border-radius: 2px;
Expand Down Expand Up @@ -172,31 +171,8 @@

//--[ "Dialog" page styles ]--------------------------------------------------------------------------------------------

.editor-page-header {
flex-grow: 1;
width:100%;
background: @brand-color;
color: white;
min-height: 80px;
display:flex;
align-items: center;
}

.editor-page-header h3 {
margin:1em;
position:relative;
font-size:20px;
top:-3px;
flex-grow:1;
}

.editor-page-header-controls {
flex-grow: 0;
margin: 1em;
}

.editor-page-header-controls button {
margin:0.5em;
.editor-page-header-controls button + button {
margin-left: 10px;
}

//--[ Pipeline Graph ]--------------------------------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions src/test/js/services/PipelineSyntaxConverter-spec.js
Expand Up @@ -233,10 +233,10 @@ describe('Pipeline Syntax Converter', () => {
"value": "someBatScript"
}
}],
"stageUnknownSection": {
"someStageKey": "someStageValue",
}
}]
}],
"stageUnknownSection": {
"someStageKey": "someStageValue",
}
}],
"someUnkownSection": {
"someKey": "someValue",
Expand All @@ -252,7 +252,6 @@ describe('Pipeline Syntax Converter', () => {
assert(out.pipeline.someUnkownSection, "Unknown section not restored");
assert(out.pipeline.
stages[0].
branches[0].
stageUnknownSection, "Stage unknown section not restored");
});

Expand Down

0 comments on commit c7290fa

Please sign in to comment.