Skip to content

Commit

Permalink
fix: Fix the error that the editor and replay the pipeline
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 30, 2020
1 parent 3f86d7e commit 3e8e4ed
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
27 changes: 15 additions & 12 deletions src/pages/devops/components/Pipeline/StepModals/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Form, Modal } from 'components/Base'
import { Mention, Alert } from '@pitrix/lego-ui'
import MentionsInput from '@pitrix/lego-ui/lib/components/Mention/MentionsInput'

import DevopsStore from 'stores/devops'
import UserStore from 'stores/user'

import styles from './index.scss'

Expand All @@ -43,7 +43,7 @@ export default class InputStep extends React.Component {

constructor(props) {
super(props)
this.devopsStore = new DevopsStore()
this.memberStore = new UserStore()
const { value, submitter } = this.getDefaultData()
this.state = { loading: false, value, submitter }
}
Expand All @@ -61,13 +61,14 @@ export default class InputStep extends React.Component {
const { edittingData } = this.props
let value = ''
let submitter = []
const editData = toJS(edittingData)

if (
!isEmpty(edittingData) &&
!isEmpty(edittingData.data) &&
isArray(edittingData.data)
!isEmpty(editData) &&
!isEmpty(editData.data) &&
isArray(editData.data)
) {
edittingData.data.forEach(param => {
editData.data.forEach(param => {
if (param.key === 'message') {
value = param.value.value
}
Expand All @@ -91,17 +92,19 @@ export default class InputStep extends React.Component {
}

getUsers = () => {
const { devops, cluster } = this.props
this.setState({ loading: true })
this.devopsStore
.fetchMembers({ devops: this.props.devops })
this.memberStore
.fetchList({
devops,
cluster,
})
.then(result => {
this.setState({ loading: false })

if (!result.items) {
if (isEmpty(result)) {
return []
}

return result.items
return result
.map(user => ({
id: user.username,
display: user.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export default class StepsEditor extends React.Component {
/>
<InputStep
devops={devops}
cluster={cluster}
visible={this.state.isShowinput}
edittingData={edittingData}
onAddStep={this.handleAddStep('input')}
Expand Down
15 changes: 13 additions & 2 deletions src/pages/devops/components/Pipeline/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
*/

import { action, observable, computed, toJS } from 'mobx'
import { get, set, unset } from 'lodash'
import { get, set, unset, isObject, isEmpty } from 'lodash'
import { Message } from '@pitrix/lego-ui'
import Notify from 'components/Base/Notify'

import CredentialStore from 'stores/devops/credential'
import BaseStore from 'stores/devops/base'
Expand All @@ -44,6 +45,11 @@ const formatPipeLineJson = json => {
delete stage.isActive
return stage
})

if (isObject(json.parameters) && isEmpty(json.parameters)) {
delete json.parameters
}

return json
}

Expand Down Expand Up @@ -277,8 +283,13 @@ export default class Store extends BaseStore {
const loacationArr = error.location.join('.').split('.branches')
// can't find location
const errorObj = get(this.jsonData.json, loacationArr[0])
if (errorObj && errorObj.length !== undefined) {
if (errorObj && !isEmpty(errorObj)) {
Message.error({ content: error.error })
Notify.error({
title: t('pipeline syntax error'),
content: t(error.error),
duration: 6000,
})
return
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/devops/components/PipelineStatus/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Pipeline extends React.Component {

@observable
parameters = []

@observable
showParamsModal = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ class RunSider extends Base {
@action
rePlay = async () => {
const { params } = this.props.match

const result = await this.store.replay(params)
if (params.branch) {
this.routing.push(
`/${params.workspace}/clusters/${params.cluster}/devops/${
params.devops
}/pipelines/${params.name}${
params.branch ? `/branch/${params.branch}` : ''
}/activity`
)
}
this.routing.push(
`/${params.workspace}/clusters/${params.cluster}/devops/${
params.devops
}/pipelines/${params.name}${
params.branch ? `/branch/${params.branch}` : ''
}/activity`
)

if (result.id) {
this.store.runDetail = result
}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/devops/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class PipelineStore extends BaseStore {
if (jenkinsfile) {
const result = await this.request.post(
`${this.getBaseUrlV2({ cluster })}tojson`,
{ jenkinsfile: toJS(this.jenkinsfile) },
{ jenkinsfile },
FORM_HEAR
)
return result.data
Expand Down

0 comments on commit 3e8e4ed

Please sign in to comment.