Skip to content

Commit 95c709d

Browse files
authored
Fix subdomain name duplicates (#4266)
* Fix subdomains name duplicates * Update the subdomain name when tab changes * Refactor the watch when dialog fire and when the tab change * Append random suffix to the subdomain name * Replace the watcher with event approach
1 parent 000977b commit 95c709d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/playground/src/components/manage_gateway_dialog.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
>
1010
<weblet-layout ref="layout" @back="onBack">
1111
<template #title> Manage Domains ({{ vm ? vm.name : k8s?.masters[0].name }}) </template>
12-
<v-tabs v-model="gatewayTab" align-tabs="center" color="secondary" class="mb-6" :disabled="deleting">
12+
<v-tabs
13+
v-model="gatewayTab"
14+
align-tabs="center"
15+
color="secondary"
16+
class="mb-6"
17+
:disabled="deleting"
18+
@update:model-value="onTabChange"
19+
>
1320
<v-tab>Domains List</v-tab>
1421
<v-tab>Add new domain</v-tab>
1522
</v-tabs>
@@ -294,6 +301,13 @@ export default {
294301
return networks.value.find(net => net.value === selectedIPAddress.value)?.title === NetworkInterfaces.WireGuard;
295302
});
296303
watch(selectedK8SNodeName, getSupportedNetworks, { deep: true });
304+
305+
function onTabChange(newTab: unknown) {
306+
if (newTab === 1) {
307+
suggestName();
308+
}
309+
}
310+
297311
const tableHeaders = ref([
298312
{ title: "Name", key: "name" },
299313
{ title: "Contract ID", key: "contractId" },
@@ -507,7 +521,8 @@ export default {
507521
grid.config.twinId;
508522
prefix.value = oldPrefix.value + props.vm.name;
509523
}
510-
subdomain.value = generateName({ prefix: prefix.value }, 4).toLowerCase();
524+
const randomSuffix = generateName({}, 2);
525+
subdomain.value = `${prefix.value}${randomSuffix}`.toLowerCase();
511526
}
512527
513528
const subdomainRules = [
@@ -551,6 +566,7 @@ export default {
551566
getSupportedNetworks,
552567
formatDomainName,
553568
onBack,
569+
onTabChange,
554570
getDomainNode,
555571
tableHeaders,
556572
subdomainRules,

0 commit comments

Comments
 (0)