From 504dd24da42d2324105e02121ba4148eda49b0bb Mon Sep 17 00:00:00 2001 From: zhuyue Date: Fri, 3 Sep 2021 17:48:50 +0800 Subject: [PATCH] fix: remove interface number check of detach action remove interface number check of detach action Change-Id: I86e904f9d59ef67a0aff6c78f598aa2344bd56a4 --- .../VirtualAdapter/actions/Detach.jsx | 45 +------------------ src/stores/neutron/virtual-adapter.js | 21 +-------- 2 files changed, 3 insertions(+), 63 deletions(-) diff --git a/src/pages/network/containers/VirtualAdapter/actions/Detach.jsx b/src/pages/network/containers/VirtualAdapter/actions/Detach.jsx index ffe3be88..506508f1 100644 --- a/src/pages/network/containers/VirtualAdapter/actions/Detach.jsx +++ b/src/pages/network/containers/VirtualAdapter/actions/Detach.jsx @@ -13,8 +13,7 @@ // limitations under the License. import { ConfirmAction } from 'containers/Action'; -import globalServerStore, { ServerStore } from 'stores/nova/instance'; -// import { isActiveOrShutOff, isNotLocked } from 'resources/instance'; +import globalServerStore from 'stores/nova/instance'; export default class Detach extends ConfirmAction { get id() { @@ -39,50 +38,10 @@ export default class Detach extends ConfirmAction { policy = 'os_compute_api:os-attach-interfaces:delete'; - hasMoreInterfaces(instance) { - let count = 0; - const { addresses } = instance; - Object.keys(addresses).forEach((key) => { - const detail = addresses[key]; - count += detail.length; - }); - return count > 1; - } - - allowedCheckFunc = (item) => { - const flag = !!item.device_id; - const { detail } = this.containerProps; - if (detail) { - return flag && this.hasMoreInterfaces(detail); - } - // && item.instance - // && isNotLocked(item.instance) && isActiveOrShutOff(item.instance) - // && this.hasMoreInterfaces(item.instance); - // console.log(flag, item); - return flag; - }; + allowedCheckFunc = (item) => !!item.device_id; onSubmit = async () => { const { id, device_id } = this.item; - const { detail } = this.containerProps; - if (!detail) { - const store = new ServerStore(); - await store.fetchDetail({ id: device_id }); - if (!this.hasMoreInterfaces(store.detail)) { - this.onlyOne = true; - this.showConfirmErrorBeforeSubmit = true; - this.confirmErrorMessageBeforeSubmit = t( - 'Unable to {action}, because : {reason}, instance: {name}.', - { - action: this.actionName || this.title, - name: this.item.name, - reason: t('the instance only has one virtual adapter'), - } - ); - return Promise.reject(); - } - } - this.showConfirmErrorBeforeSubmit = false; return globalServerStore.detachInterface({ id: device_id, ports: [id] }); }; } diff --git a/src/stores/neutron/virtual-adapter.js b/src/stores/neutron/virtual-adapter.js index dc3f95ac..328893af 100644 --- a/src/stores/neutron/virtual-adapter.js +++ b/src/stores/neutron/virtual-adapter.js @@ -40,13 +40,6 @@ export class VirtualAdapterStore extends Base { } }; - get paramsFuncPage() { - return (params) => { - const { current, withPrice, instanceAddresses, ...rest } = params; - return rest; - }; - } - @observable fixed_ips = new List(); @@ -114,19 +107,7 @@ export class VirtualAdapterStore extends Base { if (items.length === 0) { return items; } - const { - device_id, - device_owner, - addressAsIdKey, - network_id, - instanceAddresses, - } = filters; - if (instanceAddresses) { - items = items.map((i) => ({ - ...i, - instanceAddresses, - })); - } + const { device_id, device_owner, addressAsIdKey, network_id } = filters; if (device_owner || device_id || network_id) { // fetch fixed_ips details const details = await Promise.all(