-
Notifications
You must be signed in to change notification settings - Fork 526
/
GithubCredentialStep.jsx
65 lines (53 loc) · 1.89 KB
/
GithubCredentialStep.jsx
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
import React, { PropTypes } from 'react';
import Extensions from '@jenkins-cd/js-extensions';
import { i18nTranslator } from '@jenkins-cd/blueocean-core-js';
import FlowStep from '../../flow2/FlowStep';
const t = i18nTranslator('blueocean-dashboard');
export default class GithubCredentialsStep extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false,
complete: false,
};
}
_onStatus(status) {
const loading = status === 'promptLoading';
this.setState({
loading,
});
}
_onComplete(credential, selectionType) {
this.setState({
complete: true,
});
if (this.props.onCredentialSelected) {
this.props.onCredentialSelected(credential, selectionType);
}
}
render() {
const scmId = this.props.flowManager.getScmId();
const loading = this.state.loading;
const disabled = this.state.complete;
const title = loading ? t('common.pager.loading', { defaultValue: 'Loading...' }) : 'Connect to GitHub';
const githubConfig = {
scmId,
apiUrl: this.props.flowManager.getApiUrl(),
};
return (
<FlowStep {...this.props} className="github-credentials-step" disabled={disabled} loading={loading} title={title}>
<Extensions.Renderer
extensionPoint="jenkins.credentials.selection"
onStatus={status => this._onStatus(status)}
onComplete={(credential, selectionType) => this._onComplete(credential, selectionType)}
type={scmId}
githubConfig={githubConfig}
/>
</FlowStep>
);
}
}
GithubCredentialsStep.propTypes = {
flowManager: PropTypes.object,
onCredentialSelected: PropTypes.func,
};