Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ErlingHauan committed Sep 13, 2024
1 parent 480706e commit fc7a65c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 6 additions & 2 deletions frontend/scripts/componentSchemas/languageUtils.ts
Original file line number Diff line number Diff line change
@@ -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] || ''}",`,
Expand All @@ -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] || ''}",`,
Expand Down
9 changes: 4 additions & 5 deletions frontend/scripts/componentSchemas/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
1 change: 0 additions & 1 deletion frontend/scripts/componentSchemas/schemaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit fc7a65c

Please sign in to comment.