Skip to content

Commit

Permalink
fix: Fix the product download link and delete the search in the build…
Browse files Browse the repository at this point in the history
… mirror

Signed-off-by: harrisonliu5 <harrisonliu_5@163.com>
  • Loading branch information
harrisonliu5 committed Jul 22, 2020
1 parent 1d12ab5 commit 94025b4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ export default class ImageSearch extends Component {

getImageDetail = async ({ image, secret, ...rest }) => {
const { namespace, cluster } = this.props
if (!image) {
if (!image || this.isUnMounted) {
return
}

this.image = image

this.setState({ isLoading: true })
Expand All @@ -114,16 +115,11 @@ export default class ImageSearch extends Component {
secret,
})

if (result) {
const selectedImage = { ...result, ...rest, image }
set(globals, `cache[${image}]`, selectedImage)
if (!isEmpty(selectedImage.exposedPorts)) {
this.setState({ showPortsTips: true })
}
}
const selectedImage = { ...result, ...rest, image }
set(globals, `cache[${image}]`, selectedImage)

if (this.isUnMounted) {
return
if (!isEmpty(selectedImage.exposedPorts)) {
this.setState({ showPortsTips: true })
}

this.setState({ isLoading: false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import styles from './index.scss'
export default class BuilderInfo extends React.Component {
pathAddCluster = (path, cluster) => {
const match = path.match(/(\/kapis|api|apis)(.*)/)
return !cluster || cluster === 'default' || isArray(match)
return !cluster || cluster === 'default' || !isArray(match)
? path
: `${match[1]}/cluster/${cluster}${match[2]}`
}
Expand All @@ -39,7 +39,7 @@ export default class BuilderInfo extends React.Component {
const { cluster } = params
const path = get(parseUrl(sourceUrl), 'pathname', `/${sourceUrl}`)
const url = this.pathAddCluster(path, cluster)
const downLoadUrl = `${window.location.protocol}/${
const downLoadUrl = `${window.location.protocol}//${
window.location.host
}/b2i_download${url}`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class ImageBuilderLastRun extends React.Component {

pathAddCluster = (path, cluster) => {
const match = path.match(/(\/kapis|api|apis)(.*)/)
return !cluster || cluster === 'default' || isArray(match)
return !cluster || cluster === 'default' || !isArray(match)
? path
: `${match[1]}/cluster/${cluster}${match[2]}`
}
Expand All @@ -105,7 +105,7 @@ export default class ImageBuilderLastRun extends React.Component {
const { sourceUrl, cluster } = this.props.runDetail
const path = get(parseUrl(sourceUrl), 'pathname', `/${sourceUrl}`)
const url = this.pathAddCluster(path, cluster)
const downLoadUrl = `${window.location.protocol}/${
const downLoadUrl = `${window.location.protocol}//${
window.location.host
}/b2i_download${url}`
window.open(downLoadUrl)
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class ImageBuilderLastRun extends React.Component {
<Button
onClick={this.handleDownload}
type="primary"
disabled={status === 'Failed'}
disabled={status !== 'Successful'}
>
{t('Download Artifact')}
</Button>
Expand Down
27 changes: 1 addition & 26 deletions src/pages/projects/components/Cards/ImageRunRecord/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
Pagination,
Loading,
} from '@pitrix/lego-ui'
import { Search, Button } from 'components/Base'
import RunItem from './Item'

import styles from './index.scss'
Expand Down Expand Up @@ -116,35 +115,12 @@ export default class RunsCard extends React.Component {
})
}

handleRefresh = () => {
const params = this.searchValue ? { name: this.searchValue } : {}

this.fetchData(params).then(() => {
const { onSearch, onRefresh } = this.props
isEmpty(params) ? onRefresh() : onSearch(this.searchValue)
})
}

handlePage = page => {
this.fetchData({ page }).then(() => {
this.props.onPage(page)
})
}

renderHeader = () => (
<div className={styles.header}>
<Search
className={styles.search}
name="search"
placeholder={t('Please input a keyword to filter')}
onSearch={this.handleSearch}
/>
<div className={styles.actions}>
<Button type="flat" icon="refresh" onClick={this.handleRefresh} />
</div>
</div>
)

renderContent() {
const { data, isLoading } = this.store.list

Expand Down Expand Up @@ -198,11 +174,10 @@ export default class RunsCard extends React.Component {
}

render() {
const { className, hideHeader, hideFooter } = this.props
const { className, hideFooter } = this.props

return (
<div className={classnames(className, styles.content)}>
{!hideHeader && this.renderHeader()}
{this.renderContent()}
{!hideFooter && this.renderFooter()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class ImageBuilderDetail extends React.Component {
const sourceUrl = get(spec, 'config.sourceUrl', '')
const path = get(parseUrl(sourceUrl), 'pathname', `/${sourceUrl}`)
const url = this.pathAddCluster(path, cluster)
const downLoadUrl = `${window.location.protocol}/${
const downLoadUrl = `${window.location.protocol}//${
window.location.host
}/b2i_download${url}`

Expand Down
2 changes: 1 addition & 1 deletion src/stores/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class ContainerStore {
)

if (get(result, 'status', 'succeeded') !== 'succeeded') {
return null
return { status: 'failed' }
}

return ObjectMapper.imageBlob(result)
Expand Down
3 changes: 1 addition & 2 deletions src/stores/s2i/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ export default class S2irunStore extends Base {
}
}
this.logData.isLoading = true
const namespace = get(logURL.match(/namespaces\/([\w-/]*)\?/), '1')

const namespace = get(logURL.match(/namespaces\/([\w-/.]*)*\?/), '1')
if (!this.containerName) {
const podsDetail = await request.get(
`api/v1${this.getPath({ namespace, cluster })}`
Expand Down

0 comments on commit 94025b4

Please sign in to comment.