From 243f459ecd290c90686134a204e939119099537e Mon Sep 17 00:00:00 2001 From: xusongfu Date: Fri, 10 Jun 2022 15:17:19 +0800 Subject: [PATCH] fix: fix listener info in certificate Support multiple listeners for one certificate Change-Id: I2f1f476236fe90293f92cf980c7e1f799b271fb1 --- .../containers/Certificate/Certificate.jsx | 23 ++++++----- src/resources/octavia/{lb.js => lb.jsx} | 38 ++++++++++++++----- src/stores/barbican/containers.js | 14 +++---- src/stores/barbican/secrets.js | 14 +++---- 4 files changed, 57 insertions(+), 32 deletions(-) rename src/resources/octavia/{lb.js => lb.jsx} (69%) diff --git a/src/pages/network/containers/Certificate/Certificate.jsx b/src/pages/network/containers/Certificate/Certificate.jsx index d77c4305..30f7adb1 100644 --- a/src/pages/network/containers/Certificate/Certificate.jsx +++ b/src/pages/network/containers/Certificate/Certificate.jsx @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React from 'react'; import { observer, inject } from 'mobx-react'; import Base from 'containers/List'; import globalContainersStore, { @@ -104,15 +105,19 @@ export class Certificate extends Base { dataIndex: 'listener', render: (value) => { return value - ? this.getLinkRender( - 'lbListenerDetail', - value.name, - { - loadBalancerId: value.lb, - id: value.id, - }, - null - ) + ? value.map((it) => ( +
+ {this.getLinkRender( + 'lbListenerDetail', + it.name, + { + loadBalancerId: it.lb, + id: it.id, + }, + null + )} +
+ )) : '-'; }, isHideable: true, diff --git a/src/resources/octavia/lb.js b/src/resources/octavia/lb.jsx similarity index 69% rename from src/resources/octavia/lb.js rename to src/resources/octavia/lb.jsx index 875972cf..7f8d0057 100644 --- a/src/resources/octavia/lb.js +++ b/src/resources/octavia/lb.jsx @@ -1,3 +1,19 @@ +// Copyright 2022 99cloud +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import React from 'react'; + export const operatingStatusCodes = { ONLINE: t('Online'), DRAINING: t('Draining'), @@ -51,15 +67,19 @@ export const getCertificateColumns = (self) => [ dataIndex: 'listener', render: (value) => { return value - ? self.getLinkRender( - 'lbListenerDetail', - value.name, - { - loadBalancerId: value.lb, - id: value.id, - }, - null - ) + ? value.map((it) => ( +
+ {self.getLinkRender( + 'lbListenerDetail', + it.name, + { + loadBalancerId: it.lb, + id: it.id, + }, + null + )} +
+ )) : '-'; }, }, diff --git a/src/stores/barbican/containers.js b/src/stores/barbican/containers.js index 23cc848d..b7350014 100644 --- a/src/stores/barbican/containers.js +++ b/src/stores/barbican/containers.js @@ -73,7 +73,7 @@ export class ContainersStore extends Base { updateItem(item, listeners) { const { container_ref } = item; - const enabledLs = listeners.find((ls) => { + const enabledLs = listeners.filter((ls) => { const refs = [ ls.default_tls_container_ref, ls.client_ca_tls_container_ref, @@ -81,12 +81,12 @@ export class ContainersStore extends Base { ]; return refs.includes(container_ref); }); - if (enabledLs) { - item.listener = { - id: enabledLs.id, - name: enabledLs.name, - lb: enabledLs.lbIds[0], - }; + if (enabledLs.length) { + item.listener = enabledLs.map((ls) => ({ + id: ls.id, + name: ls.name, + lb: ls.lbIds[0], + })); } return item; } diff --git a/src/stores/barbican/secrets.js b/src/stores/barbican/secrets.js index a5ebaddf..dad52682 100644 --- a/src/stores/barbican/secrets.js +++ b/src/stores/barbican/secrets.js @@ -73,7 +73,7 @@ export class SecretsStore extends Base { updateItem(item, listeners) { const { secret_ref } = item; - const enabledLs = listeners.find((ls) => { + const enabledLs = listeners.filter((ls) => { const refs = [ ls.default_tls_container_ref, ls.client_ca_tls_container_ref, @@ -81,12 +81,12 @@ export class SecretsStore extends Base { ]; return refs.includes(secret_ref); }); - if (enabledLs) { - item.listener = { - id: enabledLs.id, - name: enabledLs.name, - lb: enabledLs.lbIds[0], - }; + if (enabledLs.length) { + item.listener = enabledLs.map((ls) => ({ + id: ls.id, + name: ls.name, + lb: ls.lbIds[0], + })); } return item; }