Skip to content

Commit ea2fb4a

Browse files
author
Mint de Wit
committed
chore: add actions back into property panel
1 parent aa35b1b commit ea2fb4a

File tree

3 files changed

+82
-60
lines changed

3 files changed

+82
-60
lines changed

packages/blueprints-integration/src/userEditing.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export interface UserEditingProperties {
125125
* A list of id's of operations to be exposed on the properties panel as buttons. These operations
126126
* must be available on the element
127127
*
128-
* note - perhaps these should have their own full definitions?
129128
*/
130-
operations?: string[]
129+
operations?: UserEditingDefinitionAction[]
131130
}

packages/webui/src/client/styles/propertiesPanel.scss

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@
123123

124124
> .propertiespanel-pop-up__button,
125125
.propertiespanel-pop-up__button-group .propertiespanel-pop-up__button {
126-
// background: #636363;
127-
// padding: 5px 5px 5px 5px;
128-
// gap: 10px;
129-
// border-radius: 5px;
130-
// border: 1px;
131-
// border: 1px solid #7f7f7f;
132-
// color: #ddd;
133-
// margin: 10px auto;
134126
display: block;
135127

136128
border-radius: 5px;
@@ -165,6 +157,11 @@
165157
height: 1em;
166158
}
167159

160+
svg {
161+
width: 1.3em;
162+
height: 0.875em;
163+
}
164+
168165
.label {
169166
margin-left: 10px;
170167
margin-right: 10px;
@@ -235,67 +232,29 @@
235232
}
236233

237234
> .properties-panel-pop-up__form {
238-
margin-top: 15px;
239-
color: #ddd;
240-
padding: 4px 4px;
241-
position: relative;
242-
display: flex;
243-
align-items: flex-start;
244-
gap: 8px;
245-
246-
// Add positioning for the pencil icon
247-
> svg {
248-
margin-top: 4px;
249-
flex-shrink: 0;
250-
}
251-
252-
> .properties-panel-pop-up__form__schema {
253-
border-color: pink;
254-
border-width: 0px;
255-
flex-grow: 1;
256-
}
257-
}
258-
259-
> .properties-panel-pop-up__has-been-edited {
260-
background-color: #ffffff16;
261-
border-radius: 8px;
262-
padding: 4px 4px;
263-
}
264-
265-
> .propertiespanel-pop-up__label {
266235
color: #ddd;
267236
}
268237

269-
> .propertiespanel-pop-up__select {
270-
margin-top: 10px;
271-
width: 100%;
272-
height: 3em;
273-
background: #232323;
274-
margin-bottom: 0.5em;
275-
color: #ddd;
276-
}
277-
278-
> .propertiespanel-pop-up__button {
279-
margin-top: 10px;
238+
.propertiespanel-pop-up__button {
239+
// margin-top: 10px;
280240
background: #636363;
281-
padding: 5px 5px 5px 5px;
241+
padding: 10px;
282242
gap: 10px;
283243
border-radius: 5px;
284-
border: 1px;
285244
border: 1px solid #7f7f7f;
286-
color: #ddd;
245+
color: #dfdfdf;
246+
247+
font-size: 0.875em;
248+
font-weight: 500;
287249

288250
&:active {
289251
transform: scale(0.95);
290252
top: 2px;
291253
}
292254

293-
> svg {
294-
margin-top: -0.1em;
295-
vertical-align: middle;
296-
margin-right: -0.4em;
255+
svg {
297256
width: 1em;
298-
height: 1em;
257+
height: 0.875em;
299258
}
300259

301260
.label {

packages/webui/src/client/ui/UserEditOperations/PropertiesPanel.tsx

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
JSONBlob,
88
JSONBlobParse,
99
JSONSchema,
10+
UserEditingDefinitionAction,
1011
UserEditingProperties,
1112
UserEditingSourceLayer,
1213
UserEditingType,
@@ -23,6 +24,8 @@ import { RundownUtils } from '../../lib/rundown'
2324
import * as CoreIcon from '@nrk/core-icons/jsx'
2425
import { useCallback } from 'react'
2526
import { SchemaFormWithState } from '../../lib/forms/SchemaFormWithState'
27+
import { t } from 'i18next'
28+
import { translateMessage } from '@sofie-automation/corelib/dist/TranslatableMessage'
2629

2730
type PendingChange = DefaultUserOperationEditProperties['payload']
2831

@@ -117,6 +120,25 @@ export function PropertiesPanel(): JSX.Element {
117120
clearSelections()
118121
}
119122

123+
const executeAction = (e: React.MouseEvent, id: string) => {
124+
if (!rundownId || !selectedElement) return
125+
doUserAction(t, e, UserAction.EXECUTE_USER_OPERATION, (e, ts) =>
126+
MeteorCall.userAction.executeUserChangeOperation(
127+
e,
128+
ts,
129+
rundownId,
130+
{
131+
segmentExternalId: segment?.externalId,
132+
partExternalId: part?.externalId,
133+
pieceExternalId: undefined,
134+
},
135+
{
136+
id,
137+
}
138+
)
139+
)
140+
}
141+
120142
const userEditOperations =
121143
selectedElement?.type === 'part'
122144
? part?.userEditOperations
@@ -176,6 +198,9 @@ export function PropertiesPanel(): JSX.Element {
176198
setChange={setPendingChange}
177199
/>
178200
)}
201+
{userEditProperties?.operations && (
202+
<ActionList actions={userEditProperties?.operations} executeAction={executeAction} />
203+
)}
179204
</div>
180205

181206
<div className="propertiespanel-pop-up__footer">
@@ -184,6 +209,14 @@ export function PropertiesPanel(): JSX.Element {
184209
onClick={handleRevertChanges}
185210
// disabled={!hasPendingChanges}
186211
>
212+
<span className="svg">
213+
<svg viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg">
214+
<path
215+
d="M2 14.5251H15C16.3261 14.5251 17.5979 13.9984 18.5355 13.0607C19.4732 12.123 20 10.8512 20 9.52515C20 8.19906 19.4732 6.92729 18.5355 5.98961C17.5979 5.05193 16.3261 4.52515 15 4.52515H10V0.475147L5 5.47515L10 10.4751V6.52515H15C15.7956 6.52515 16.5587 6.84122 17.1213 7.40383C17.6839 7.96643 18 8.7295 18 9.52515C18 10.3208 17.6839 11.0839 17.1213 11.6465C16.5587 12.2091 15.7956 12.5251 15 12.5251H2V14.5251Z"
216+
fill="#979797"
217+
/>
218+
</svg>
219+
</span>
187220
<span className="propertiespanel-pop-up__label">{t('Restore from NRCS')}</span>
188221
</button>
189222
<div className="propertiespanel-pop-up__button-group">
@@ -233,7 +266,6 @@ function PropertiesEditor({
233266
)
234267
const onUpdate = useCallback(
235268
(update: Record<string, any>) => {
236-
console.log(change.pieceTypeProperties.type, update)
237269
setChange({
238270
...change,
239271
pieceTypeProperties: {
@@ -269,7 +301,7 @@ function PropertiesEditor({
269301
</div>
270302
<hr />
271303
{parsedSchema && (
272-
<div className="properties-grid form-dark">
304+
<div className="properties-panel-pop-up__form styled-schema-form">
273305
<SchemaFormWithState
274306
key={(selectedGroupSchema as any as string) ?? 'key'}
275307
schema={parsedSchema}
@@ -301,7 +333,6 @@ function GlobalPropertiesEditor({
301333

302334
const onUpdate = useCallback(
303335
(update: Record<string, any>) => {
304-
console.log('glob', update)
305336
setChange({
306337
...change,
307338
globalProperties: update,
@@ -326,3 +357,36 @@ function GlobalPropertiesEditor({
326357
</div>
327358
)
328359
}
360+
361+
function ActionList({
362+
actions,
363+
executeAction,
364+
}: {
365+
actions: UserEditingDefinitionAction[]
366+
executeAction: (e: any, id: string) => void
367+
}) {
368+
const { t } = useTranslation()
369+
370+
return (
371+
<div>
372+
{actions.map((action) => (
373+
<button
374+
title={'User Action : ' + action.label.key}
375+
className="propertiespanel-pop-up__button"
376+
onClick={(e) => executeAction(e, action.id)}
377+
key={action.id}
378+
>
379+
{action.svgIcon && (
380+
<span
381+
className="svg"
382+
dangerouslySetInnerHTML={{
383+
__html: action.svgIcon,
384+
}}
385+
></span>
386+
)}
387+
<span className="propertiespanel-pop-up__label">{translateMessage(action.label, t)}</span>
388+
</button>
389+
))}
390+
</div>
391+
)
392+
}

0 commit comments

Comments
 (0)