Skip to content

Commit

Permalink
fix: credential role
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisonliu5 committed Jul 6, 2020
1 parent 85e30fb commit 90973fa
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/pages/devops/containers/Credential/detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { get } from 'lodash'
import { getLocalTime } from 'utils'
import { ICON_TYPES } from 'utils/constants'
import CredentialStore from 'stores/devops/credential'

import DevopsStore from 'stores/devops'
import Base from 'core/containers/Base/Detail'
import BaseInfo from 'core/containers/Base/Detail/BaseInfo'
import CreateModal from '../credentialModal'
Expand Down Expand Up @@ -59,12 +59,30 @@ class CredentialDetail extends Base {

init() {
this.store = new CredentialStore(this.module)
this.devopsStore = new DevopsStore()
}

fetchData = () => {
const { params } = this.props.match
this.store.setParams(params)
this.store.fetchDetail(params).catch(this.catch)
this.getRole()
}

getRole = async () => {
const { params } = this.props.match
await Promise.all([
this.devopsStore.fetchDetail(params),
this.props.rootStore.getRules({
workspace: params.workspace,
}),
])

await this.props.rootStore.getRules({
cluster: params.cluster,
workspace: params.workspace,
devops: this.store.getDevops(params.project_id),
})
}

getOperations = () => [
Expand Down Expand Up @@ -134,13 +152,16 @@ class CredentialDetail extends Base {

renderSider() {
const { detail } = this.store
const operations = this.getOperations().filter(item =>
this.enabledActions.includes(item.action)
)

return (
<BaseInfo
icon={ICON_TYPES[this.module]}
name={detail.id || ''}
desc={get(detail, 'description')}
operations={this.getEnabledOperations()}
operations={operations}
labels={detail.labels}
attrs={this.getAttrs()}
/>
Expand Down

0 comments on commit 90973fa

Please sign in to comment.