Skip to content

Commit

Permalink
fix: Filter support quota item for federated project
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 21, 2020
1 parent af2987e commit 82a6211
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/components/Modals/QuotaEdit/Quotas/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import { Input, Select } from '@pitrix/lego-ui'
import { Button } from 'components/Base'
import { QUOTAS_MAP } from 'utils/constants'

import { RESERVED_MODULES } from './constants'
import {
RESERVED_MODULES,
FEDERATED_PROJECT_UNSOPPORT_QUOTA,
} from './constants'

import styles from './index.scss'

Expand All @@ -34,7 +37,13 @@ export default class QuotaItem extends React.Component {
...RESERVED_MODULES,
]
return Object.keys(QUOTAS_MAP)
.filter(key => !filteredModules.includes(key))
.filter(
key =>
!filteredModules.includes(key) &&
(this.props.isFederated
? !FEDERATED_PROJECT_UNSOPPORT_QUOTA.includes(key)
: true)
)
.map(key => ({
label: t(key),
value: key,
Expand Down
6 changes: 6 additions & 0 deletions src/components/Modals/QuotaEdit/Quotas/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ export const QUOTAS_KEY_MODULE_MAP = Object.entries(QUOTAS_MAP).reduce(
}),
{}
)

export const FEDERATED_PROJECT_UNSOPPORT_QUOTA = [
'daemonsets',
'jobs',
'cronjobs',
]
1 change: 1 addition & 0 deletions src/components/Modals/QuotaEdit/Quotas/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default class Quotas extends React.Component {
onModuleDelete={this.handleItemModuleDelete}
filterModules={filterModules}
disableSelect={item.module === 'pods'}
isFederated={this.props.isFederated}
/>
</Form.Item>
))}
Expand Down
11 changes: 9 additions & 2 deletions src/components/Modals/QuotaEdit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ export default class QuotaEditModal extends React.Component {
}

render() {
const { detail, visible, onOk, onCancel, isSubmitting } = this.props
const {
detail,
visible,
onOk,
onCancel,
isFederated,
isSubmitting,
} = this.props

return (
<Modal.Form
Expand All @@ -193,7 +200,7 @@ export default class QuotaEditModal extends React.Component {
<ResourceLimit {...this.resourceLimitProps} />
</Form.Item>
<div className={styles.label}>{t('Resource Quota')}</div>
<Quotas data={this.state.formTemplate} />
<Quotas data={this.state.formTemplate} isFederated={isFederated} />
</div>
</Modal.Form>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class ResourceQuota extends React.Component {
this.trigger('project.quota.edit', {
detail: { name: namespace, namespace, cluster: cluster.name },
success: this.fetchData,
isFederated: true,
})
}

Expand Down

0 comments on commit 82a6211

Please sign in to comment.