Skip to content

Commit

Permalink
fix: fix filter out scaner error
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh1028 committed Feb 21, 2020
1 parent 30db7d9 commit 32e89c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/locales/en/cicd.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,5 @@ export default {
'When a pipeline is deleted, the tasks in the specified pipeline are automatically triggered.',
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}',
}
2 changes: 2 additions & 0 deletions src/locales/zh/cicd.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,6 @@ export default {
WHEN_CHRETE_PIEPLINE_DESC:
'当有创建新的流水线时,将自动触发指定流水线中的任务。',
'select a pipeline': '选择一个流水线',
timer: '定时器',
'Started By {name}': '由{name}触发扫描',
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Icon } from '@pitrix/lego-ui'
import { observer } from 'mobx-react'
import { get } from 'lodash'
import { Modal, Button, Notify } from 'components/Base'

import styles from './scanModal.scss'
Expand Down Expand Up @@ -53,9 +54,17 @@ export default class ScanReponsitoryLogs extends React.Component {
get startBy() {
const { reponsitorylog } = this.props.store
const arr = reponsitorylog.split('\n')
if (arr[0] && arr[0].startsWith('Started by user ')) {
return arr[0].slice(15)
const firstLine = get(arr, '[0]', '')
const parser = firstLine.match(/^Started by (user )?(.*)?/) || []
const isUser = parser[1]
const name = parser[2]
if (firstLine && isUser) {
return `${t('Started By')}: ${name}`
}
if (firstLine && !isUser) {
return t('Started By {name}', { name: t(name) })
}
return `${t('Started By')}: -`
}

handleFetch = async () => {
Expand Down Expand Up @@ -88,7 +97,7 @@ export default class ScanReponsitoryLogs extends React.Component {
<div className={styles.content}>
<div className={styles.btn_group}>
<Icon name="human" size={20} />
{`${t('Started By')}: ${this.startBy}`}
{this.startBy}
<Button onClick={this.handleDownloadLogs}>
{t('Download Logs')}
</Button>
Expand Down

0 comments on commit 32e89c9

Please sign in to comment.