Fix workflow limit empty values being set to 0
(#795)
* default to null * pass undefined for removing values * handle 0 default
This commit is contained in:
parent
9500fd97fa
commit
9a1c2ba871
@ -63,19 +63,28 @@ export class ConfigDetails extends LiteElement {
|
|||||||
const renderTimeLimit = (
|
const renderTimeLimit = (
|
||||||
valueSeconds?: number | null,
|
valueSeconds?: number | null,
|
||||||
fallbackValue?: number
|
fallbackValue?: number
|
||||||
) =>
|
) => {
|
||||||
valueSeconds
|
if (valueSeconds) {
|
||||||
? RelativeDuration.humanize(valueSeconds * 1000, { verbose: true })
|
return RelativeDuration.humanize(valueSeconds * 1000, {
|
||||||
: typeof fallbackValue === "number"
|
|
||||||
? html`<span class="text-neutral-400"
|
|
||||||
>${fallbackValue === Infinity
|
|
||||||
? msg("Unlimited")
|
|
||||||
: RelativeDuration.humanize(fallbackValue * 1000, {
|
|
||||||
verbose: true,
|
verbose: true,
|
||||||
})}
|
});
|
||||||
${msg("(default)")}</span
|
}
|
||||||
>`
|
if (typeof fallbackValue === "number") {
|
||||||
: undefined;
|
let value = "";
|
||||||
|
if (fallbackValue === Infinity) {
|
||||||
|
value = msg("Unlimited");
|
||||||
|
} else if (fallbackValue === 0) {
|
||||||
|
value = msg("0 seconds");
|
||||||
|
} else {
|
||||||
|
value = RelativeDuration.humanize(fallbackValue * 1000, {
|
||||||
|
verbose: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return html`<span class="text-neutral-400"
|
||||||
|
>${value} ${msg("(default)")}</span
|
||||||
|
>`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<section id="crawler-settings" class="mb-8">
|
<section id="crawler-settings" class="mb-8">
|
||||||
|
@ -150,7 +150,7 @@ const getDefaultFormState = (): FormState => ({
|
|||||||
pageExtraDelaySeconds: null,
|
pageExtraDelaySeconds: null,
|
||||||
scopeType: "host",
|
scopeType: "host",
|
||||||
exclusions: [],
|
exclusions: [],
|
||||||
pageLimit: undefined,
|
pageLimit: null,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
blockAds: true,
|
blockAds: true,
|
||||||
lang: undefined,
|
lang: undefined,
|
||||||
@ -1810,8 +1810,12 @@ https://archiveweb.page/images/${"logo.svg"}`}
|
|||||||
value = elem.value;
|
value = elem.value;
|
||||||
break;
|
break;
|
||||||
case "sl-input": {
|
case "sl-input": {
|
||||||
if ((elem as SlInput).type === "number" && elem.value !== "") {
|
if ((elem as SlInput).type === "number") {
|
||||||
|
if (elem.value === "") {
|
||||||
|
value = null;
|
||||||
|
} else {
|
||||||
value = +elem.value;
|
value = +elem.value;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
value = elem.value;
|
value = elem.value;
|
||||||
}
|
}
|
||||||
@ -2034,16 +2038,16 @@ https://archiveweb.page/images/${"logo.svg"}`}
|
|||||||
schedule: this.formState.scheduleType === "cron" ? this.utcSchedule : "",
|
schedule: this.formState.scheduleType === "cron" ? this.utcSchedule : "",
|
||||||
crawlTimeout: this.formState.crawlTimeoutMinutes
|
crawlTimeout: this.formState.crawlTimeoutMinutes
|
||||||
? this.formState.crawlTimeoutMinutes * 60
|
? this.formState.crawlTimeoutMinutes * 60
|
||||||
: 0,
|
: null,
|
||||||
tags: this.formState.tags,
|
tags: this.formState.tags,
|
||||||
config: {
|
config: {
|
||||||
...(this.jobType === "seed-crawl"
|
...(this.jobType === "seed-crawl"
|
||||||
? this.parseSeededConfig()
|
? this.parseSeededConfig()
|
||||||
: this.parseUrlListConfig()),
|
: this.parseUrlListConfig()),
|
||||||
behaviorTimeout: +(this.formState.behaviorTimeoutSeconds || ""),
|
behaviorTimeout: this.formState.behaviorTimeoutSeconds,
|
||||||
pageLoadTimeout: +(this.formState.pageLoadTimeoutSeconds || ""),
|
pageLoadTimeout: this.formState.pageLoadTimeoutSeconds,
|
||||||
pageExtraDelay: +(this.formState.pageExtraDelaySeconds || ""),
|
pageExtraDelay: this.formState.pageExtraDelaySeconds,
|
||||||
limit: this.formState.pageLimit ? +this.formState.pageLimit : undefined,
|
limit: this.formState.pageLimit,
|
||||||
lang: this.formState.lang || "",
|
lang: this.formState.lang || "",
|
||||||
blockAds: this.formState.blockAds,
|
blockAds: this.formState.blockAds,
|
||||||
exclude: trimArray(this.formState.exclusions),
|
exclude: trimArray(this.formState.exclusions),
|
||||||
|
Loading…
Reference in New Issue
Block a user