1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

fix(ingress): update ingress tls after deletion EE-4387 (#7804)

* fix(ing): update tls value EE-4387
This commit is contained in:
Ali 2022-10-10 09:32:30 +13:00 committed by GitHub
parent 56087bcbb3
commit c6ae8467c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -190,13 +190,16 @@ export function CreateIngressView() {
config.SecretType === 'kubernetes.io/tls' && config.SecretType === 'kubernetes.io/tls' &&
config.Namespace === namespace config.Namespace === namespace
); );
const tlsOptions: Option<string>[] = [ const tlsOptions: Option<string>[] = useMemo(
{ label: 'No TLS', value: '' }, () => [
...(matchedConfigs?.map((config) => ({ { label: 'No TLS', value: '' },
label: config.Name, ...(matchedConfigs?.map((config) => ({
value: config.Name, label: config.Name,
})) || []), value: config.Name,
]; })) || []),
],
[matchedConfigs]
);
useEffect(() => { useEffect(() => {
if ( if (
@ -226,6 +229,19 @@ export function CreateIngressView() {
params.namespace, params.namespace,
]); ]);
useEffect(() => {
// for each host, if the tls selection doesn't exist as an option, change it to the first option
if (ingressRule?.Hosts?.length) {
ingressRule.Hosts.forEach((host, hIndex) => {
const secret = host.Secret || '';
const tlsOptionVals = tlsOptions.map((o) => o.value);
if (tlsOptions?.length && !tlsOptionVals?.includes(secret)) {
handleTLSChange(hIndex, tlsOptionVals[0]);
}
});
}
}, [tlsOptions, ingressRule.Hosts]);
useEffect(() => { useEffect(() => {
// for each path in each host, if the service port doesn't exist as an option, change it to the first option // for each path in each host, if the service port doesn't exist as an option, change it to the first option
if (ingressRule?.Hosts?.length) { if (ingressRule?.Hosts?.length) {