Skip to content

Commit

Permalink
feat: publication for blueprint upgrade status SOFIE-2258 (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian authored Oct 13, 2023
1 parent 3c90669 commit 48dbda2
Show file tree
Hide file tree
Showing 26 changed files with 1,034 additions and 991 deletions.
7 changes: 7 additions & 0 deletions meteor/client/ui/Collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ export const UIPieceContentStatuses = createSyncCustomPublicationMongoCollection
export const UIBucketContentStatuses = createSyncCustomPublicationMongoCollection(
CustomCollectionName.UIBucketContentStatuses
)

/**
* Pre-processed Blueprint Upgrade statuses
*/
export const UIBlueprintUpgradeStatuses = createSyncCustomPublicationMongoCollection(
CustomCollectionName.UIBlueprintUpgradeStatuses
)
2 changes: 1 addition & 1 deletion meteor/client/ui/Settings/Migration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import * as _ from 'underscore'
import { EditAttribute, EditAttributeBase } from '../../lib/EditAttribute'
import { MeteorCall } from '../../../lib/api/methods'
import { checkForOldDataAndCleanUp } from './SystemManagement'
import { UpgradesView } from './Upgrades'
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
import { UpgradesView } from './Upgrades/View'

interface IProps {}
interface IState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { MappingsExt } from '@sofie-automation/corelib/dist/dataModel/Studio'
import { DBShowStyleBase, SourceLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
import { SelectConfigPreset } from './SelectConfigPreset'
import { SelectBlueprint } from './SelectBlueprint'
import { ShowStyleBaseId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { PubSub } from '../../../../../lib/api/pubsub'
import { useSubscription, useTracker } from '../../../../lib/ReactMeteorData/ReactMeteorData'
import { UIBlueprintUpgradeStatuses } from '../../../Collections'
import { getUpgradeStatusMessage, UpgradeStatusButtons } from '../../Upgrades/Components'

interface ShowStyleBaseBlueprintConfigurationSettingsProps {
showStyleBase: DBShowStyleBase
Expand Down Expand Up @@ -46,6 +51,8 @@ export function ShowStyleBaseBlueprintConfigurationSettings(
<SelectBlueprint showStyleBase={props.showStyleBase} />
<SelectConfigPreset showStyleBase={props.showStyleBase} />

<BlueprintUpgradeStatus showStyleBaseId={props.showStyleBase._id} />

<BlueprintConfigSchemaSettings
schema={props.schema}
translationNamespaces={translationNamespaces}
Expand All @@ -58,3 +65,31 @@ export function ShowStyleBaseBlueprintConfigurationSettings(
</>
)
}

interface BlueprintUpgradeStatusProps {
showStyleBaseId: ShowStyleBaseId
}

function BlueprintUpgradeStatus({ showStyleBaseId }: BlueprintUpgradeStatusProps): JSX.Element {
const { t } = useTranslation()

const isReady = useSubscription(PubSub.uiBlueprintUpgradeStatuses)

const status = useTracker(
() =>
UIBlueprintUpgradeStatuses.findOne({
documentId: showStyleBaseId,
documentType: 'showStyle',
}),
[showStyleBaseId]
)

const statusMessage = isReady && status ? getUpgradeStatusMessage(t, status) ?? t('OK') : t('Loading...')

return (
<p>
{t('Upgrade Status')}: {statusMessage}
{status && <UpgradeStatusButtons upgradeResult={status} />}
</p>
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useMemo } from 'react'
import { useTracker } from '../../../../lib/ReactMeteorData/react-meteor-data'
import { useSubscription, useTracker } from '../../../../lib/ReactMeteorData/react-meteor-data'
import { BlueprintManifestType } from '@sofie-automation/blueprints-integration'
import { BlueprintConfigSchemaSettings } from '../../BlueprintConfigSchema'
import {
Expand All @@ -12,6 +12,10 @@ import { useTranslation } from 'react-i18next'
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
import { SelectConfigPreset } from './SelectConfigPreset'
import { SelectBlueprint } from './SelectBlueprint'
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { PubSub } from '../../../../../lib/api/pubsub'
import { UIBlueprintUpgradeStatuses } from '../../../Collections'
import { getUpgradeStatusMessage, UpgradeStatusButtons } from '../../Upgrades/Components'

interface StudioBlueprintConfigurationSettingsProps {
studio: DBStudio
Expand Down Expand Up @@ -58,6 +62,8 @@ export function StudioBlueprintConfigurationSettings(props: StudioBlueprintConfi
<SelectBlueprint studio={props.studio} />
<SelectConfigPreset studio={props.studio} blueprint={blueprint} />

<BlueprintUpgradeStatus studioId={props.studio._id} />

<BlueprintConfigSchemaSettings
schema={configSchema}
translationNamespaces={translationNamespaces}
Expand All @@ -69,3 +75,31 @@ export function StudioBlueprintConfigurationSettings(props: StudioBlueprintConfi
</>
)
}

interface BlueprintUpgradeStatusProps {
studioId: StudioId
}

function BlueprintUpgradeStatus({ studioId }: BlueprintUpgradeStatusProps): JSX.Element {
const { t } = useTranslation()

const isReady = useSubscription(PubSub.uiBlueprintUpgradeStatuses)

const status = useTracker(
() =>
UIBlueprintUpgradeStatuses.findOne({
documentId: studioId,
documentType: 'studio',
}),
[studioId]
)

const statusMessage = isReady && status ? getUpgradeStatusMessage(t, status) ?? t('OK') : t('Loading...')

return (
<p>
{t('Upgrade Status')}: {statusMessage}
{status && <UpgradeStatusButtons upgradeResult={status} />}
</p>
)
}
254 changes: 0 additions & 254 deletions meteor/client/ui/Settings/Upgrades.tsx

This file was deleted.

Loading

0 comments on commit 48dbda2

Please sign in to comment.