-
Notifications
You must be signed in to change notification settings - Fork 526
/
CreatePipeline.js
132 lines (112 loc) · 4.96 KB
/
CreatePipeline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import React, { PropTypes } from 'react';
import { Page } from '@jenkins-cd/design-language';
import { ContentPageHeader, i18nTranslator, loadingIndicator } from '@jenkins-cd/blueocean-core-js';
import Extensions from '@jenkins-cd/js-extensions';
import { ClassicCreationLink } from './ClassicCreationLink';
import { CreatePipelineScmListRenderer } from './CreatePipelineScmListRenderer';
import { CreatePipelineStepsRenderer } from './CreatePipelineStepsRenderer';
import VerticalStep from './flow2/VerticalStep';
import StepStatus from './flow2/FlowStepStatus';
import creationUtils from './creation-status-utils';
const Sandbox = Extensions.SandboxedComponent;
const t = i18nTranslator('blueocean-dashboard');
export default class CreatePipeline extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedProvider: null,
};
}
componentWillMount() {
loadingIndicator.hide();
}
componentWillUnmount() {
if (this.state.selectedProvider) {
this.state.selectedProvider.destroyFlowManager();
}
}
_onSelection(selectedProvider) {
if (this.state.selectedProvider) {
this.state.selectedProvider.destroyFlowManager();
}
this.setState({
selectedProvider,
});
}
_onCompleteFlow(path) {
this._onExit(path);
}
_onNavigatePipelines() {
this._onExit({ url: '/pipelines' });
}
_onExit({ url } = {}) {
if (url) {
this.context.router.replace(url);
} else if (history && history.length <= 2) {
this.context.router.replace('/pipelines');
} else {
this.context.router.goBack();
}
}
render() {
const firstStepStatus = this.state.selectedProvider ? StepStatus.COMPLETE : StepStatus.ACTIVE;
return (
<Page>
<div className="create-pipeline">
<ContentPageHeader>
<h1>{t('creation.core.header.title')}</h1>
<ClassicCreationLink />
</ContentPageHeader>
{creationUtils.isEnabled() && (
<main>
<article className="content-area">
<VerticalStep className="first-step" status={firstStepStatus}>
<h1>{t('creation.core.intro.scm_provider')}</h1>
<CreatePipelineScmListRenderer
extensionPoint="jenkins.pipeline.create.scm.provider"
onSelection={provider => this._onSelection(provider)}
selectedProvider={this.state.selectedProvider}
/>
</VerticalStep>
<Sandbox>
<CreatePipelineStepsRenderer
selectedProvider={this.state.selectedProvider}
onCompleteFlow={data => this._onCompleteFlow(data)}
/>
</Sandbox>
</article>
</main>
)}
{creationUtils.isDisabled() && (
<main>
<article className="content-area">
<VerticalStep className="first-step" status={StepStatus.ERROR}>
<h1>{t('creation.core.intro.invalid_security_title')}</h1>
<p>
<span>{t('creation.core.intro.invalid_security_message')} - </span>
<a href={t('creation.core.intro.invalid_security_linkhref')} target="_blank">
{t('creation.core.intro.invalid_security_linktext')}
</a>
</p>
</VerticalStep>
</article>
</main>
)}
{creationUtils.isHidden() && (
<main>
<article className="content-area">
<VerticalStep className="first-step" status={StepStatus.ERROR}>
<h1>{t('creation.core.intro.invalid_permission_title')}</h1>
<button onClick={() => this._onNavigatePipelines()}>{t('creation.core.intro.invalid_permission_button')}</button>
</VerticalStep>
</article>
</main>
)}
</div>
</Page>
);
}
}
CreatePipeline.contextTypes = {
router: PropTypes.object,
};