Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: blueprint settings overhaul #878

Merged
merged 92 commits into from Mar 29, 2023
Merged

Conversation

Julusian
Copy link
Member

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Feature

Builds on #837, as it shares a lot of the JSONSchema work from there.

  • What is the current behavior? (You can also link to an open issue here)

Blueprint configuration has for a long time been using our custom ConfigManifest types.

  • What is the new behavior (if this is a feature change)?

This has been replaced with using JSONSchema, allowing us to generate typescript interfaces and describe the structure for the UI in one place. This puts us almost competely at having one unified way of describing these UIs from outside of the main codebase.

To help with managing the growing number of blueprint-configuration fields, it is now possible to assign a property to a category.

With this the look of the blueprint-configuration page has changed, and is now more similar to how the other schema-form derived UI's look.

image

Additionally, it is now possible to define tables which allow for the values to be granularly overridden. The old way works for compatibility reasons, but by defining the property as an object, it is possible to get the same granular behaviour we have for source-layers/mappings for the table rows.
For example:

"SomeProperties": {
    "type": "object",
    "ui:category": "Test",
    "ui:title": "Test Table",
    "ui:description": "",
    "patternProperties": {
        "": {
            "type": "object",
            "title": "MyInterface",
            "properties": {
                "number": {
                    "type": "integer",
                    "ui:title": "Number",
                    "ui:description": "Camera number",
                    "ui:summaryTitle": "Number",
                    "default": 1,
                    "min": 0
                },
                "port": {
                    "type": "integer",
                    "ui:title": "Port",
                    "ui:description": "ATEM Port",
                    "default": 1,
                    "min": 0
                },
            },
            "required": ["number", "port"],
            "additionalProperties": false
        }
    },
    "additionalProperties": false
},

Further details on the supported json-schema features are in the documentation.

  • Other information:

There is one place remaining using the ConfigManifest types, for adlib-actions with editable fields. This should be converted across soon, to allow the remaining ConfigManifest code to be cleaned up.

In our blueprints we are building the typescript interfaces from the schema with the script below.
Some work will be required to convert blueprint config to have a schema to expose, with some minor optional work to update imports for any types generated from this schema, and fixing up any unit tests which were generating config objects based on the old config manifest.
We did not need to touch any of the main blueprint code, as the typings generated are identical to before.

import { compileFromFile } from 'json-schema-to-typescript'
import * as fs from 'fs/promises'

/** ********************************************************
 *
 * This script goes through the json-schemas of all devices (located under /$schemas )
 * and auto-generates types for those schemas
 *
 ***********************************************************/
const BANNER =
	'/* eslint-disable */\n/**\n * This file was automatically generated by json-schema-to-typescript.\n * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,\n * and run "yarn generate-schema-types" to regenerate this file.\n */\n'

const PrettierConf = JSON.parse(
	await fs.readFile('./node_modules/@sofie-automation/code-standard-preset/.prettierrc.json')
)

// convert main-showStyle-config options
try {
	const schema = await compileFromFile('./src/$schemas/main-showStyle-config.json', {
		additionalProperties: false,
		style: PrettierConf,
		bannerComment: '',
		enableConstEnums: false,
	})

	await fs.writeFile('./src/generated/main-showStyle-config.ts', BANNER + '\n' + schema)
} catch (e) {
	console.error('Error while generating main-showStyle-config.json, continuing...')
	console.error(e)
}

// convert main-studio-config options
try {
	const schema = await compileFromFile('./src/$schemas/main-studio-config.json', {
		additionalProperties: false,
		style: PrettierConf,
		bannerComment: '',
		enableConstEnums: false,
	})

	await fs.writeFile('./src/generated/main-studio-config.ts', BANNER + '\n' + schema)
} catch (e) {
	console.error('Error while generating main-studio-config.json, continuing...')
	console.error(e)
}

Status

  • Code documentation for the relevant parts in the code have been added/updated by the PR author
  • The functionality has been tested by the PR author
  • The functionality has been tested by NRK

