feat: add shared host note to private domain dialog with i18n

This commit is contained in:
Aiden McClelland
2026-03-04 17:40:55 -07:00
parent 4005365239
commit d982ffa722
6 changed files with 29 additions and 21 deletions

View File

@@ -132,6 +132,7 @@ export class InterfaceAddressesComponent {
}),
}),
),
note: await this.getSharedHostNote(),
buttons: [
{
text: this.i18n.transform('Save')!,
@@ -185,32 +186,12 @@ export class InterfaceAddressesComponent {
: {}),
})
let note = ''
const pkgId = this.packageId()
if (pkgId) {
const pkg = await firstValueFrom(
this.patch.watch$('packageData', pkgId),
)
if (pkg) {
const hostId = iface.addressInfo.hostId
const otherNames = Object.values(pkg.serviceInterfaces)
.filter(
si =>
si.addressInfo.hostId === hostId && si.id !== iface.id,
)
.map(si => si.name)
if (otherNames.length) {
note = `This domain also applies to ${otherNames.join(', ')}`
}
}
}
this.formDialog.open(FormComponent, {
label: 'Add public domain',
size: 's',
data: {
spec: await configBuilderToSpec(addSpec),
note,
note: await this.getSharedHostNote(),
buttons: [
{
text: this.i18n.transform('Save')!,
@@ -254,6 +235,28 @@ export class InterfaceAddressesComponent {
}
}
private async getSharedHostNote(): Promise<string> {
const iface = this.value()
const pkgId = this.packageId()
if (!iface || !pkgId) return ''
const pkg = await firstValueFrom(
this.patch.watch$('packageData', pkgId),
)
if (!pkg) return ''
const hostId = iface.addressInfo.hostId
const otherNames = Object.values(pkg.serviceInterfaces)
.filter(
si => si.addressInfo.hostId === hostId && si.id !== iface.id,
)
.map(si => si.name)
if (!otherNames.length) return ''
return `${this.i18n.transform('This domain will also apply to')} ${otherNames.join(', ')}`
}
private async savePublicDomain(
fqdn: string,
authority?: 'local' | string,