Skip to content

Commit

Permalink
fix: change the keywords of project_id to devops and add the generate…
Browse files Browse the repository at this point in the history
…Name in devops

Signed-off-by: harrisonliu5 harrisonliu_5@163.com
  • Loading branch information
harrisonliu5 committed Jul 30, 2020
1 parent 8b9ea6f commit 809ecdf
Show file tree
Hide file tree
Showing 48 changed files with 273 additions and 306 deletions.
6 changes: 3 additions & 3 deletions src/components/Forms/CICDs/BaseInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ export default class BaseInfo extends React.Component {
}

renderRepoSelectForm() {
const { formTemplate, project_id, cluster } = this.props
const { formTemplate, devops, cluster } = this.props
return (
<RepoSelectForm
sourceData={formTemplate['multi_branch_pipeline']}
project_id={project_id}
devops={devops}
name={formTemplate.name}
cluster={cluster}
onSave={this.handleRepoChange}
Expand Down Expand Up @@ -150,7 +150,7 @@ export default class BaseInfo extends React.Component {
ref={this.scmRef}
onClick={this.showSelectRepo}
handleDeleteSource={this.handleDeleteSource}
project_id={this.props.project_id}
devops={this.props.devops}
/>
</Form.Item>
</Column>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Forms/CICDs/RepoSelect/BitBucketForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export default class BitBucketForm extends GitHubForm {

@action
handlePasswordConfirm = async () => {
const { cluster, project_id } = this.props
const { cluster, devops } = this.props
const data = this.tokenFormRef.current.getData()
this.setState({ isLoading: true })
this.props.store
.creatBitBucketServers({ cluster, project_id, ...data })
.creatBitBucketServers({ cluster, devops, ...data })
.finally(() => {
this.setState({ isLoading: false })
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/Forms/CICDs/RepoSelect/GithubForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export default class GitHubForm extends React.Component {

@action
handlePasswordConfirm = async () => {
const { name, cluster, project_id } = this.props
const { name, cluster, devops } = 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 })
.putAccessToken({ token: data.token, name, cluster, devops })
.finally(() => {
this.setState({ isLoading: false })
})
Expand Down
22 changes: 11 additions & 11 deletions src/components/Forms/CICDs/RepoSelect/subForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export default class RepoSelectForm extends React.Component {
showCredential = false

componentDidMount() {
const { onCancel, project_id, name, cluster } = this.props
const { onCancel, devops, name, cluster } = this.props
const { registerSubRoute } = this.context
const { sourceData } = this.props

registerSubRoute && registerSubRoute(this.handleSubmit, onCancel)

this.store.getCredential({ project_id, cluster })
this.store.getCredential({ devops, cluster })
this.store.name = name

if (!isEmpty(sourceData)) {
Expand Down Expand Up @@ -105,8 +105,8 @@ export default class RepoSelectForm extends React.Component {
}

hideCreateCredential = async () => {
const { project_id, cluster } = this.props
await this.store.getCredential({ project_id, cluster })
const { devops, cluster } = this.props
await this.store.getCredential({ devops, cluster })
this.showCredential = false
}

Expand Down Expand Up @@ -193,15 +193,15 @@ export default class RepoSelectForm extends React.Component {
}

renderForm() {
const { project_id, enableTypeChange, cluster } = this.props
const { devops, enableTypeChange, cluster } = this.props
if (this.source_type === 'github') {
return (
<GithubForm
store={this.store}
formRef={this.formRef}
handleSubmit={this.handleSubmit}
cluster={cluster}
project_id={project_id}
devops={devops}
/>
)
}
Expand All @@ -212,7 +212,7 @@ export default class RepoSelectForm extends React.Component {
store={this.store}
formRef={this.formRef}
handleSubmit={this.handleSubmit}
project_id={project_id}
devops={devops}
showCredential={this.showCreateCredential}
enableTypeChange={enableTypeChange}
cluster={cluster}
Expand All @@ -227,7 +227,7 @@ export default class RepoSelectForm extends React.Component {
formRef={this.formRef}
handleSubmit={this.handleSubmit}
cluster={cluster}
project_id={project_id}
devops={devops}
/>
)
}
Expand All @@ -237,14 +237,14 @@ export default class RepoSelectForm extends React.Component {
store={this.store}
formRef={this.formRef}
handleSubmit={this.handleSubmit}
project_id={project_id}
devops={devops}
showCredential={this.showCreateCredential}
/>
)
}

render() {
const { project_id, cluster } = this.props
const { devops, cluster } = this.props

return (
<div className={styles.formWrapper}>
Expand All @@ -262,7 +262,7 @@ export default class RepoSelectForm extends React.Component {
visible={this.showCredential}
onOk={this.hideCreateCredential}
onCancel={this.hideCreateCredential}
project_id={project_id}
devops={devops}
cluster={cluster}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/HOCs/withList.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function withList(options) {
module: this.authKey,
...this.props.match.params,
project: this.props.match.params.namespace,
devops: this.props.match.params.project_id,
devops: this.props.match.params.devops,
})
}

Expand Down
6 changes: 5 additions & 1 deletion src/components/Modals/DevOpsCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ export default class ProjectCreateModal extends React.Component {
{ validator: this.nameValidator },
]}
>
<Input name="metadata.name" autoFocus={true} maxLength={63} />
<Input
name="metadata.generateName"
autoFocus={true}
maxLength={63}
/>
</Form.Item>
</Column>
<Column>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modals/ProjectSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default class ProjectSelectModal extends React.Component {
>
{data.map(item => (
<Card
key={item.uid || item.project_id}
key={item.uid || item.devops}
data={item}
type={type}
onEnter={this.handleOnEnter}
Expand Down
2 changes: 1 addition & 1 deletion src/core/containers/Base/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class DetailBase extends React.Component {
module: this.authKey,
workspace: this.props.match.params.workspace,
project: this.props.match.params.namespace,
devops: this.props.match.params.project_id,
devops: this.props.match.params.devops,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/containers/Base/List/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class BaseList extends React.Component {
module: this.authKey,
workspace: this.props.match.params.workspace,
project: this.props.match.params.namespace,
devops: this.props.match.params.project_id,
devops: this.props.match.params.devops,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/layouts/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DetailLayout extends Component {
rootStore.register('project', projectStore)
}

if (params.project_id && !rootStore.devops) {
if (params.devops && !rootStore.devops) {
const devopsStore = new DevOpsStore()
rootStore.register('devops', devopsStore)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default [
component: Projects,
},
{
path: '/:workspace/clusters/:cluster/devops/:project_id',
path: '/:workspace/clusters/:cluster/devops/:devops',
component: DevOps,
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/devops/components/Pipeline/StepModals/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class InputStep extends React.Component {
getUsers = () => {
this.setState({ loading: true })
this.devopsStore
.fetchMembers({ project_id: this.props.project_id })
.fetchMembers({ devops: this.props.devops })
.then(result => {
this.setState({ loading: false })

Expand Down
6 changes: 3 additions & 3 deletions src/pages/devops/components/Pipeline/StepsSelector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class StepsEditor extends React.Component {
}

renderStepsModal = () => {
const { project_id, cluster } = this.props.store.params
const { devops, cluster } = this.props.store.params
const { edittingData, isAddingStep } = this.props.store

if (isAddingStep === 'condition') {
Expand Down Expand Up @@ -249,7 +249,7 @@ export default class StepsEditor extends React.Component {
store={this.props.store}
/>
<InputStep
project_id={project_id}
devops={devops}
visible={this.state.isShowinput}
edittingData={edittingData}
onAddStep={this.handleAddStep('input')}
Expand Down Expand Up @@ -281,7 +281,7 @@ export default class StepsEditor extends React.Component {
visible={this.state.showCredential}
onOk={this.hideCreateCredential}
onCancel={this.hideCreateCredential}
project_id={project_id}
devops={devops}
cluster={cluster}
credentialType={this.state.isShowkubernetesDeploy ? 'kubeconfig' : ''}
/>
Expand Down
12 changes: 6 additions & 6 deletions src/pages/devops/components/Pipeline/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export default class Pipeline extends React.Component {
if (props.isEditMode) {
this.store = new Store()
this.store.params = props.params
const { project_id, name } = props.params
const { devops, name } = props.params
this.prevData = JSON.parse(
localStorage.getItem(`${globals.user.username}-${project_id}-${name}`)
localStorage.getItem(`${globals.user.username}-${devops}-${name}`)
)
if (isEmpty(props.jsonData)) {
this.store.setData(this.prevData || CREATE_TEMP)
Expand Down Expand Up @@ -90,17 +90,17 @@ export default class Pipeline extends React.Component {

@action
handleContinue = () => {
const { project_id, name } = this.props.params
const { devops, name } = this.props.params
this.setState({ showConfirmPrevdata: false })
this.store.setData(this.prevData)
localStorage.removeItem(`${globals.user.username}-${project_id}-${name}`)
localStorage.removeItem(`${globals.user.username}-${devops}-${name}`)
}

@action
handleDiscard = () => {
const { project_id, name } = this.props.params
const { devops, name } = this.props.params
this.setState({ showConfirmPrevdata: false })
localStorage.removeItem(`${globals.user.username}-${project_id}-${name}`)
localStorage.removeItem(`${globals.user.username}-${devops}-${name}`)
}

render() {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/devops/components/Pipeline/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export default class Store extends BaseStore {
}

handleSetInLocalStorage() {
const { project_id, name } = this.params
const { devops, name } = this.params
this.prevData = localStorage.setItem(
`${globals.user.username}-${project_id}-${name}`,
`${globals.user.username}-${devops}-${name}`,
JSON.stringify(toJS(this.jsonData))
)
}
Expand Down Expand Up @@ -321,7 +321,7 @@ export default class Store extends BaseStore {
getCredentials = async () => {
this.isCredentialLoading = true
const result = await this.credentialStore.fetchList({
project_id: this.params.project_id,
devops: this.params.devops,
cluster: this.params.cluster,
})

Expand Down
22 changes: 11 additions & 11 deletions src/pages/devops/containers/BaseInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import React from 'react'
import { toJS } from 'mobx'
import { observer, inject } from 'mobx-react'
import { Icon, Dropdown, Menu } from '@pitrix/lego-ui'
import { Card, Button } from 'components/Base'
import { Card, Button, Notify } from 'components/Base'
import DeleteModal from 'components/Modals/Delete'
import Info from 'components/Cards/Info'
import Banner from 'components/Cards/Banner'
import EditModal from 'devops/components/Modals/DevOpsEdit'

import UserStore from 'stores/user'
import RoleStore from 'stores/role'

import styles from './index.scss'

@inject('rootStore', 'devopsStore')
Expand Down Expand Up @@ -64,12 +63,12 @@ class BaseInfo extends React.Component {
return this.props.devopsStore
}

get project_id() {
return this.props.match.params.project_id
get devops() {
return this.props.match.params.devops
}

get devops() {
return this.store.devops
get devopsName() {
return this.store.devopsName
}

get workspace() {
Expand Down Expand Up @@ -117,15 +116,16 @@ class BaseInfo extends React.Component {
})
}

handleEdit = ({ name, ...data }) => {
handleEdit = ({ devops, ...data }) => {
this.store
.update(
{ name, cluster: this.cluster, workspace: this.workspace },
{ devops, cluster: this.cluster, workspace: this.workspace },
data,
true
)
.then(() => {
this.hideEdit()
Notify.success({ content: `${t('Updated Successfully')}!` })
this.store.fetchDetail({
workspace: this.workspace,
...this.props.match.params,
Expand All @@ -142,7 +142,7 @@ class BaseInfo extends React.Component {
handleDelete = () => {
this.store
.delete({
name: this.devops,
devops: this.devops,
cluster: this.cluster,
workspace: this.workspace,
})
Expand Down Expand Up @@ -213,7 +213,7 @@ class BaseInfo extends React.Component {
title={memberCount}
desc={t('Members')}
url={`/${this.workspace}/clusters/${this.cluster}/devops/${
this.project_id
this.devops
}/members`}
/>
<Info
Expand All @@ -222,7 +222,7 @@ class BaseInfo extends React.Component {
title={roleCount}
desc={t('Project Roles')}
url={`/${this.workspace}/clusters/${this.cluster}/devops/${
this.project_id
this.devops
}/roles`}
/>
</div>
Expand Down
Loading

0 comments on commit 809ecdf

Please sign in to comment.