web: Replace null defaults with undefined for optional props
Aligns optional prop types and defaults with TypeScript/Svelte 5 idioms by dropping explicit null in favor of undefined throughout components.
This commit is contained in:
parent
66e85dbb13
commit
9042bd0b69
9 changed files with 24 additions and 24 deletions
|
|
@ -78,8 +78,8 @@
|
||||||
body: {
|
body: {
|
||||||
domain: domainName,
|
domain: domainName,
|
||||||
group: group || undefined,
|
group: group || undefined,
|
||||||
id_owner: id_owner || undefined,
|
id_owner: id_owner,
|
||||||
id_provider: id_provider || undefined,
|
id_provider: id_provider,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@
|
||||||
body: {
|
body: {
|
||||||
domain: domain,
|
domain: domain,
|
||||||
group: group || undefined,
|
group: group || undefined,
|
||||||
id_owner: id_owner || undefined,
|
id_owner: id_owner,
|
||||||
id_provider: id_provider || undefined,
|
id_provider: id_provider,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@
|
||||||
addingNewDomain?: boolean;
|
addingNewDomain?: boolean;
|
||||||
autofocus?: boolean;
|
autofocus?: boolean;
|
||||||
noButton?: boolean;
|
noButton?: boolean;
|
||||||
preAddFunc?: null | ((arg0: string) => Promise<boolean>);
|
preAddFunc?: (arg0: string) => Promise<boolean>;
|
||||||
provider?: Provider | null;
|
provider?: Provider;
|
||||||
value?: string;
|
value?: string;
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
@ -57,8 +57,8 @@
|
||||||
addingNewDomain = $bindable(false),
|
addingNewDomain = $bindable(false),
|
||||||
autofocus = false,
|
autofocus = false,
|
||||||
noButton = false,
|
noButton = false,
|
||||||
preAddFunc = null,
|
preAddFunc,
|
||||||
provider = null,
|
provider,
|
||||||
value = $bindable(""),
|
value = $bindable(""),
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
interface Props {
|
interface Props {
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
step: number;
|
step: number;
|
||||||
service?: ServiceCombined | null;
|
service?: ServiceCombined;
|
||||||
form?: string;
|
form?: string;
|
||||||
origin?: Domain | undefined;
|
origin?: Domain | undefined;
|
||||||
update?: boolean;
|
update?: boolean;
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
let {
|
let {
|
||||||
toggle,
|
toggle,
|
||||||
step,
|
step,
|
||||||
service = $bindable(null),
|
service = $bindable(),
|
||||||
form = "addSvcForm",
|
form = "addSvcForm",
|
||||||
origin = undefined,
|
origin = undefined,
|
||||||
update = false,
|
update = false,
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@
|
||||||
edit?: boolean;
|
edit?: boolean;
|
||||||
ptype: string;
|
ptype: string;
|
||||||
state: number;
|
state: number;
|
||||||
providerId?: string | null;
|
providerId?: string;
|
||||||
value?: ProviderSettingsState | null;
|
value?: ProviderSettingsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
@ -52,12 +52,12 @@
|
||||||
edit = false,
|
edit = false,
|
||||||
ptype,
|
ptype,
|
||||||
state: formstate,
|
state: formstate,
|
||||||
providerId = null,
|
providerId,
|
||||||
value = $bindable(null)
|
value = $bindable()
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
//
|
//
|
||||||
function createProviderForm(ptype: string, providerId: string | null, value: ProviderSettingsState | null, edit: boolean): ProviderForm {
|
function createProviderForm(ptype: string, providerId: string | undefined, value: ProviderSettingsState | undefined, edit: boolean): ProviderForm {
|
||||||
const pf = new ProviderForm(
|
const pf = new ProviderForm(
|
||||||
ptype,
|
ptype,
|
||||||
() => refreshProviders().then(() => navigate("/?newProvider")),
|
() => refreshProviders().then(() => navigate("/?newProvider")),
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
interface Props {
|
interface Props {
|
||||||
canDoNext?: boolean;
|
canDoNext?: boolean;
|
||||||
edit?: boolean;
|
edit?: boolean;
|
||||||
form?: CustomForm | null;
|
form?: CustomForm;
|
||||||
nextInProgress?: boolean;
|
nextInProgress?: boolean;
|
||||||
previousInProgress?: boolean;
|
previousInProgress?: boolean;
|
||||||
submitForm?: string;
|
submitForm?: string;
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
let {
|
let {
|
||||||
canDoNext = true,
|
canDoNext = true,
|
||||||
edit = false,
|
edit = false,
|
||||||
form = null,
|
form,
|
||||||
nextInProgress = false,
|
nextInProgress = false,
|
||||||
previousInProgress = false,
|
previousInProgress = false,
|
||||||
submitForm,
|
submitForm,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: ClassValue;
|
class?: ClassValue;
|
||||||
service: HappydnsService | null;
|
service?: HappydnsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { service, class: className = "" }: Props = $props();
|
let { service, class: className = "" }: Props = $props();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
import { controls as ctrlServiceDetails } from "../ServiceDetailsOffcanvas.svelte";
|
import { controls as ctrlServiceDetails } from "../ServiceDetailsOffcanvas.svelte";
|
||||||
import { controls as ctrlServicePath } from "$lib/components/services/NewServicePath.svelte";
|
import { controls as ctrlServicePath } from "$lib/components/services/NewServicePath.svelte";
|
||||||
import type { Domain } from "$lib/model/domain";
|
import type { Domain } from "$lib/model/domain";
|
||||||
import type { ServiceCombined } from "$lib/model/service.svelte";
|
import type { HappydnsService } from "$lib/api-base/types.gen";
|
||||||
import { servicesSpecs, servicesSpecsLoaded } from "$lib/stores/services";
|
import { servicesSpecs, servicesSpecsLoaded } from "$lib/stores/services";
|
||||||
import { t } from "$lib/translations";
|
import { t } from "$lib/translations";
|
||||||
import PropagationCountdown from "$lib/components/services/PropagationCountdown.svelte";
|
import PropagationCountdown from "$lib/components/services/PropagationCountdown.svelte";
|
||||||
|
|
@ -45,11 +45,11 @@
|
||||||
interface Props {
|
interface Props {
|
||||||
dn: string;
|
dn: string;
|
||||||
origin: Domain;
|
origin: Domain;
|
||||||
service?: ServiceCombined | null;
|
service?: HappydnsService;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { dn, origin, service = $bindable(null), zoneId }: Props = $props();
|
let { dn, origin, service, zoneId }: Props = $props();
|
||||||
|
|
||||||
// Will be changed by PropagationCountdown
|
// Will be changed by PropagationCountdown
|
||||||
let isPropagating = $state(true);
|
let isPropagating = $state(true);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
let svcType: string = $derived(page.url.searchParams.get("type") ?? "");
|
let svcType: string = $derived(page.url.searchParams.get("type") ?? "");
|
||||||
|
|
||||||
let service: HappydnsService | null = $state(null);
|
let service: HappydnsService | undefined = $state();
|
||||||
let serviceLoading = $state(false);
|
let serviceLoading = $state(false);
|
||||||
|
|
||||||
let serviceTitle = $derived.by(() => {
|
let serviceTitle = $derived.by(() => {
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (data.serviceid !== "new") {
|
if (data.serviceid !== "new") {
|
||||||
const svcs = $thisZone?.services[data.subdomain];
|
const svcs = $thisZone?.services[data.subdomain];
|
||||||
service = svcs?.find((s) => s._id === data.serviceid) ?? null;
|
service = svcs?.find((s) => s._id === data.serviceid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function helpLink(svc: HappydnsService | null): string {
|
function helpLink(svc: HappydnsService | undefined): string {
|
||||||
if (!svc?._svctype) return "";
|
if (!svc?._svctype) return "";
|
||||||
const svcPart = svc._svctype.toLowerCase().split(".");
|
const svcPart = svc._svctype.toLowerCase().split(".");
|
||||||
let path = svcPart[svcPart.length - 1] + "/";
|
let path = svcPart[svcPart.length - 1] + "/";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue