fix: Refactor create instance
1. Refactor create instance base step codes 2. Fix fetch all data with sort params Change-Id: I835c2c29c96dc6fada1c6982539a448363ac684e
This commit is contained in:
parent
6e96e18809
commit
9c678927d5
@ -145,11 +145,11 @@ export class BaseStep extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get imageSourceType() {
|
get imageSourceType() {
|
||||||
return this.sourceTypes[0];
|
return this.sourceTypes.find((it) => it.value === 'image');
|
||||||
}
|
}
|
||||||
|
|
||||||
get volumeSourceType() {
|
get volumeSourceType() {
|
||||||
return this.sourceTypes[1];
|
return this.sourceTypes.find((it) => it.value === 'bootableVolume');
|
||||||
}
|
}
|
||||||
|
|
||||||
allowed = () => Promise.resolve();
|
allowed = () => Promise.resolve();
|
||||||
@ -198,7 +198,7 @@ export class BaseStep extends Base {
|
|||||||
} else {
|
} else {
|
||||||
await this.volumeStore.fetchList({
|
await this.volumeStore.fetchList({
|
||||||
sortKey: 'bootable',
|
sortKey: 'bootable',
|
||||||
sortDir: 'ascend',
|
sortOrder: 'ascend',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (volume) {
|
if (volume) {
|
||||||
@ -219,26 +219,6 @@ export class BaseStep extends Base {
|
|||||||
return getImageSystemTabs();
|
return getImageSystemTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
get specTabs() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
label: t('General Computing Type'),
|
|
||||||
// value: 'general'
|
|
||||||
value: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('Optimized Computing Type'),
|
|
||||||
// value: 'computing'
|
|
||||||
value: 5,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('GPU Accelerated Computing Type'),
|
|
||||||
// value: 'gpu'
|
|
||||||
value: 10,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
checkSystemDisk = (rule, value) => {
|
checkSystemDisk = (rule, value) => {
|
||||||
if (!value.type) {
|
if (!value.type) {
|
||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
@ -312,6 +292,48 @@ export class BaseStep extends Base {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get imageColumns() {
|
||||||
|
return getImageColumns(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
get volumeColumns() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: t('Name'),
|
||||||
|
dataIndex: 'name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('Size'),
|
||||||
|
dataIndex: 'size',
|
||||||
|
render: (value) => `${value}GB`,
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('Status'),
|
||||||
|
dataIndex: 'status',
|
||||||
|
render: (value) => volumeStatus[value] || '-',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('Type'),
|
||||||
|
dataIndex: 'volume_type',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('Created At'),
|
||||||
|
dataIndex: 'created_at',
|
||||||
|
valueRender: 'sinceTime',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
get showSystemDisk() {
|
||||||
|
return this.sourceTypeIsImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
getFlavorComponent() {
|
||||||
|
return <FlavorSelectTable onChange={this.onFlavorChange} />;
|
||||||
|
}
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { image } = this.locationParams;
|
const { image } = this.locationParams;
|
||||||
const imageLoading = image
|
const imageLoading = image
|
||||||
@ -341,7 +363,7 @@ export class BaseStep extends Base {
|
|||||||
{
|
{
|
||||||
name: 'flavor',
|
name: 'flavor',
|
||||||
label: t('Specification'),
|
label: t('Specification'),
|
||||||
component: <FlavorSelectTable onChange={this.onFlavorChange} />,
|
component: this.getFlavorComponent(),
|
||||||
required: true,
|
required: true,
|
||||||
wrapperCol: {
|
wrapperCol: {
|
||||||
xs: {
|
xs: {
|
||||||
@ -362,7 +384,9 @@ export class BaseStep extends Base {
|
|||||||
tip: t(
|
tip: t(
|
||||||
'The start source is a template used to create an instance. You can choose an image or a bootable volume.'
|
'The start source is a template used to create an instance. You can choose an image or a bootable volume.'
|
||||||
),
|
),
|
||||||
onChange: this.onSourceChange,
|
onChange: (value) => {
|
||||||
|
this.onSourceChange(value);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'image',
|
name: 'image',
|
||||||
@ -372,7 +396,7 @@ export class BaseStep extends Base {
|
|||||||
isLoading: imageLoading,
|
isLoading: imageLoading,
|
||||||
required: this.sourceTypeIsImage,
|
required: this.sourceTypeIsImage,
|
||||||
isMulti: false,
|
isMulti: false,
|
||||||
hidden: !this.sourceTypeIsImage,
|
display: this.sourceTypeIsImage,
|
||||||
extra: this.getImageExtraWords(),
|
extra: this.getImageExtraWords(),
|
||||||
filterParams: [
|
filterParams: [
|
||||||
{
|
{
|
||||||
@ -380,7 +404,7 @@ export class BaseStep extends Base {
|
|||||||
name: 'name',
|
name: 'name',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
columns: getImageColumns(this),
|
columns: this.imageColumns,
|
||||||
tabs: this.systemTabs,
|
tabs: this.systemTabs,
|
||||||
defaultTabValue:
|
defaultTabValue:
|
||||||
this.locationParams.os_distro || this.systemTabs[0].value,
|
this.locationParams.os_distro || this.systemTabs[0].value,
|
||||||
@ -395,7 +419,7 @@ export class BaseStep extends Base {
|
|||||||
isLoading: this.volumeStore.list.isLoading,
|
isLoading: this.volumeStore.list.isLoading,
|
||||||
required: this.sourceTypeIsVolume,
|
required: this.sourceTypeIsVolume,
|
||||||
isMulti: false,
|
isMulti: false,
|
||||||
hidden: !this.sourceTypeIsVolume,
|
display: this.sourceTypeIsVolume,
|
||||||
onChange: this.onBootableVolumeChange,
|
onChange: this.onBootableVolumeChange,
|
||||||
filterParams: [
|
filterParams: [
|
||||||
{
|
{
|
||||||
@ -403,33 +427,7 @@ export class BaseStep extends Base {
|
|||||||
name: 'name',
|
name: 'name',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
columns: [
|
columns: this.volumeColumns,
|
||||||
{
|
|
||||||
title: t('Name'),
|
|
||||||
dataIndex: 'name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('Size'),
|
|
||||||
dataIndex: 'size',
|
|
||||||
render: (value) => `${value}GB`,
|
|
||||||
width: 80,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('Status'),
|
|
||||||
dataIndex: 'status',
|
|
||||||
render: (value) => volumeStatus[value] || '-',
|
|
||||||
width: 80,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('Type'),
|
|
||||||
dataIndex: 'volume_type',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('Created At'),
|
|
||||||
dataIndex: 'created_at',
|
|
||||||
valueRender: 'sinceTime',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
@ -439,8 +437,8 @@ export class BaseStep extends Base {
|
|||||||
label: t('System Disk'),
|
label: t('System Disk'),
|
||||||
type: 'instance-volume',
|
type: 'instance-volume',
|
||||||
options: this.volumeTypes,
|
options: this.volumeTypes,
|
||||||
required: !this.sourceTypeIsVolume,
|
required: this.showSystemDisk,
|
||||||
hidden: this.sourceTypeIsVolume,
|
hidden: !this.showSystemDisk,
|
||||||
validator: this.checkSystemDisk,
|
validator: this.checkSystemDisk,
|
||||||
minSize: this.getSystemDiskMinSize(),
|
minSize: this.getSystemDiskMinSize(),
|
||||||
extra: t('Disk size is limited by the min disk of flavor, image, etc.'),
|
extra: t('Disk size is limited by the min disk of flavor, image, etc.'),
|
||||||
|
@ -370,6 +370,7 @@ export default class BaseStore {
|
|||||||
// todo: no page, no limit, fetch all
|
// todo: no page, no limit, fetch all
|
||||||
const { tab, all_projects, ...rest } = filters;
|
const { tab, all_projects, ...rest } = filters;
|
||||||
const params = { ...rest };
|
const params = { ...rest };
|
||||||
|
this.updateParamsSort(params, sortKey, sortOrder);
|
||||||
if (all_projects) {
|
if (all_projects) {
|
||||||
if (!this.listFilterByProject) {
|
if (!this.listFilterByProject) {
|
||||||
params.all_projects = true;
|
params.all_projects = true;
|
||||||
|
@ -89,6 +89,8 @@ export class VolumeStore extends Base {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateParamsSort = this.updateParamsSortPage;
|
||||||
|
|
||||||
async listDidFetch(items, _, filters) {
|
async listDidFetch(items, _, filters) {
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
return items;
|
return items;
|
||||||
|
Loading…
Reference in New Issue
Block a user