-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/jenkins 38595 create pipeline scm list (#572)
* [JENKINS-38594] wire up new "create-pipeline" route; stub out directory for new "Creation" submodule * [JENKINS-38594] update CreatePipeline to use a placeholder dialog until component is ready; integrate with existing router / background code so the existing screen's DOM will display under the dialog * [JENKINS-38594] refine logic for handling background for enter/leave of create-pipeline * [JENKINS-38595] enhance ExtensionRenderer so that extensions can be force reloaded / re-rendered * [JENKINS-38595] tick up js-ext deps * [JENKINS-38595] visual components for multi-step flows * [JENKINS-38595] ExtensionPoint APIs for contributing to SCM provider list and workflow steps in Create Pipeline * [JENKINS-38594] delint * [JENKINS-38594] code refactoring to improve comprehensibility * [JENKINS-38595] visual refinements to step indicators * [JENKINS-38595] quick and dirty version of Git creation flow to test out new MultiStepFlow / FlowStep APIs * [JENKINS-38594] add some security util methods; add some defense against NPE in config * [JENKINS-38594] only show the "New Pipeline" link if the user has permission * [JENKINS-38595] simplify down the extension point API to use a single XP; lay the groundwork for "re-entrant" flow; still needs to sandbox rendered content * [JENKINS-38595] extract the "sandboxing" of rendering (via ReactDOM.render) so that we can have more flexibility with how we render untrusted React code * [JENKINS-38595] add proper error handling and sandboxed rendering to the extension points in Create Pipeline flow * [JENKINS-38595] fix a bug where the "activeStep" was falling out of sync w/ props.children and yielding incorrect statuses for steps; now we just track the current step index which is much simpler anyways * [JENKINS-38595] add support for "percent complete" for steps * [JENKINS-38595] add a "GitCreationManager" to centralize logic that needs sharing between the two steps; enhance "CompletedStep" to display its progress via percent complete * [JENKINS-38595] delint * [JENKINS-38595] fix failing test * [JENKINS-38595] comments and renaming * [JENKINS-38595] add support for className on SandboxedComponent; eliminate duplicate ContextBridge; update deps after beta publish * [JENKINS-38595] CSS tweak * [JENKINS-38595] more comments * [JENKINS-38595] rename for clarity * [JENKINS-38594] add a "blueCreate" query string switch to turn on new UI conditionally; by defaul the Jenkins classic UI will be used * [JENKINS-38594] fix accidental disabling of hibernate page refresh * [JENKINS-38595] republish merged js-extensions to fix missing "SandboxedComponent" error * [JENKINS-38595] remove the temp dialog and use a full-screen Dialog instead
- Loading branch information
1 parent
e8b7e06
commit 1a576d3
Showing
40 changed files
with
2,870 additions
and
91 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
blueocean-dashboard/src/main/js/creation/CreatePipelineScmListRenderer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Created by cmeyers on 10/17/16. | ||
*/ | ||
import React, { PropTypes } from 'react'; | ||
import Extensions from '@jenkins-cd/js-extensions'; | ||
|
||
const Sandbox = Extensions.SandboxedComponent; | ||
|
||
/** | ||
* Displays the initial set of options to begin a creation flow from a SCM Provider. | ||
*/ | ||
export class CreatePipelineScmListRenderer extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
providers: [], | ||
}; | ||
} | ||
|
||
componentWillMount() { | ||
this._initialize(); | ||
} | ||
|
||
_initialize() { | ||
// load and store the SCM providers that contributed the specified extension point | ||
Extensions.store.getExtensions(this.props.extensionPoint, (extensions) => { | ||
let providers = extensions.map(Provider => { | ||
try { | ||
return new Provider(); | ||
} catch (error) { | ||
console.warn('error initializing ScmProvider', Provider, error); | ||
return null; | ||
} | ||
}); | ||
|
||
providers = providers.filter(provider => !!provider); | ||
|
||
this.setState({ | ||
providers, | ||
}); | ||
}); | ||
} | ||
|
||
_onSelection(provider) { | ||
if (this.props.onSelection) { | ||
this.props.onSelection(provider); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="scm-provider-list"> | ||
{ this.state.providers.map(provider => { | ||
let defaultOption; | ||
|
||
try { | ||
defaultOption = provider.getDefaultOption(); | ||
} catch (error) { | ||
console.warn('error invoking getDefaultOption for Provider', provider, error); | ||
return Extensions.ErrorUtils.errorToElement(error); | ||
} | ||
|
||
const props = { | ||
onSelect: () => this._onSelection(provider), | ||
}; | ||
|
||
return ( | ||
<Sandbox className="provider-button"> | ||
{React.cloneElement(defaultOption, props)} | ||
</Sandbox> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
CreatePipelineScmListRenderer.propTypes = { | ||
extensionPoint: PropTypes.string, | ||
onSelection: PropTypes.func, | ||
}; |
52 changes: 52 additions & 0 deletions
52
blueocean-dashboard/src/main/js/creation/CreatePipelineStepsRenderer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Created by cmeyers on 10/17/16. | ||
*/ | ||
import React, { PropTypes } from 'react'; | ||
import Extensions from '@jenkins-cd/js-extensions'; | ||
import VerticalStep from './VerticalStep'; | ||
|
||
const Sandbox = Extensions.SandboxedComponent; | ||
|
||
/** | ||
* Displays the current steps based on the selection in the SCM provider list. | ||
*/ | ||
export class CreatePipelineStepsRenderer extends React.Component { | ||
|
||
shouldComponentUpdate(nextProps) { | ||
return this.props.selectedProvider !== nextProps.selectedProvider; | ||
} | ||
|
||
render() { | ||
if (!this.props.selectedProvider) { | ||
return ( | ||
<VerticalStep className="last-step"> | ||
<h1>Completed</h1> | ||
</VerticalStep> | ||
); | ||
} | ||
|
||
const props = { | ||
onCompleteFlow: this.props.onCompleteFlow, | ||
}; | ||
|
||
let creationFlow; | ||
|
||
try { | ||
creationFlow = this.props.selectedProvider.getCreationFlow(); | ||
} catch (error) { | ||
console.warn('Error rendering:', this.props.selectedProvider, error); | ||
return Extensions.ErrorUtils.errorToElement(error); | ||
} | ||
|
||
return ( | ||
<Sandbox> | ||
{React.cloneElement(creationFlow, props)} | ||
</Sandbox> | ||
); | ||
} | ||
} | ||
|
||
CreatePipelineStepsRenderer.propTypes = { | ||
selectedProvider: PropTypes.object, | ||
onCompleteFlow: PropTypes.func, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Created by cmeyers on 10/19/16. | ||
*/ | ||
import React, { PropTypes } from 'react'; | ||
import VerticalStep from './VerticalStep'; | ||
import status from './FlowStepStatus'; | ||
|
||
/** | ||
* Visual/logic component that defines an individual step of a multi-step workflow. | ||
* Intended to be used within a MultiStepFlow component. | ||
* Hides all content except for the title until the step becomes active. | ||
* Complete the step by calling 'props.onCompleteStep'; complete entire flow by calling 'props.onCompleteFlow' | ||
*/ | ||
export default function FlowStep(props) { | ||
return ( | ||
<VerticalStep | ||
status={props.status} | ||
percentage={props.percentage} | ||
isLastStep={props.isLastStep} | ||
> | ||
<h1>{props.title}</h1> | ||
{ | ||
props.status !== status.INCOMPLETE && | ||
props.children | ||
} | ||
</VerticalStep> | ||
); | ||
} | ||
|
||
FlowStep.propTypes = { | ||
children: PropTypes.node, | ||
title: PropTypes.string, | ||
status: PropTypes.string, | ||
percentage: PropTypes.number, | ||
isLastStep: PropTypes.bool, | ||
onCompleteStep: PropTypes.func, | ||
onCompleteFlow: PropTypes.func, | ||
}; |
16 changes: 16 additions & 0 deletions
16
blueocean-dashboard/src/main/js/creation/FlowStepStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Created by cmeyers on 10/19/16. | ||
*/ | ||
|
||
/** | ||
* Valid statuses for a FlowStep. | ||
*/ | ||
const status = { | ||
ACTIVE: 'active', | ||
COMPLETE: 'complete', | ||
INCOMPLETE: 'incomplete', | ||
|
||
values: () => [status.ACTIVE, status.COMPLETE, status.INCOMPLETE], | ||
}; | ||
|
||
export default status; |
Oops, something went wrong.