diff --git a/src/locales/en.json b/src/locales/en.json index ac2fd926..eda9643d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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", diff --git a/src/locales/zh.json b/src/locales/zh.json index cc08a1f4..c6ad8e77 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -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.": "配额不足以扩容共享。", diff --git a/src/pages/share/containers/ShareNetwork/actions/Create.jsx b/src/pages/share/containers/ShareNetwork/actions/Create.jsx index fb601bd7..7c0c82e0 100644 --- a/src/pages/share/containers/ShareNetwork/actions/Create.jsx +++ b/src/pages/share/containers/ShareNetwork/actions/Create.jsx @@ -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, }, ]; } diff --git a/src/resources/cinder/backup.jsx b/src/resources/cinder/backup.jsx index 339e6bb8..af210618 100644 --- a/src/resources/cinder/backup.jsx +++ b/src/resources/cinder/backup.jsx @@ -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'), diff --git a/src/stores/cinder/pool.js b/src/stores/cinder/pool.js index a517ab41..99dee0e2 100644 --- a/src/stores/cinder/pool.js +++ b/src/stores/cinder/pool.js @@ -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() { diff --git a/src/stores/manila/share-access-rule.js b/src/stores/manila/share-access-rule.js index 90f4ef8d..95614631 100644 --- a/src/stores/manila/share-access-rule.js +++ b/src/stores/manila/share-access-rule.js @@ -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, diff --git a/src/stores/manila/share-group-type.js b/src/stores/manila/share-group-type.js index b075ccd0..9763ab31 100644 --- a/src/stores/manila/share-group-type.js +++ b/src/stores/manila/share-group-type.js @@ -29,7 +29,10 @@ export class ShareGroupTypeStore extends Base { } get paramsFunc() { - return (params) => params; + return (params) => { + const { keywords, ...rest } = params; + return rest; + }; } @action diff --git a/src/stores/manila/share-group.js b/src/stores/manila/share-group.js index 518a45aa..9cc85946 100644 --- a/src/stores/manila/share-group.js +++ b/src/stores/manila/share-group.js @@ -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, diff --git a/src/stores/manila/share-instance.js b/src/stores/manila/share-instance.js index b4657f9e..b5c23f5d 100644 --- a/src/stores/manila/share-instance.js +++ b/src/stores/manila/share-instance.js @@ -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) { diff --git a/src/stores/manila/share-network.js b/src/stores/manila/share-network.js index 338524ac..5fc9621f 100644 --- a/src/stores/manila/share-network.js +++ b/src/stores/manila/share-network.js @@ -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, diff --git a/src/stores/manila/share-server.js b/src/stores/manila/share-server.js index 0c95dd4d..25910e2b 100644 --- a/src/stores/manila/share-server.js +++ b/src/stores/manila/share-server.js @@ -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; }; } diff --git a/src/stores/manila/share.js b/src/stores/manila/share.js index 76bc41d6..b5384c22 100644 --- a/src/stores/manila/share.js +++ b/src/stores/manila/share.js @@ -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();