From fc7a65c7f018d1ac59bf6da25d3ea6894f1e5af1 Mon Sep 17 00:00:00 2001 From: Erling Hauan Date: Fri, 13 Sep 2024 12:36:25 +0200 Subject: [PATCH] add comments --- frontend/scripts/componentSchemas/languageUtils.ts | 8 ++++++-- frontend/scripts/componentSchemas/run.ts | 9 ++++----- frontend/scripts/componentSchemas/schemaUtils.ts | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/scripts/componentSchemas/languageUtils.ts b/frontend/scripts/componentSchemas/languageUtils.ts index 791d848f6c3..a137777ac1d 100644 --- a/frontend/scripts/componentSchemas/languageUtils.ts +++ b/frontend/scripts/componentSchemas/languageUtils.ts @@ -1,6 +1,8 @@ import nb from '../../language/src/nb.json'; -export const generateTextResourceLabels = (textResourceBindingKeys: string[]) => { +// Logs language keys and values related to the "Tekst" accordion in the component configuration. +// Use it to find missing entries in the language file(s). +export const logTextResourceLabels = (textResourceBindingKeys: string[]) => { textResourceBindingKeys.sort().forEach((key) => { console.log( `"ux_editor.modal_properties_textResourceBindings_${key}": "${nb['ux_editor.modal_properties_textResourceBindings_' + key] || ''}",`, @@ -11,7 +13,9 @@ export const generateTextResourceLabels = (textResourceBindingKeys: string[]) => }); }; -export const generateComponentPropertyLabels = (componentPropertyKeys: string[]) => { +// Logs various language keys and values related to the component configuration. +// Use it to find missing entries in the language file(s). +export const logComponentPropertyLabels = (componentPropertyKeys: string[]) => { componentPropertyKeys.sort().forEach((key) => { console.log( `"ux_editor.component_properties.${key}": "${nb['ux_editor.component_properties.' + key] || ''}",`, diff --git a/frontend/scripts/componentSchemas/run.ts b/frontend/scripts/componentSchemas/run.ts index 4285648e735..730e66fab17 100644 --- a/frontend/scripts/componentSchemas/run.ts +++ b/frontend/scripts/componentSchemas/run.ts @@ -2,8 +2,7 @@ import { expandAllOf, expandAnyOf, expandRefsInProperties, verifySchema } from ' import type { AppFrontendVersion } from './version'; import { isValidVersion, versionSettings } from './version'; import { getLayoutSchema } from './api'; -import { generateComponentPropertyLabels, generateTextResourceLabels } from './languageUtils'; -import {Layout} from "../configurationStats/Layout"; +import { logComponentPropertyLabels, logTextResourceLabels } from './languageUtils'; const allTextResourceBindingKeys = []; const allPropertyKeys = []; @@ -41,7 +40,7 @@ const generateComponentSchema = (name: string, layoutSchema: any) => { $schema: layoutSchema.$schema, }; - // v4 schema has external definitions. Code block needed to fetch v4 properties correctly. + // The v4 schema has external definitions. This code block is needed to fetch v4 properties correctly. const externalDefinitionName = definitionName + "External"; if (layoutSchema.definitions[externalDefinitionName].allOf) { componentSchema.allOf = layoutSchema.definitions[externalDefinitionName].allOf; @@ -116,9 +115,9 @@ const run = async () => { }); const uniqueTextResourceBindingKeys = [...new Set(allTextResourceBindingKeys)]; - generateTextResourceLabels(uniqueTextResourceBindingKeys); + logTextResourceLabels(uniqueTextResourceBindingKeys); console.log('--------------------------------------------------------'); - generateComponentPropertyLabels([...new Set(allPropertyKeys)]); + logComponentPropertyLabels([...new Set(allPropertyKeys)]); }; run(); diff --git a/frontend/scripts/componentSchemas/schemaUtils.ts b/frontend/scripts/componentSchemas/schemaUtils.ts index 28d2532dea2..3b1e29922c3 100644 --- a/frontend/scripts/componentSchemas/schemaUtils.ts +++ b/frontend/scripts/componentSchemas/schemaUtils.ts @@ -11,7 +11,6 @@ import jsonpointer from 'jsonpointer'; * @returns The expanded schema */ export const expandAllOf = (schema: any, layoutSchema: any, componentNode: boolean = true) => { - console.log("Inside expandAllOf"); const expandedSchema: any = {}; const allOfList = componentNode ? schema.allOf?.slice(0, -1) : schema.allOf; allOfList.forEach((item: any) => {