Skip to content

Commit 954a05a

Browse files
committed
fix: implement editor ui
1 parent 752a30a commit 954a05a

File tree

2 files changed

+88
-4
lines changed

2 files changed

+88
-4
lines changed

packages/webui/src/client/ui/Settings/components/triggeredActions/actionEditors/actionSelector/ActionSelector.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { preventOverflow } from '@popperjs/core'
1515
import { ToggleSwitchControl } from '../../../../../../lib/Components/ToggleSwitch'
1616
import { DropdownInputControl, DropdownInputOption } from '../../../../../../lib/Components/DropdownInput'
1717
import { IntInputControl } from '../../../../../../lib/Components/IntInput'
18+
import { SwitchRouteSetEditor } from './actionEditors/SwitchRouteSetEditor'
1819

1920
interface IProps {
2021
action: SomeAction
@@ -75,9 +76,7 @@ function getArguments(t: TFunction, action: SomeAction): string[] {
7576
case PlayoutActions.resyncRundownPlaylist:
7677
break
7778
case PlayoutActions.switchRouteSet:
78-
if (action.routeSetId) {
79-
result.push(t('Route Set: {{routeSet}}', { routeSet: action.routeSetId }))
80-
}
79+
result.push(t('State "{{state}}"', { state: action.state }))
8180
break
8281
case ClientActions.shelf:
8382
if (action.state === true) {
@@ -257,7 +256,7 @@ function getActionParametersEditor(
257256
case PlayoutActions.activateAdlibTestingMode:
258257
return null
259258
case PlayoutActions.switchRouteSet:
260-
return null
259+
return <SwitchRouteSetEditor action={action} onChange={onChange} />
261260
case PlayoutActions.disableNextPiece:
262261
return (
263262
<div className="mts">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { useTranslation } from 'react-i18next'
2+
import { useTracker } from '../../../../../../../lib/ReactMeteorData/ReactMeteorData'
3+
import { Studios } from '../../../../../../../collections'
4+
import { DropdownInputControl, DropdownInputOption } from '../../../../../../../lib/Components/DropdownInput'
5+
import { SwitchRouteSetProps } from '@sofie-automation/corelib/dist/worker/studio'
6+
import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
7+
import { StudioRouteSet } from '@sofie-automation/blueprints-integration'
8+
9+
export function SwitchRouteSetEditor({
10+
action,
11+
onChange,
12+
}: Readonly<{
13+
action: SwitchRouteSetProps
14+
onChange: (newVal: Partial<typeof action>) => void
15+
}>): JSX.Element | null {
16+
const { t } = useTranslation()
17+
const allRouteSetOptions = useTracker<DropdownInputOption<string>[]>(
18+
() => {
19+
const studios = Studios.find({}, { sort: { name: 1 } }).fetch()
20+
const routeSetOptions = studios.flatMap((studio) => {
21+
const routeSets = applyAndValidateOverrides(studio.routeSetsWithOverrides).obj
22+
return Object.entries<StudioRouteSet>(routeSets).map(
23+
([id, routeSet]): Omit<DropdownInputOption<string>, 'i'> => ({
24+
value: id,
25+
name: studios.length > 1 ? `${studio.name} - ${routeSet.name}` : routeSet.name,
26+
})
27+
)
28+
})
29+
30+
return routeSetOptions.map((option, i): DropdownInputOption<string> => ({ ...option, i }))
31+
},
32+
[],
33+
[]
34+
)
35+
36+
return (
37+
<>
38+
<div className="mts">
39+
<label className="block">{t('Route Set')}</label>
40+
<DropdownInputControl<typeof action.routeSetId>
41+
classNames="input text-input input-m"
42+
value={action.routeSetId}
43+
options={allRouteSetOptions}
44+
handleUpdate={(newVal) => {
45+
onChange({
46+
...action,
47+
routeSetId: newVal,
48+
})
49+
}}
50+
/>
51+
</div>
52+
53+
<div className="mts">
54+
<label className="block">{t('State')}</label>
55+
<DropdownInputControl<typeof action.state>
56+
classNames="input text-input input-m"
57+
value={action.state}
58+
options={[
59+
{
60+
name: t('Enabled'),
61+
value: true,
62+
i: 0,
63+
},
64+
{
65+
name: t('Disabled'),
66+
value: false,
67+
i: 1,
68+
},
69+
{
70+
name: t('Toggle'),
71+
value: 'toggle',
72+
i: 2,
73+
},
74+
]}
75+
handleUpdate={(newVal) => {
76+
onChange({
77+
...action,
78+
state: newVal,
79+
})
80+
}}
81+
/>
82+
</div>
83+
</>
84+
)
85+
}

0 commit comments

Comments
 (0)