diff --git a/frontend/package.json b/frontend/package.json index c69e07d0..a68c7b84 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -83,6 +83,7 @@ "thread-loader": "^4.0.4", "ts-loader": "^9.2.6", "tsconfig-paths-webpack-plugin": "^4.1.0", + "type-fest": "^4.39.1", "typescript": "^5.3.3", "update-dotenv": "^1.1.1", "url-pattern": "^1.0.3", diff --git a/frontend/src/pages/org/settings/components/crawling-defaults.ts b/frontend/src/pages/org/settings/components/crawling-defaults.ts index a744537f..a0ae5f47 100644 --- a/frontend/src/pages/org/settings/components/crawling-defaults.ts +++ b/frontend/src/pages/org/settings/components/crawling-defaults.ts @@ -7,6 +7,7 @@ import { css, html, type TemplateResult } from "lit"; import { customElement, query, state } from "lit/decorators.js"; import { guard } from "lit/directives/guard.js"; import { ifDefined } from "lit/directives/if-defined.js"; +import type { Entries } from "type-fest"; import { BtrixElement } from "@/classes/BtrixElement"; import type { LanguageSelect } from "@/components/ui/language-select"; @@ -86,7 +87,7 @@ export class OrgSettingsCrawlWorkflows extends BtrixElement { return html` ${this.renderWorkflowDefaults()} `; } - get fields(): Partial>> { + get fields() { const orgDefaults: Partial = this.org ?.crawlingDefaults || { exclude: PLACEHOLDER_EXCLUSIONS, @@ -269,7 +270,7 @@ export class OrgSettingsCrawlWorkflows extends BtrixElement { limits, behaviors, browserSettings, - } as const; + } as const satisfies Partial>>; } private renderWorkflowDefaults() { @@ -277,18 +278,22 @@ export class OrgSettingsCrawlWorkflows extends BtrixElement {
${guard([this.defaults, this.org], () => - Object.entries(this.fields).map(([sectionName, fields]) => - section( - sectionName as SectionsEnum, - Object.entries(fields) - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - .filter(([, field]) => field) - .map(([fieldName, field]) => [ - field, - infoTextFor[fieldName as keyof typeof infoTextFor], - ]), - ), - ), + Object.entries(this.fields).map(([sectionName, fields]) => { + const cols: Cols = []; + + (Object.entries(fields) as Entries).forEach( + ([fieldName, field]) => { + if (field) { + cols.push([ + field, + infoTextFor[fieldName as keyof typeof infoTextFor], + ]); + } + }, + ); + + return section(sectionName as SectionsEnum, cols); + }), )}