Skip to content

Commit

Permalink
[FIX JENKINS-39372] enable bidirectional import/export for Pipeline M…
Browse files Browse the repository at this point in the history
…odel Definition (#11)

JENKINS-39372 - enable bidirectional import/export for Pipeline Model Definition
  • Loading branch information
kzantow committed Dec 22, 2016
1 parent 0745432 commit 9764be0
Show file tree
Hide file tree
Showing 25 changed files with 2,928 additions and 602 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ work/
/.classpath
/.project
/.settings/
npm-debug.log
46 changes: 46 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,46 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Tests",
"type": "node",
"request": "launch",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "test"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false,
"outFiles": [],
"timeout": 100000
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outFiles": [],
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": false,
"outFiles": []
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,4 @@
// Place your settings in this file to overwrite default and user settings.
{
"javascript.validate.enable": false
}
Expand Up @@ -22,6 +22,7 @@
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
import org.kohsuke.stapler.NoStaplerConstructorException;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.verb.GET;

import hudson.Extension;
Expand Down Expand Up @@ -49,6 +50,11 @@ public String getUrlName() {
return "pipeline-metadata";
}

@GET
public String doCrumbInfo() {
return Jenkins.getInstance().getCrumbIssuer().getCrumbRequestField() + "=" + Jenkins.getInstance().getCrumbIssuer().getCrumb();
}

/**
* Function to return all {@link DeclarativeAgent}s present in the system when accessed through the REST API
*/
Expand Down
56 changes: 6 additions & 50 deletions src/main/js/components/EditorDemo.jsx
Expand Up @@ -3,70 +3,26 @@
import React, { Component, PropTypes } from 'react';
import { EditorPage } from './editor/EditorPage';
import { EditorMain } from './editor/EditorMain';

import type {StepInfo, StageInfo} from './editor/common';
import Extensions from '@jenkins-cd/js-extensions';

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

/// Simple helpers for data generation

var __id = 1;

function makeStage(name, children = []):StageInfo {
const id = __id++;
return {name, children, id};
}

function makeStep(type:string, label:string, nestedSteps?:Array<StepInfo>):StepInfo {
const id = __id++;
const children = nestedSteps || [];
const isContainer = !!children.length;
const data = {}; // TODO: Put stuff here at some point
return {
id,
type,
label,
isContainer,
children,
data
};
}

/**
This is basically adapted from the Storybooks entry, for the purposes of connecting a demo into the main appendEvent
*/
export class EditorDemo extends Component {
constructor() {
super();
}
render() {

let bt = [
makeStage("Firefox"),
makeStage("Safari"),
makeStage("Chrome"),
makeStage("Internet Explorer"),
];

let stages = [
makeStage("Build"),
makeStage("Browser Tests", bt),
makeStage("Static Analysis"),
makeStage("Package"),
];

let stageSteps = {};

stageSteps[stages[0].id] = [makeStep("sh", "Run Script")];
stageSteps[bt[3].id] = [
makeStep("sh", "Run Script"),
makeStep("sh", "Run Script")
];

return (
<EditorPage style={pageStyles}>
<EditorMain stages={stages} stageSteps={stageSteps}/>
<Extensions.Renderer extensionPoint="pipeline.editor.css"/>
<EditorMain />
</EditorPage>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/js/components/editor/AddStepSelectionDialog.jsx
Expand Up @@ -89,7 +89,7 @@ export class AddStepSelectionDialog extends Component<DefaultProps, Props, State
</div>
<div className="editor-step-selection-dialog-steps">
{steps && steps.filter(isStepValidForSelectionUI).filter(this.state.searchFilter).map(step =>
<div tabIndex="0" onKeyPress={e => this.selectItemByKeyPress(e, step)} onClick={() => this.setState({selectedStep: step})} className={'step-item' + (this.state.selectedStep === step ? ' selected' : '')}>
<div tabIndex="0" onKeyPress={e => this.selectItemByKeyPress(e, step)} onClick={() => this.setState({selectedStep: step})} onDoubleClick={() => this.selectAddStep()} className={'step-item' + (this.state.selectedStep === step ? ' selected' : '')}>
{step.displayName}
</div>
)}
Expand Down

0 comments on commit 9764be0

Please sign in to comment.