fix: fix listener info in certificate

Support multiple listeners for one certificate

Change-Id: I2f1f476236fe90293f92cf980c7e1f799b271fb1
This commit is contained in:
xusongfu 2022-06-10 15:17:19 +08:00
parent 8ed4795ece
commit 243f459ecd
4 changed files with 57 additions and 32 deletions

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import globalContainersStore, { import globalContainersStore, {
@ -104,15 +105,19 @@ export class Certificate extends Base {
dataIndex: 'listener', dataIndex: 'listener',
render: (value) => { render: (value) => {
return value return value
? this.getLinkRender( ? value.map((it) => (
'lbListenerDetail', <div>
value.name, {this.getLinkRender(
{ 'lbListenerDetail',
loadBalancerId: value.lb, it.name,
id: value.id, {
}, loadBalancerId: it.lb,
null id: it.id,
) },
null
)}
</div>
))
: '-'; : '-';
}, },
isHideable: true, isHideable: true,

View File

@ -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 = { export const operatingStatusCodes = {
ONLINE: t('Online'), ONLINE: t('Online'),
DRAINING: t('Draining'), DRAINING: t('Draining'),
@ -51,15 +67,19 @@ export const getCertificateColumns = (self) => [
dataIndex: 'listener', dataIndex: 'listener',
render: (value) => { render: (value) => {
return value return value
? self.getLinkRender( ? value.map((it) => (
'lbListenerDetail', <div>
value.name, {self.getLinkRender(
{ 'lbListenerDetail',
loadBalancerId: value.lb, it.name,
id: value.id, {
}, loadBalancerId: it.lb,
null id: it.id,
) },
null
)}
</div>
))
: '-'; : '-';
}, },
}, },

View File

@ -73,7 +73,7 @@ export class ContainersStore extends Base {
updateItem(item, listeners) { updateItem(item, listeners) {
const { container_ref } = item; const { container_ref } = item;
const enabledLs = listeners.find((ls) => { const enabledLs = listeners.filter((ls) => {
const refs = [ const refs = [
ls.default_tls_container_ref, ls.default_tls_container_ref,
ls.client_ca_tls_container_ref, ls.client_ca_tls_container_ref,
@ -81,12 +81,12 @@ export class ContainersStore extends Base {
]; ];
return refs.includes(container_ref); return refs.includes(container_ref);
}); });
if (enabledLs) { if (enabledLs.length) {
item.listener = { item.listener = enabledLs.map((ls) => ({
id: enabledLs.id, id: ls.id,
name: enabledLs.name, name: ls.name,
lb: enabledLs.lbIds[0], lb: ls.lbIds[0],
}; }));
} }
return item; return item;
} }

View File

@ -73,7 +73,7 @@ export class SecretsStore extends Base {
updateItem(item, listeners) { updateItem(item, listeners) {
const { secret_ref } = item; const { secret_ref } = item;
const enabledLs = listeners.find((ls) => { const enabledLs = listeners.filter((ls) => {
const refs = [ const refs = [
ls.default_tls_container_ref, ls.default_tls_container_ref,
ls.client_ca_tls_container_ref, ls.client_ca_tls_container_ref,
@ -81,12 +81,12 @@ export class SecretsStore extends Base {
]; ];
return refs.includes(secret_ref); return refs.includes(secret_ref);
}); });
if (enabledLs) { if (enabledLs.length) {
item.listener = { item.listener = enabledLs.map((ls) => ({
id: enabledLs.id, id: ls.id,
name: enabledLs.name, name: ls.name,
lb: enabledLs.lbIds[0], lb: ls.lbIds[0],
}; }));
} }
return item; return item;
} }