@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2023

Codecov Report

Patch coverage: 96.89% and project coverage change: +0.25 🎉

Comparison is base (fb8f1c3) 59.30% compared to head (3e3d2ea) 59.55%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@              Coverage Diff              @@
##           release50     #878      +/-   ##
=============================================
+ Coverage      59.30%   59.55%   +0.25%     
=============================================
  Files            468      467       -1     
  Lines          71384    71103     -281     
  Branches        3626     3634       +8     
=============================================
+ Hits           42333    42347      +14     
+ Misses         29000    28706     -294     
+ Partials          51       50       -1     
Impacted Files Coverage Δ
packages/job-worker/src/blueprints/config.ts 100.00% <ø> (+8.74%) ⬆️
...ckages/corelib/src/settings/objectWithOverrides.ts 80.68% <80.00%> (-0.17%) ⬇️
meteor/lib/jsonSchemaUtil.ts 93.87% <93.87%> (ø)
meteor/lib/api/rundown.ts 100.00% <100.00%> (ø)
meteor/lib/lib.ts 81.59% <100.00%> (+1.13%) ⬆️
meteor/server/api/blueprints/api.ts 83.87% <100.00%> (-0.21%) ⬇️
meteor/server/api/rundown.ts 29.81% <100.00%> (+10.09%) ⬆️
meteor/server/coreSystem/index.ts 100.00% <100.00%> (ø)
meteor/server/migration/upgrades/checkStatus.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Julusian Julusian requested a review from a team March 13, 2023 15:46
…-overhaul

# Conflicts:
#	meteor/client/ui/Settings/StudioSettings.tsx
#	meteor/server/coreSystem/checkBlueprintsConfig.ts
#	packages/playout-gateway/package.json
#	packages/shared-lib/package.json
#	packages/yarn.lock
Base automatically changed from feat/gateways-json-schema to release50 March 21, 2023 19:16
# Conflicts:
#	meteor/client/lib/forms/schemaFormForCollection.tsx
#	meteor/client/lib/forms/schemaFormInPlace.tsx
#	meteor/client/lib/forms/schemaFormUtil.tsx
#	meteor/client/lib/forms/schemaFormWithOverrides.tsx
#	meteor/client/ui/Settings/StudioSettings.tsx
#	meteor/client/ui/Settings/components/ConfigManifestEntryComponent.tsx
#	meteor/client/ui/Settings/components/DeviceConfigSchemaSettings.tsx
#	meteor/client/ui/Settings/util/OverrideOpHelper.tsx
#	meteor/client/ui/Shelf/Inspector/ItemRenderers/ActionItemRenderer.tsx
#	meteor/yarn.lock
#	packages/documentation/docs/for-developers/json-config-schema.md
@jstarpl jstarpl changed the title Feat/blueprint settings overhaul feat: blueprint settings overhaul Mar 22, 2023
@github-actions
Copy link

github-actions bot commented Mar 22, 2023

⚡ Published prerelease version server-core-integration@1.50.0-nightly-release50-20230321-191558-fb8f1c3.0 to NPM

meteor/client/lib/forms/schemaFormTableArray.tsx Outdated Show resolved Hide resolved
meteor/client/lib/forms/schemaFormTableArray.tsx Outdated Show resolved Hide resolved
meteor/client/lib/forms/schemaFormTableObject.tsx Outdated Show resolved Hide resolved
meteor/client/lib/forms/schemaFormTableArray.tsx Outdated Show resolved Hide resolved
meteor/client/lib/forms/schemaFormTableArray.tsx Outdated Show resolved Hide resolved
meteor/client/ui/Settings/Studio/Generic.tsx Outdated Show resolved Hide resolved
meteor/lib/jsonSchemaUtil.ts Outdated Show resolved Hide resolved
@Julusian Julusian merged commit ee3307c into release50 Mar 29, 2023
48 checks passed
@Julusian Julusian deleted the feat/blueprint-settings-overhaul branch March 29, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants