fix: Fix share api && create share network

1. Fix delete share when share has share group
2. Fix subnet select when create share network: only subnets that are already connected to the router can be selected
3. Remove keywords param when fetch share-access-rules/share-groups/share-group-types/share-instances/share-networks/share-servers/cinder-pools

Change-Id: Icd53239d7cadbfe37369a27d4b53d4edfcbd2c12
This commit is contained in:
Jingwei.Zhang 2022-05-18 11:21:01 +08:00
parent b8675c197c
commit 92b3ba546c
12 changed files with 75 additions and 27 deletions

View File

@ -1420,6 +1420,7 @@
"Online": "Online",
"Online Resize": "Online Resize",
"Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field",
"Only subnets that are already connected to the router can be selected.": "Only subnets that are already connected to the router can be selected.",
"Open External Gateway": "Open External Gateway",
"OpenStack Service": "OpenStack Service",
"Operating Status": "Operating Status",

View File

@ -121,7 +121,7 @@
"Application Credentials": "应用凭证",
"Application Template": "应用模板",
"Apply Latency(ms)": "应用延迟(毫秒)",
"Applying": "使用中",
"Applying": "申请中",
"Arch": "",
"Architecture": "架构",
"Are you sure to cancel transfer volume { name }? ": "确认要取消{ name }云硬盘转让?",
@ -610,7 +610,7 @@
"Deleting this stack will delete all resources deployed by the stack.": "删除此堆栈将删除所有堆栈部署的资源。",
"Democratic Republic of the Congo": "刚果民主共和国",
"Denmark": "丹麦",
"Denying": "拒绝中",
"Denying": "删除中",
"Deploy Failed": "部署失败",
"Deploy Wait": "等待部署",
"Deploying": "部署中",
@ -1420,6 +1420,7 @@
"Online": "在线",
"Online Resize": "在线修改配置",
"Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "只可填写交换机的Mac地址或者交换机基于openflow的数据路径ID",
"Only subnets that are already connected to the router can be selected.": "仅可选择已经连接过路由器的子网。",
"Open External Gateway": "开启公网网关",
"OpenStack Service": "OpenStack服务",
"Operating Status": "操作状态",
@ -1660,7 +1661,7 @@
"Qos Policy": "QoS策略",
"Queued": "已排队",
"Queued To Apply": "排队申请",
"Queued To Deny": "排队拒绝",
"Queued To Deny": "排队删除",
"Quota Overview": "配额概况",
"Quota exceeded": "配额用尽",
"Quota is not enough for extend share.": "配额不足以扩容共享。",

View File

@ -17,6 +17,7 @@ import { ModalAction } from 'containers/Action';
import globalShareNetworkStore from 'stores/manila/share-network';
import { NetworkStore } from 'stores/neutron/network';
import { SubnetStore } from 'stores/neutron/subnet';
import { PortStore } from 'stores/neutron/port';
export class Create extends ModalAction {
static id = 'create';
@ -31,6 +32,7 @@ export class Create extends ModalAction {
this.store = globalShareNetworkStore;
this.networkStore = new NetworkStore();
this.subnetStore = new SubnetStore();
this.portStore = new PortStore();
}
static policy = 'manila:share_network:create';
@ -45,25 +47,42 @@ export class Create extends ModalAction {
return 'large';
}
get subnets() {
const { networkId } = this.state;
if (!networkId) {
return [];
}
return this.subnetStore.list.data || [];
}
getSubnets() {
async getSubnets() {
const { networkId } = this.state;
if (!networkId) {
return;
}
this.subnetStore.fetchList({ network_id: networkId });
const [subnets, ports] = await Promise.all([
this.subnetStore.fetchList({ network_id: networkId }),
this.portStore.fetchList({ network_id: networkId }),
]);
const routerInterfaceOwners = [
'network:router_interface',
'network:ha_router_replicated_interface',
'network:router_interface_distributed',
];
const routerPorts = ports.filter((it) =>
routerInterfaceOwners.includes(it.device_owner)
);
subnets.forEach((subnet) => {
const port = routerPorts.find((it) => {
const { fixed_ips = [] } = it;
return fixed_ips.some((ip) => ip.subnet_id === subnet.id);
});
subnet.selectable = !!port;
});
this.setState({
subnets,
});
}
onNetworkChange = (value) => {
const { selectedRowKeys = [] } = value;
if (selectedRowKeys.length === 0) {
this.setState({
networkId: null,
subnets: [],
});
return;
}
this.setState(
@ -81,7 +100,7 @@ export class Create extends ModalAction {
}
get formItems() {
const { networkId } = this.state;
const { networkId, subnets } = this.state;
return [
{
name: 'name',
@ -105,9 +124,16 @@ export class Create extends ModalAction {
name: 'subnet',
label: t('Subnet'),
type: 'select-table',
data: this.subnets,
isLoading: networkId && this.subnetStore.list.isLoading,
data: subnets,
isLoading:
networkId &&
this.subnetStore.list.isLoading &&
this.portStore.list.isLoading,
required: true,
extra: t(
'Only subnets that are already connected to the router can be selected.'
),
disabledFunc: (record) => !record.selectable,
filterParams: [
{
label: t('Name'),
@ -139,6 +165,7 @@ export class Create extends ModalAction {
valueRender: 'sinceTime',
},
],
display: !!networkId,
},
];
}

View File

@ -21,7 +21,6 @@ export const backupStatus = {
error: t('Error'),
updating: t('Updating'),
deleting: t('Deleting'),
applying: t('Applying'),
error_deleting: t('Error Deleting'),
restoring: t('Restoring'),
creating: t('Creating'),

View File

@ -26,10 +26,13 @@ export class PoolStore extends Base {
}
get paramsFunc() {
return (params) => ({
...params,
detail: true,
});
return (params) => {
const { keywords, ...rest } = params;
return {
...rest,
detail: true,
};
};
}
get mapper() {

View File

@ -32,7 +32,7 @@ export class ShareAccessRuleStore extends Base {
get paramsFunc() {
return (params) => {
const { id, ...rest } = params;
const { id, keywords, ...rest } = params;
return {
...rest,
share_id: id,

View File

@ -29,7 +29,10 @@ export class ShareGroupTypeStore extends Base {
}
get paramsFunc() {
return (params) => params;
return (params) => {
const { keywords, ...rest } = params;
return rest;
};
}
@action

View File

@ -29,7 +29,7 @@ export class ShareGroupStore extends Base {
get paramsFuncPage() {
return (params) => {
const { all_projects, current, ...rest } = params;
const { all_projects, current, keywords, ...rest } = params;
return {
...rest,
all_tenants: all_projects ? 1 : 0,

View File

@ -22,7 +22,10 @@ export class ShareInstanceStore extends Base {
}
get paramsFunc() {
return (params) => params;
return (params) => {
const { keywords, ...rest } = params;
return rest;
};
}
async detailDidFetch(item) {

View File

@ -35,7 +35,7 @@ export class ShareNetworkStore extends Base {
get paramsFunc() {
return (params) => {
const { all_projects, ...rest } = params;
const { all_projects, keywords, ...rest } = params;
return {
...rest,
all_tenants: all_projects ? 1 : 0,

View File

@ -22,7 +22,7 @@ export class ShareServerStore extends Base {
get paramsFunc() {
return (params) => {
const { all_projects, ...rest } = params;
const { all_projects, keywords, ...rest } = params;
return rest;
};
}

View File

@ -157,6 +157,17 @@ export class ShareStore extends Base {
};
return this.submitting(this.client.action(id, body));
}
deleteItem = (data) => {
const { id, share_group_id } = data;
if (!share_group_id) {
return this.client.delete(id);
}
return this.client.delete(id, null, { share_group_id });
};
@action
delete = (data) => this.submitting(this.deleteItem(data));
}
const globalShareStore = new ShareStore();