Skip to content

Commit

Permalink
add clone sourceType in filter option
Browse files Browse the repository at this point in the history
Signed-off-by: andy.lee <andy.lee@suse.com>
  • Loading branch information
a110605 committed Jul 7, 2024
1 parent d92f9a4 commit 091293c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
14 changes: 1 addition & 13 deletions src/routes/backingImage/BackingImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { formatMib } from '../../utils/formatter'
import { nodeTagColor, diskTagColor } from '../../utils/constants'

function list({ loading, dataSource, deleteBackingImage, showDiskStateMapDetail, rowSelection, downloadBackingImage, showUpdateMinCopiesCount, height }) {
// console.log('🚀 ~ list ~ dataSource:', dataSource)
const backingImageActionsProps = {
deleteBackingImage,
downloadBackingImage,
Expand All @@ -22,19 +23,6 @@ function list({ loading, dataSource, deleteBackingImage, showDiskStateMapDetail,
</Tooltip>
)
}
if (Object.values(record.diskFileStatusMap).length > 0
&& Object.values(record.diskFileStatusMap).some((diskStatus) => ['starting', 'pending', 'in-progress', 'ready-for-transfer'].includes(diskStatus.state))) {
// some creating states
const state = Object.values(record.diskFileStatusMap)[0]?.state || ''
const percentage = Object.values(record.diskFileStatusMap)[0]?.progress?.toString() || ''
return (
<Tooltip title={state}>
<Icon type="sync" style={{ color: '#00558b', marginRight: 4 }} spin />
{percentage && <span style={{ color: '#00558b' }}>{`${percentage} %`}</span>}
</Tooltip>
)
}

return ''
}

Expand Down
39 changes: 10 additions & 29 deletions src/routes/backingImage/CreateBackingImage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Form, Input, Select, Upload, Button, Icon, InputNumber, Spin } from 'antd'
import { ModalBlur, AutoComplete } from '../../components'
import { ModalBlur } from '../../components'
import { hasReadyBackingDisk } from '../../utils/status'

const FormItem = Form.Item
Expand All @@ -22,6 +22,9 @@ const genDataFromType = (type, getFieldValue) => {
const payload = {
name: getFieldValue('name'),
sourceType: getFieldValue('sourceType'),
minNumberOfCopies: getFieldValue('minNumberOfCopies'),
diskSelector: getFieldValue('diskSelector'),
nodeSelector: getFieldValue('nodeSelector'),
}

switch (type) {
Expand Down Expand Up @@ -110,16 +113,6 @@ const modal = ({
},
}


const autoCompleteProps = {
options: volumeNameOptions,
autoCompleteChange: (value) => {
setFieldsValue({
volumeName: value,
})
},
}

const creationType = getFieldValue('sourceType')
const availBackingImages = backingImageOptions?.filter(image => hasReadyBackingDisk(image)) || []

Expand Down Expand Up @@ -149,8 +142,8 @@ const modal = ({
})(<Select defaultValue={'download'} onChange={() => {}}>
<Option value={'download'}>Download From URL</Option>
<Option value={'upload'}>Upload From Local</Option>
<Option value={'volume'}>Export from a Longhorn volume</Option>
<Option value={'clone'}>Clone from existing backing image</Option>
<Option value={'volume'}>Export From a Longhorn Volume</Option>
<Option value={'clone'}>Clone From Existing Backing Image</Option>
</Select>)}
</FormItem>
{/* Display when select type = volume */}
Expand All @@ -159,27 +152,15 @@ const modal = ({
<FormItem label="Volume Name" {...formItemLayout}>
{getFieldDecorator('volumeName', {
initialValue: '',
valuePropName: 'value',
rules: [
{
required: creationType === 'volume',
message: 'Please input volume name',
},
{
validator: (_rule, value, callback) => {
if (creationType === 'volume') {
if (volumeNameOptions && volumeNameOptions.includes(value)) {
callback()
} else {
callback('Please select an existing Longhorn volume.')
}
} else {
callback()
}
},
message: 'Please select an existing volume',
},
],
})(<AutoComplete {...autoCompleteProps}></AutoComplete>)}
})(<Select>
{volumeNameOptions.map(vol => <Option key={vol} value={vol}>{vol}</Option>)}
</Select>)}
</FormItem>
<FormItem label="Exported Backing Image Type" {...formItemLayout}>
{getFieldDecorator('exportType', {
Expand Down
1 change: 1 addition & 0 deletions src/routes/backingImage/DiskStateMapDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const modal = ({
{currentData.sourceType === 'download' && 'Download from URL'}
{currentData.sourceType === 'upload' && 'Upload'}
{currentData.sourceType === 'export-from-volume' && 'Export from a Longhorn volume'}
{currentData.sourceType === 'clone' && 'Clone from existing backing image'}
</span>
<div style={{ textAlign: 'left' }}>Parameters During Creation</div>
<div>
Expand Down
6 changes: 1 addition & 5 deletions src/routes/backingImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ class BackingImage extends React.Component {
duration: 0,
})
}
params.expectedChecksum = newBackingImage.expectedChecksum
params.diskSelector = newBackingImage.diskSelector
params.nodeSelector = newBackingImage.nodeSelector
params.minNumberOfCopies = newBackingImage.minNumberOfCopies

dispatch({
type: 'backingImage/create',
payload,
Expand Down Expand Up @@ -278,6 +273,7 @@ class BackingImage extends React.Component {
{ value: 'download', name: 'download' },
{ value: 'upload', name: 'upload' },
{ value: 'export-from-volume', name: 'export-from-volume' },
{ value: 'clone', name: 'clone' },
],
onSearch(filter) {
const { field: filterField, value: filterValue, createdFromValue: createdFromPropValue } = filter
Expand Down

0 comments on commit 091293c

Please sign in to comment.