Skip to content

Commit

Permalink
fix: Fix some issues in the DevOps
Browse files Browse the repository at this point in the history
Signed-off-by: harrisonliu5 harrisonliu_5@163.com
  • Loading branch information
harrisonliu5 committed Jul 24, 2020
1 parent 1b2dd21 commit e78a428
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 135 deletions.
3 changes: 3 additions & 0 deletions src/components/Forms/CICDs/RepoSelect/GithubForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export default class GitHubForm extends React.Component {
handlePasswordConfirm = async () => {
const { name, cluster, project_id } = this.props
const data = this.tokenFormRef.current.getData()

if (isEmpty(data)) return false

this.setState({ isLoading: true })
this.props.store
.putAccessToken({ token: data.token, name, cluster, project_id })
Expand Down
1 change: 1 addition & 0 deletions src/components/Forms/CICDs/RepoSelect/subForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class RepoSelectForm extends React.Component {

@observable
source_type = 'github'

@observable
showCredential = false

Expand Down
45 changes: 21 additions & 24 deletions src/components/Forms/CICDs/paramsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export default class ParamsModal extends React.Component {
}

init = async () => {
const parameters = await this.getParametersFromBranch(this.branch)
const parameters = this.branch
? await this.getParametersFromBranch(this.branch)
: this.props.parameters
this.setState({
currentBranch: this.branch,
parameters,
Expand All @@ -114,19 +116,26 @@ export default class ParamsModal extends React.Component {
}

handleOk = () => {
const { branch, ...parameters } = this.formRef.current.getData()
const { branch, ...formParameters } = this.formRef.current.getData()
const { parameters } = this.state
this.formRef.current.validate(() => {
const params = Object.keys(parameters).map(key => ({
name: key,
value: parameters[key],
}))
const params = isEmpty(formParameters)
? parameters.map(item => ({
name: item.name,
value: '',
}))
: Object.keys(formParameters).map(key => ({
name: key,
value: parameters[key],
}))

this.props.onOk(params, branch)
})
}

renderParamsItem(param) {
const type = param.type.toLowerCase().split('parameterdefinition')[0]

const defaultValue = get(param, 'defaultParameterValue.value')
switch (type) {
case 'string':
return (
Expand All @@ -135,10 +144,7 @@ export default class ParamsModal extends React.Component {
label={param.name}
desc={param.description}
>
<Input
defaultValue={param.defaultParameterValue.value}
name={param.name}
/>
<Input defaultValue={defaultValue} name={param.name} />
</Form.Item>
)
case 'text':
Expand All @@ -148,10 +154,7 @@ export default class ParamsModal extends React.Component {
label={param.name}
desc={param.description}
>
<TextArea
defaultValue={param.defaultParameterValue.value}
name={param.name}
/>
<TextArea defaultValue={defaultValue} name={param.name} />
</Form.Item>
)
case 'boolean':
Expand All @@ -161,10 +164,7 @@ export default class ParamsModal extends React.Component {
label={param.name}
desc={param.description}
>
<RadioGroup
name={param.name}
defaultValue={String(param.defaultParameterValue.value)}
>
<RadioGroup name={param.name} defaultValue={String(defaultValue)}>
<Radio name={param.name} value={'true'}>
True
</Radio>
Expand Down Expand Up @@ -199,7 +199,7 @@ export default class ParamsModal extends React.Component {
desc={param.description}
>
<Input
defaultValue={param.defaultParameterValue.value}
defaultValue={defaultValue}
type="password"
name={param.name}
/>
Expand All @@ -212,10 +212,7 @@ export default class ParamsModal extends React.Component {
label={param.name}
desc={param.description}
>
<Input
defaultValue={param.defaultParameterValue.value}
name={param.name}
/>
<Input defaultValue={defaultValue} name={param.name} />
</Form.Item>
)
}
Expand Down
133 changes: 67 additions & 66 deletions src/locales/en/cicd.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,110 +326,110 @@ export default {
'You can execute shell commands or windows batch commands in the build.':
'You can execute shell commands or windows batch commands in the build.',

'CI/CD_CREATE_DESC': `Pipeline is a collection of plugins that can be combined
to achieve continuous integration and continuous delivery.
Pipeline DSL provides us with an extensible set of tools that allow
'CI/CD_CREATE_DESC': `Pipeline is a collection of plugins that can be combined
to achieve continuous integration and continuous delivery.
Pipeline DSL provides us with an extensible set of tools that allow
us to implement simple to complex logic through code.`,
username_password: 'Account Credentials',
login_Plateform: 'Login platform',
CREDENTIALS_DESC: `Credential is an object that contains some sensitive data,
CREDENTIALS_DESC: `Credential is an object that contains some sensitive data,
such as username and password, SSH key and Token.
It is used to provide authentication for the process of pulling code,
It is used to provide authentication for the process of pulling code,
pushing/pulling images, executing SSH scripts, etc. when a pipeline is running.`,
tips_Parametric_build: `The parameterized build process allows
you to pass in one or more parameters when you build.
For example: You may have a pipeline for publishing software and you
want to upload the release notes together.
This can be done by adding text parameters here.
Each parameter has a Name and a Value,
and the value of Value depends on the parameter type.
These values can be accessed in the Pipeline using params.Name or Name.
tips_Parametric_build: `The parameterized build process allows
you to pass in one or more parameters when you build.
For example: You may have a pipeline for publishing software and you
want to upload the release notes together.
This can be done by adding text parameters here.
Each parameter has a Name and a Value,
and the value of Value depends on the parameter type.
These values can be accessed in the Pipeline using params.Name or Name.
This means that each parameter defined here should have a unique name.
When parameterizing a project, the build is replaced with a parameterized build,
which prompts the user to enter a value for each defined parameter.
If they choose not to enter anything,
the build proceeds with the default value for each parameter.
If the project's build is started automatically, for example, by a timed trigger,
When parameterizing a project, the build is replaced with a parameterized build,
which prompts the user to enter a value for each defined parameter.
If they choose not to enter anything,
the build proceeds with the default value for each parameter.
If the project's build is started automatically, for example, by a timed trigger,
it will be triggered with the default value of the parameter. `,
tips_Authentication_token: `Enable this option if you need to
trigger a build by accessing a predefined URL.
A typical use of this feature is to trigger through the source code
management system's hook script.
You need to provide an authorization token in the form of a string so that
tips_Authentication_token: `Enable this option if you need to
trigger a build by accessing a predefined URL.
A typical use of this feature is to trigger through the source code
management system's hook script.
You need to provide an authorization token in the form of a string so that
only the person with the authorization token can trigger the remote build.`,
tips_disable_concurrent: `This will determine when the
project's build record should be discarded.
Build records include console output, archive artifacts,
and other metadata related to a particular build.
Keeping less builds saves disk space used by Jenkins.
We provide two conditions to determine when the old build should be discarded:
1. Number of days to keep the build:
The build will be discarded after a certain number of days.
2. Number of builds to be kept:
If there are already a certain number of builds, discard the oldest build.
These two conditions apply to the build at the same time,
tips_disable_concurrent: `This will determine when the
project's build record should be discarded.
Build records include console output, archive artifacts,
and other metadata related to a particular build.
Keeping less builds saves disk space used by Jenkins.
We provide two conditions to determine when the old build should be discarded:
1. Number of days to keep the build:
The build will be discarded after a certain number of days.
2. Number of builds to be kept:
If there are already a certain number of builds, discard the oldest build.
These two conditions apply to the build at the same time,
and if either one is met first, the build will be discarded.`,
tips_disable_concurrent_withscm: `This will determine when the branch should be discarded and all build records under the branch.
tips_disable_concurrent_withscm: `This will determine when the branch should be discarded and all build records under the branch.
The build record includes the console output,
Archive artifacts and other metadata related to a particular build.
Archive artifacts and other metadata related to a particular build.
Keeping less builds saves disk space used by Jenkins.
We provide two options to determine when the old branch should be discarded:
1. Number of days to keep the branch: If the branch reaches a certain number of days,
We provide two options to determine when the old branch should be discarded:
1. Number of days to keep the branch: If the branch reaches a certain number of days,
the branch is dropped.
2. Number of reserved branches: If a certain number of branches already exist,
the oldest branch is discarded.
2. Number of reserved branches: If a certain number of branches already exist,
the oldest branch is discarded.
These two options can work on the branch at the same time.
If any of the limits are exceeded,
If any of the limits are exceeded,
any branches that exceed this limit will be dropped.`,
tips_Timing_build:
'Provides cron-like functionality to perform this project regularly',
tips_days_keep_withscm: `If the number of days the branch has been retained will be deleted.
tips_days_keep_withscm: `If the number of days the branch has been retained will be deleted.
(Default -1: will delete the branch that has been deleted)`,
tips_numbers_keep_withscm: `If the number of branches reached the number of reservations will be deleted.
tips_numbers_keep_withscm: `If the number of branches reached the number of reservations will be deleted.
(Default value -1: will delete the branches that have been deleted)`,
tips_timer_trigger: `This field follows the cron syntax (slightly different).
Specifically, each line contains 5 fields separated by tabs or spaces.
tips_timer_trigger: `This field follows the cron syntax (slightly different).
Specifically, each line contains 5 fields separated by tabs or spaces.
minutes: the first few minutes of an hour (0-59)
hours: the first few hours of the day (0-23)
the days of the month: the first few days of a month (1-31 )
Month: The first few days of the first few days (0-12), the first few days of the week (0-12),
hours: the first few hours of the day (0-23)
the days of the month: the first few days of a month (1-31 )
Month: The first few days of the first few days (0-12), the first few days of the week (0-12),
0 and 7 are Sundays. `,

CICDS_BASEINFO_DESC: 'Please enter the basic information of the pipeline.',
CICD_ADVANCE_SETTINGS_DESC:
'Configure a complex behavior policy for the pipeline (Optional).',
CREDENTIALS_CREATE_DESC: 'Create credentials for DevOps projects',
CHECKOUT_DESC: 'Pull code; often used to pull non-git code, such as svn.',
PRIVATE_IMAGE_DESC: `To deploy from a private image repository,
PRIVATE_IMAGE_DESC: `To deploy from a private image repository,
you need to create a mirrored repository and then pull the image. `,
AGENT_TYPE_DESC: `The agent section specifies
where the entire Pipeline or a particular stage will be executed in the Jenkins environment,
depending on where the agent part is placed.
This part must be defined at the top level within the pipeline block,
AGENT_TYPE_DESC: `The agent section specifies
where the entire Pipeline or a particular stage will be executed in the Jenkins environment,
depending on where the agent part is placed.
This part must be defined at the top level within the pipeline block,
but the stage level usage is optional. `,
AUTHENTICATION_TOKEN_DESC: `Use the following URL to remotely trigger the build:
JENKINS_URL / job / JOB_NAME / build? Token =TOKEN_NAME or /buildWithParameters?
Token = TOKEN_NAME You can choose to append &cause=reason to provide the text that
AUTHENTICATION_TOKEN_DESC: `Use the following URL to remotely trigger the build:
JENKINS_URL / job / JOB_NAME / build? Token =TOKEN_NAME or /buildWithParameters?
Token = TOKEN_NAME You can choose to append &cause=reason to provide the text that
will be included in the build reason for the record. `,
ACTIVITY_EMPTY_TIP: 'The current pipeline is not running yet',

PIPELINE_NO_CONFIG:
'The relevant configuration file was not found in the current pipeline',
NOT_VALID_JENKINS_FILE: `The current Jenkinsfile is not a standard declarative Jenkinsfile
NOT_VALID_JENKINS_FILE: `The current Jenkinsfile is not a standard declarative Jenkinsfile
and cannot be graphically displayed`,
PIPELINE_CRONJOB_CRON_DESC: `Every hour, on the hour syntax reference
PIPELINE_CRONJOB_CRON_DESC: `Every hour, on the hour syntax reference
<a href="//jenkins.io/doc/book/pipeline/syntax/#cron-syntax" target="_blank">CRON</a>`,
WEBHOOK_DESC:
'Push a message to this URL to trigger a reindexing of the repository. ',
TIME_TRIGGER_DESC: `Some types of items will automatically re-index
when they receive an external push message.
However, in some cases, message notifications may fail.
This option will check if the index has been executed within the specified time interval,
TIME_TRIGGER_DESC: `Some types of items will automatically re-index
when they receive an external push message.
However, in some cases, message notifications may fail.
This option will check if the index has been executed within the specified time interval,
and if not, trigger the index. `,

KUBERNETES_DEPLOY_DESC: `Deploy resources on a Kubernetes cluster.
In a continuous integration or continuous deployment environment,
only those resources that need to be updated regularly should be placed in the deployment step.
KUBERNETES_DEPLOY_DESC: `Deploy resources on a Kubernetes cluster.
In a continuous integration or continuous deployment environment,
only those resources that need to be updated regularly should be placed in the deployment step.
Therefore, this step is mostly used to process the deployment of such resources.`,
KUBERNETES_DEPLOY_DESC_MORE: `<br />
<label>This step has the following main features:</label>
Expand Down Expand Up @@ -522,7 +522,7 @@ export default {
href="https://github.com/settings/tokens/new?scopes=repo,read:user,user:email,write:repo_hook"
target="_blank"
>
Get Token
Get Token
</a>`,

bitbucket_server_ACCESSTOKEN_PLACEHOLDER:
Expand All @@ -536,4 +536,5 @@ export default {
WHEN_CHRETE_PIEPLINE_DESC:
'When a new pipeline is created, the tasks in the specified pipeline are automatically triggered.',
'Started By {name}': 'Started By {name}',
'Credential ID exists': 'Credential ID exists',
}
1 change: 1 addition & 0 deletions src/locales/tc/cicd.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,5 @@ export default {
'select a pipeline': '選擇一個流水線',
timer: '定時器',
'Started By {name}': '由{name}觸發掃描',
'Credential ID exists': '憑證 ID 已存在',
}
1 change: 1 addition & 0 deletions src/locales/zh/cicd.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,5 @@ export default {
'select a pipeline': '选择一个流水线',
timer: '定时器',
'Started By {name}': '由{name}触发扫描',
'Credential ID exists': '凭证 ID 已存在',
}
2 changes: 1 addition & 1 deletion src/pages/devops/components/PipelineStatus/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class PipelineCard extends React.Component {
loading={this.state.runLoading}
onClick={this.handleProceed(hasInputStep, node.id)}
>
{get(hasInputStep, 'input.ok') || t('Proceed')}
{t(get(hasInputStep, 'input.ok') || 'Proceed')}
</Button>
<Button
size="small"
Expand Down
Loading

0 comments on commit e78a428

Please sign in to comment.