Skip to content

Commit

Permalink
fix: Display volume template info in statefulsets setting modal (#3522)
Browse files Browse the repository at this point in the history
Signed-off-by: TheYoungManLi <cjl@kubesphere.io>
  • Loading branch information
weili520 authored Aug 3, 2022
1 parent b17f3ea commit bfc27a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { List } from 'components/Base'

import styles from './index.scss'

const Card = ({ volume, onDelete, onEdit }) => {
const Card = ({ volume, onDelete, onEdit, banEdit = false }) => {
const handleDelete = () => onDelete(volume.metadata.name)
const handleEdit = () => onEdit(volume)

Expand Down Expand Up @@ -70,6 +70,22 @@ const Card = ({ volume, onDelete, onEdit }) => {
</div>
)

if (banEdit) {
return (
<List.Item
icon="storage"
title={get(volume, 'metadata.name', '-')}
description={`${t('Storage Classs')}: ${get(
volume,
'spec.storageClassName',
'-'
)}`}
extras={mount}
details={details}
/>
)
}

return (
<List.Item
icon="storage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class VolumeList extends React.Component {
onChange: PropTypes.func,
onShowAddVolume: PropTypes.func,
onShowEdit: PropTypes.func,
hideVolumeSetting: PropTypes.bool,
}

static defaultProps = {
Expand All @@ -45,6 +46,7 @@ export default class VolumeList extends React.Component {
onChange() {},
onShowAddVolume() {},
onShowEdit() {},
hideVolumeSetting: false,
}

static contextTypes = {
Expand Down Expand Up @@ -144,7 +146,7 @@ export default class VolumeList extends React.Component {
}

render() {
const { className } = this.props
const { className, hideVolumeSetting } = this.props
const formatVolumes = this.getFormattedVolumes()

return (
Expand All @@ -158,11 +160,12 @@ export default class VolumeList extends React.Component {
key={get(volume, 'metadata.name')}
onEdit={this.handleEdit}
onDelete={this.handleDelete}
banEdit={hideVolumeSetting}
/>
))}
</ul>
)}
{this.renderAddVolume()}
{!hideVolumeSetting && this.renderAddVolume()}
</div>
</div>
)
Expand Down
3 changes: 2 additions & 1 deletion src/components/Forms/Workload/VolumeSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class VolumeSettings extends React.Component {
/>
)}
<div className={styles.volumes}>
{isSTS && !hideVolumeSetting && (
{isSTS && (
<Form.Item>
<VolumeTemplateList
prefix={this.prefix}
Expand All @@ -676,6 +676,7 @@ class VolumeSettings extends React.Component {
onShowEdit={this.showEditVolumeTemplate}
collectSavedLog={collectSavedLog}
logPath={logPath}
hideVolumeSetting={hideVolumeSetting}
/>
</Form.Item>
)}
Expand Down

0 comments on commit bfc27a9

Please sign in to comment.