Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Oct 8, 2024
1 parent e839b97 commit 752a30a
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 107 deletions.
2 changes: 1 addition & 1 deletion meteor/server/api/userActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ class ServerUserActionAPI
async () => {
check(studioId, String)
check(routeSetId, String)
check(state, Boolean)
check(state, Match.OneOf('toggle', Boolean))

const access = await StudioContentWriteAccess.routeSet(this, studioId)
return ServerPlayoutAPI.switchRouteSet(access, routeSetId, state)
Expand Down
51 changes: 0 additions & 51 deletions meteor/server/migration/1_42_0.ts

This file was deleted.

41 changes: 24 additions & 17 deletions meteor/server/migration/X_X_X.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
id: `convert routesets to ObjectWithOverrides`,
canBeRunAutomatically: true,
validate: async () => {
const studios = await Studios.findFetchAsync({ routeSets: { $exists: true } })
const studios = await Studios.findFetchAsync({
routeSets: { $exists: true },
routeSetsWithOverrides: { $exists: false },
})

for (const studio of studios) {
//@ts-expect-error routeSets is not typed as ObjectWithOverrides
Expand All @@ -31,15 +34,16 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
return false
},
migrate: async () => {
const studios = await Studios.findFetchAsync({ routeSets: { $exists: true } })
const studios = await Studios.findFetchAsync({
routeSets: { $exists: true },
routeSetsWithOverrides: { $exists: false },
})

for (const studio of studios) {
//@ts-expect-error routeSets is not typed as ObjectWithOverrides
if (!studio.routeSets) continue
//@ts-expect-error routeSets is not typed as ObjectWithOverrides
const oldRouteSets = studio.routeSets as any as Record<string, StudioRouteSet>
//@ts-expect-error routeSets is typed as Record<string, StudioRouteSet>
const oldRouteSets = studio.routeSets

const newRouteSets = convertObjectIntoOverrides(oldRouteSets)
const newRouteSets = convertObjectIntoOverrides<StudioRouteSet>(oldRouteSets || {})

await Studios.updateAsync(studio._id, {
$set: {
Expand All @@ -56,7 +60,10 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
id: `convert routeSetExclusivityGroups to ObjectWithOverrides`,
canBeRunAutomatically: true,
validate: async () => {
const studios = await Studios.findFetchAsync({ routeSetExclusivityGroups: { $exists: true } })
const studios = await Studios.findFetchAsync({
routeSetExclusivityGroups: { $exists: true },
routeSetExclusivityGroupsWithOverrides: { $exists: false },
})

for (const studio of studios) {
//@ts-expect-error routeSetExclusivityGroups is not typed as ObjectWithOverrides
Expand All @@ -68,18 +75,18 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
return false
},
migrate: async () => {
const studios = await Studios.findFetchAsync({ routeSetExclusivityGroups: { $exists: true } })
const studios = await Studios.findFetchAsync({
routeSetExclusivityGroups: { $exists: true },
routeSetExclusivityGroupsWithOverrides: { $exists: false },
})

for (const studio of studios) {
//@ts-expect-error routeSetExclusivityGroups is not typed as ObjectWithOverrides
if (!studio.routeSetExclusivityGroups) return
//@ts-expect-error routeSetExclusivityGroups is not typed as ObjectWithOverrides
const oldRouteSetExclusivityGroups = studio.routeSetExclusivityGroups as any as Record<
string,
StudioRouteSetExclusivityGroup
>
//@ts-expect-error routeSets is typed as Record<string, StudioRouteSetExclusivityGroup>
const oldRouteSetExclusivityGroups = studio.routeSetExclusivityGroups

const newRouteSetExclusivityGroups = convertObjectIntoOverrides(oldRouteSetExclusivityGroups)
const newRouteSetExclusivityGroups = convertObjectIntoOverrides<StudioRouteSetExclusivityGroup>(
oldRouteSetExclusivityGroups || {}
)

await Studios.updateAsync(studio._id, {
$set: {
Expand Down
3 changes: 1 addition & 2 deletions meteor/server/migration/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ addSteps1_40_0()
import { addSteps as addSteps1_41_0 } from './1_41_0'
addSteps1_41_0()

import { addSteps as addSteps1_42_0 } from './1_42_0'
addSteps1_42_0()
// Note: There where no migrations for Release 42

import { addSteps as addSteps1_44_0 } from './1_44_0'
addSteps1_44_0()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface IActionExecutionContext
queuePart(part: IBlueprintPart, pieces: IBlueprintPiece[]): Promise<IBlueprintPartInstance>

/** Switch RouteSet State*/
switchRouteSet(routeSetId: string, state: boolean): Promise<void>
switchRouteSet(routeSetId: string, state: boolean | 'toggle'): Promise<void>
/** Misc actions */
// updateAction(newManifest: Pick<IBlueprintAdLibActionManifest, 'description' | 'payload'>): void // only updates itself. to allow for the next one to do something different
// executePeripheralDeviceAction(deviceId: string, functionName: string, args: any[]): Promise<any>
Expand Down
2 changes: 1 addition & 1 deletion packages/blueprints-integration/src/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export interface ISwitchRouteSetAction extends ITriggeredActionBase {
action: PlayoutActions.switchRouteSet
filterChain: (IRundownPlaylistFilterLink | IGUIContextFilterLink)[]
routeSetId: string
state: boolean
state: boolean | 'toggle'
}

export interface ITakeAction extends ITriggeredActionBase {
Expand Down
2 changes: 1 addition & 1 deletion packages/job-worker/src/blueprints/context/adlibActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class ActionExecutionContext extends ShowStyleUserContext implements IAct
partInstance.blockTakeUntil(time)
}

async switchRouteSet(routeSetId: string, state: boolean): Promise<void> {
async switchRouteSet(routeSetId: string, state: boolean | 'toggle'): Promise<void> {
this._playoutModel.switchRouteSet(routeSetId, state)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/job-worker/src/playout/model/PlayoutModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export interface PlayoutModel extends PlayoutModelReadonly, StudioPlayoutModelBa
* @param routeSetId
* @param isActive
*/
switchRouteSet(routeSetId: string, isActive: boolean): void
switchRouteSet(routeSetId: string, isActive: boolean | 'toggle'): void

/**
* Clear the currently selected PartInstances, so that nothing is selected for playback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
return partInstance
}

switchRouteSet(routeSetId: string, isActive: boolean): void {
switchRouteSet(routeSetId: string, isActive: boolean | 'toggle'): void {
this.#baselineHelper.updateRouteSetActive(routeSetId, isActive)
}

Expand Down
26 changes: 16 additions & 10 deletions packages/job-worker/src/playout/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { BlueprintMapping, BlueprintMappings, JSONBlobParse, TSR } from '@sofie-automation/blueprints-integration'
import {
BlueprintMapping,
BlueprintMappings,
JSONBlobParse,
StudioRouteBehavior,
TSR,
} from '@sofie-automation/blueprints-integration'
import {
MappingsExt,
StudioIngestDevice,
Expand Down Expand Up @@ -70,23 +76,23 @@ export async function handleBlueprintUpgradeForStudio(context: JobContext, _data
])
)
const routeSets = Object.fromEntries(
Object.entries<unknown>(result.routeSets ?? {}).map((dev) => [
Object.entries<Partial<StudioRouteSet>>(result.routeSets ?? {}).map((dev) => [
dev[0],
literal<Complete<StudioRouteSet>>({
name: (dev[1] as StudioRouteSet).name ?? '',
active: (dev[1] as StudioRouteSet).active ?? false,
defaultActive: (dev[1] as StudioRouteSet).defaultActive ?? false,
behavior: (dev[1] as StudioRouteSet).behavior ?? {},
exclusivityGroup: (dev[1] as StudioRouteSet).exclusivityGroup ?? undefined,
routes: (dev[1] as StudioRouteSet).routes,
name: dev[1].name ?? '',
active: dev[1].active ?? false,
defaultActive: dev[1].defaultActive ?? false,
behavior: dev[1].behavior ?? StudioRouteBehavior.TOGGLE,
exclusivityGroup: dev[1].exclusivityGroup ?? undefined,
routes: dev[1].routes ?? [],
}),
])
)
const routeSetExclusivityGroups = Object.fromEntries(
Object.entries<unknown>(result.routeSetExclusivityGroups ?? {}).map((dev) => [
Object.entries<Partial<StudioRouteSetExclusivityGroup>>(result.routeSetExclusivityGroups ?? {}).map((dev) => [
dev[0],
literal<Complete<StudioRouteSetExclusivityGroup>>({
name: (dev[1] as StudioRouteSetExclusivityGroup).name,
name: dev[1].name ?? '',
}),
])
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class StudioBaselineHelper {
updateRouteSetActive(routeSetId: string, isActive: boolean | 'toggle'): void {
const studio = this.#context.studio
const saveOverrides = (newOps: SomeObjectOverrideOp[]) => {
// this.#overridesRouteSetBuffer = { defaults: this.#overridesRouteSetBuffer.defaults, overrides: newOps }
this.#overridesRouteSetBuffer.overrides = newOps
this.#routeSetChanged = true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/meteor-lib/src/triggers/actionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export function createAction(
ts,
ctx.studioId.get(),
action.routeSetId,
'toggle'
action.state
)
)
case ClientActions.showEntireCurrentSegment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export default translateWithTracker<IProps, IState, ITrackedProps>((props: IProp
</Route>
<Route path={`${this.props.match.path}/action-triggers`}>
<TriggeredActionsEditor
studioId={protectString('fakeStudio')} // A studioId is needed to enable the preview renders
showStyleBaseId={showStyleBase._id}
sourceLayers={this.props.sourceLayers}
outputLayers={this.props.outputLayers}
Expand Down
7 changes: 1 addition & 6 deletions packages/webui/src/client/ui/Settings/SystemManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ export default function SystemManagement(): JSX.Element | null {

<div className="row">
<div className="col c12 r1-c12">
<TriggeredActionsEditor
studioId={null}
showStyleBaseId={null}
sourceLayers={emptyObject}
outputLayers={emptyObject}
/>
<TriggeredActionsEditor showStyleBaseId={null} sourceLayers={emptyObject} outputLayers={emptyObject} />
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import classNames from 'classnames'
import { catchError, fetchFrom } from '../../../../lib/lib'
import { NotificationCenter, Notification, NoticeLevel } from '../../../../lib/notifications/notifications'
import { doModalDialog } from '../../../../lib/ModalDialog'
import {
PartId,
RundownId,
ShowStyleBaseId,
StudioId,
TriggeredActionId,
} from '@sofie-automation/corelib/dist/dataModel/Ids'
import { PartId, RundownId, ShowStyleBaseId, TriggeredActionId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { RundownPlaylists, Rundowns, TriggeredActions } from '../../../../collections'
import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
import { SourceLayers, OutputLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
Expand All @@ -46,7 +40,6 @@ export interface PreviewContext {
}

interface IProps {
studioId: StudioId | null
showStyleBaseId: ShowStyleBaseId | null
sourceLayers: SourceLayers
outputLayers: OutputLayers
Expand Down Expand Up @@ -81,7 +74,7 @@ export const TriggeredActionsEditor: React.FC<IProps> = function TriggeredAction
},
})

const { studioId, showStyleBaseId, sourceLayers, outputLayers } = props
const { showStyleBaseId, sourceLayers, outputLayers } = props

useSubscription(MeteorPubSub.triggeredActions, showStyleBaseId ? [showStyleBaseId] : null)
useSubscription(CorelibPubSub.rundownsWithShowStyleBases, showStyleBaseId ? [showStyleBaseId] : [])
Expand Down Expand Up @@ -392,12 +385,12 @@ export const TriggeredActionsEditor: React.FC<IProps> = function TriggeredAction

return (
<div>
{sorensen && previewContext.rundownPlaylist && showStyleBaseId && studioId && (
{sorensen && previewContext.rundownPlaylist && showStyleBaseId && (
<ErrorBoundary>
<TriggersHandler
sorensen={sorensen}
simulateTriggerBinding={true}
studioId={studioId}
studioId={previewContext.rundownPlaylist.studioId}
showStyleBaseId={showStyleBaseId}
currentRundownId={previewContext.currentRundownId}
rundownPlaylistId={previewContext.rundownPlaylist._id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ export const ActionSelector = function ActionSelector({
{...attributes.popper}
>
<div>
<p>ACT</p>
<DropdownInputControl
classNames="input text-input input-m"
value={action.action}
Expand Down

0 comments on commit 752a30a

Please sign in to comment.