From 34a41dd38dc22dafa32c1c6fd0162d2a4785ca80 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Mon, 15 Apr 2024 13:11:34 +0800 Subject: [PATCH] feat: update qos policy info For the qos policy info in the port detail page: 1. add qos policy name 2. update qos policy link for console and administrator Change-Id: Ib17f3c84aade6ce44610f379e577e676c30facb7 --- .../Port/Detail/BaseDetail/index.jsx | 19 +++++++++++-------- src/stores/neutron/port-extension.js | 10 ++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/pages/network/containers/Port/Detail/BaseDetail/index.jsx b/src/pages/network/containers/Port/Detail/BaseDetail/index.jsx index 1c079484..4a066931 100644 --- a/src/pages/network/containers/Port/Detail/BaseDetail/index.jsx +++ b/src/pages/network/containers/Port/Detail/BaseDetail/index.jsx @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import React from 'react'; -import { Link } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import Base from 'containers/BaseDetail'; import { qosEndpoint } from 'client/client/constants'; @@ -63,12 +61,17 @@ export class BaseDetail extends Base { label: t('QoS Policy'), dataIndex: 'qos_policy_id', copyable: false, - render: (data) => - data ? ( - {data} - ) : ( - '-' - ), + render: (data) => { + if (!data) { + return '-'; + } + const { qosPolicy } = this.detailData; + const { name } = qosPolicy || {}; + const displayName = name ? `${data}(${name})` : data; + return this.getLinkRender('networkQosDetail', displayName, { + id: data, + }); + }, }); } return { diff --git a/src/stores/neutron/port-extension.js b/src/stores/neutron/port-extension.js index c2db8795..f7edfe87 100644 --- a/src/stores/neutron/port-extension.js +++ b/src/stores/neutron/port-extension.js @@ -166,6 +166,16 @@ export class PortStore extends Base { }); } item.itemInList = itemContrib; + const { qos_policy_id } = item; + if (qos_policy_id) { + try { + const { policy } = await client.neutron.qosPolicies.show(qos_policy_id); + item.qosPolicy = policy; + } catch (e) { + // eslint-disable-next-line no-console + console.log('fetch qos error', e); + } + } return item; }