From 08d9e248714acbc5d48de6eae5920428a4803af6 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Thu, 19 Jun 2025 18:07:42 +0200 Subject: [PATCH] Remove public event feature (#1645) --- README.md | 7 - apps/client/src/AppRouter.tsx | 10 - .../client/src/common/hooks/useEntryAction.ts | 9 +- .../src/common/hooks/useRuntimeStylesheet.js | 46 ---- .../src/common/hooks/useRuntimeStylesheet.ts | 75 +++++++ apps/client/src/common/models/ProjectData.ts | 2 - .../src/common/stores/editorSettings.ts | 10 - .../src/common/utils/__tests__/clone.test.ts | 2 - ...{dateConfig.test.js => dateConfig.test.ts} | 0 .../__tests__/{math.test.js => math.test.ts} | 0 apps/client/src/common/utils/clone.ts | 1 - .../automations-panel/automationUtils.ts | 1 - .../template-input/templateInput.utils.ts | 2 - .../interface-panel/EditorSettingsForm.tsx | 13 -- .../panel/project-panel/ProjectCreateForm.tsx | 26 +-- .../panel/project-panel/ProjectData.tsx | 24 +-- .../__test__/importMapUtils.test.ts | 1 - .../import-map/importMapUtils.ts | 2 - .../sources-panel/preview/PreviewRundown.tsx | 3 - .../src/features/rundown/RundownEntry.tsx | 2 +- .../rundown/event-block/EventBlock.tsx | 37 +--- .../rundown/event-block/EventBlockInner.tsx | 12 +- .../rundown/event-editor/EventEditor.tsx | 1 - .../composite/EventEditorTimes.tsx | 25 +-- .../rundown/quick-add-block/QuickAddBlock.tsx | 2 - .../src/features/viewers/ViewWrapper.tsx | 25 +-- .../features/viewers/countdown/Countdown.tsx | 16 +- .../{Countdown.test.js => Countdown.test.ts} | 46 ++-- .../viewers/lower-thirds/LowerThird.tsx | 2 +- .../features/viewers/studio/StudioClock.tsx | 6 +- apps/client/src/translation/languages/de.ts | 3 - apps/client/src/translation/languages/en.ts | 3 - apps/client/src/translation/languages/es.ts | 3 - apps/client/src/translation/languages/fr.ts | 4 +- apps/client/src/translation/languages/hu.ts | 3 - apps/client/src/translation/languages/it.ts | 3 - apps/client/src/translation/languages/no.ts | 3 - apps/client/src/translation/languages/pl.ts | 3 - apps/client/src/translation/languages/pt.ts | 3 - apps/client/src/translation/languages/sv.ts | 3 - apps/client/src/translation/languages/zh.ts | 3 - apps/client/src/viewerConfig.ts | 1 - apps/client/src/views/ViewLoader.tsx | 2 +- apps/client/src/views/backstage/Backstage.tsx | 8 +- .../src/views/common/schedule/Schedule.tsx | 10 +- .../views/common/schedule/ScheduleContext.tsx | 14 +- .../views/common/schedule/ScheduleExport.tsx | 7 +- .../views/common/schedule/ScheduleItem.tsx | 13 +- .../views/common/schedule/schedule.utils.ts | 11 +- .../cuesheet/__tests__/cuesheet.utils.test.ts | 20 +- .../src/views/cuesheet/cuesheet.utils.ts | 4 +- .../src/views/project-info/ProjectInfo.tsx | 2 - .../views/project-info/projectInfo.options.ts | 7 - .../project-info/public-info/PublicInfo.tsx | 40 ---- apps/client/src/views/public/Public.scss | 204 ------------------ apps/client/src/views/public/Public.tsx | 126 ----------- .../client/src/views/public/public.options.ts | 58 ----- apps/client/src/views/public/public.utils.ts | 45 ---- .../src/views/timeline/TimelinePage.tsx | 6 +- .../src/views/timeline/timeline.options.ts | 7 - .../src/views/timeline/timeline.utils.ts | 6 - apps/client/tsconfig.json | 2 +- apps/client/vite.config.js | 6 + apps/electron/src/menu/applicationMenu.js | 1 - apps/server/src/api-data/db/db.controller.ts | 2 - apps/server/src/api-data/db/db.validation.ts | 2 - .../excel/__tests__/excel.parser.test.ts | 6 - .../src/api-data/excel/__tests__/mockData.ts | 3 - .../server/src/api-data/excel/excel.parser.ts | 7 - .../project-data/projectData.parser.ts | 2 - .../project-data/projectData.router.ts | 2 - .../project-data/projectData.validation.ts | 2 - .../rundown/__tests__/rundown.utils.test.ts | 2 - .../src/api-data/rundown/rundown.utils.ts | 2 - .../src/api-integration/integration.utils.ts | 1 - apps/server/src/app.ts | 2 - .../__tests__/DataProvider.utils.test.ts | 3 - apps/server/src/models/dataModel.ts | 2 - apps/server/src/models/demoProject.ts | 16 -- apps/server/src/models/eventsDefinition.ts | 1 - .../src/services/__tests__/rollUtils.test.ts | 22 -- .../src/services/__tests__/timerUtils.test.ts | 6 - .../runtime-service/RuntimeService.ts | 40 +--- .../__tests__/sheetUtils.test.ts | 10 - .../stores/__mocks__/runtimeState.mocks.ts | 2 - .../src/stores/__tests__/runtimeState.test.ts | 2 - apps/server/src/stores/runtimeState.ts | 57 +---- apps/server/test-db/db.json | 16 -- e2e/tests/001-smoke-tests.spec.ts | 7 - e2e/tests/002-view-navigation.spec.ts | 6 - e2e/tests/features/203-delay-block.spec.ts | 6 +- e2e/tests/features/204-editor-crud.spec.ts | 4 +- e2e/tests/fixtures/e2e-test-db.json | 16 -- .../src/definitions/core/OntimeEvent.type.ts | 1 - .../src/definitions/core/ProjectData.type.ts | 2 - .../src/definitions/runtime/RuntimeStore.ts | 2 - .../definitions/runtime/RuntimeStore.type.ts | 2 - .../__tests__/spreadsheetImport.test.ts | 3 - .../spreadsheet-import/spreadsheetImport.ts | 1 - 99 files changed, 173 insertions(+), 1129 deletions(-) delete mode 100644 apps/client/src/common/hooks/useRuntimeStylesheet.js create mode 100644 apps/client/src/common/hooks/useRuntimeStylesheet.ts rename apps/client/src/common/utils/__tests__/{dateConfig.test.js => dateConfig.test.ts} (100%) rename apps/client/src/common/utils/__tests__/{math.test.js => math.test.ts} (100%) rename apps/client/src/features/viewers/countdown/__tests__/{Countdown.test.js => Countdown.test.ts} (80%) delete mode 100644 apps/client/src/views/project-info/public-info/PublicInfo.tsx delete mode 100644 apps/client/src/views/public/Public.scss delete mode 100644 apps/client/src/views/public/Public.tsx delete mode 100644 apps/client/src/views/public/public.options.ts delete mode 100644 apps/client/src/views/public/public.utils.ts diff --git a/README.md b/README.md index afe691e57..ab81f4d79 100644 --- a/README.md +++ b/README.md @@ -103,13 +103,6 @@ IP.ADDRESS:4001/studio > Studio Clock IP.ADDRESS:4001/timeline > Timeline ``` -``` -For the public views -------------------------------------------------------------- -IP.ADDRESS:4001/public > Public / Foyer view -IP.ADDRESS:4001/lower > Lower Thirds -``` - ``` For production views ------------------------------------------------------------- diff --git a/apps/client/src/AppRouter.tsx b/apps/client/src/AppRouter.tsx index 63cb9099d..7b747d639 100644 --- a/apps/client/src/AppRouter.tsx +++ b/apps/client/src/AppRouter.tsx @@ -29,7 +29,6 @@ const Countdown = React.lazy(() => import('./features/viewers/countdown/Countdow const Backstage = React.lazy(() => import('./views/backstage/Backstage')); const Timeline = React.lazy(() => import('./views/timeline/TimelinePage')); -const Public = React.lazy(() => import('./views/public/Public')); const Lower = React.lazy(() => import('./features/viewers/lower-thirds/LowerThird')); const StudioClock = React.lazy(() => import('./features/viewers/studio/StudioClock')); const ProjectInfo = React.lazy(() => import('./views/project-info/ProjectInfo')); @@ -40,7 +39,6 @@ const SClock = withPreset(withData(ClockView)); const SCountdown = withPreset(withData(Countdown)); const SBackstage = withPreset(withData(Backstage)); const SProjectInfo = withPreset(withData(ProjectInfo)); -const SPublic = withPreset(withData(Public)); const SLowerThird = withPreset(withData(Lower)); const SStudio = withPreset(withData(StudioClock)); const STimeline = withPreset(withData(Timeline)); @@ -88,14 +86,6 @@ export default function AppRouter() { } /> - - - - } - /> ; @@ -51,7 +50,6 @@ export type EventOptions = Partial<{ export const useEntryActions = () => { const queryClient = useQueryClient(); const { - defaultPublic, linkPrevious, defaultTimeStrategy, defaultDuration, @@ -95,7 +93,6 @@ export const useEntryActions = () => { const applicationOptions = { after: options?.after, before: options?.before, - defaultPublic: options?.defaultPublic ?? defaultPublic, lastEventId: options?.lastEventId, linkPrevious: options?.linkPrevious ?? linkPrevious, }; @@ -111,7 +108,6 @@ export const useEntryActions = () => { // Override event with options from editor settings newEntry.linkStart = applicationOptions.linkPrevious; - newEntry.isPublic = applicationOptions.defaultPublic; if (newEntry.duration === undefined && newEntry.timeEnd === undefined) { newEntry.duration = parseUserTime(defaultDuration); @@ -157,7 +153,6 @@ export const useEntryActions = () => { defaultDangerTime, defaultDuration, defaultEndAction, - defaultPublic, defaultTimerType, defaultTimeStrategy, defaultWarnTime, diff --git a/apps/client/src/common/hooks/useRuntimeStylesheet.js b/apps/client/src/common/hooks/useRuntimeStylesheet.js deleted file mode 100644 index 0c9164d94..000000000 --- a/apps/client/src/common/hooks/useRuntimeStylesheet.js +++ /dev/null @@ -1,46 +0,0 @@ -import { useEffect, useState } from 'react'; - -const scriptTagId = 'ontime-override'; -export const useRuntimeStylesheet = (pathToFile) => { - const [shouldRender, setShouldRender] = useState(false); - - useEffect(() => { - const fetchData = async () => { - const response = await fetch(pathToFile); - if (response.ok) { - return response.text(); - } - }; - - if (!pathToFile) { - document.getElementById(scriptTagId)?.remove(); - setShouldRender(true); - return; - } - - if (document.getElementById(scriptTagId)) { - setShouldRender(true); - return; - } - - setShouldRender(false); - const styleSheet = document.createElement('style'); - styleSheet.rel = 'stylesheet'; - styleSheet.setAttribute('id', scriptTagId); - - fetchData() - .then((data) => { - styleSheet.innerHTML = data; - document.head.append(styleSheet); - }) - .catch((error) => { - console.error(`Error loading stylesheet: ${error}`); - }) - .finally(() => { - // schedule render for next tick - setTimeout(() => setShouldRender(true), 0); - }); - }, [pathToFile]); - - return { shouldRender }; -}; diff --git a/apps/client/src/common/hooks/useRuntimeStylesheet.ts b/apps/client/src/common/hooks/useRuntimeStylesheet.ts new file mode 100644 index 000000000..c757b7117 --- /dev/null +++ b/apps/client/src/common/hooks/useRuntimeStylesheet.ts @@ -0,0 +1,75 @@ +import { useEffect, useState } from 'react'; + +const scriptTagId = 'ontime-override'; + +export const useRuntimeStylesheet = (pathToFile?: string): { shouldRender: boolean } => { + const [shouldRender, setShouldRender] = useState(false); + + /** + * When a view mounts or the stylesheet path changes we need to handle potentially loading a new stylesheet + * - if no path is given, ensure there is no stylesheet loaded + * - if a path is given, fetch the stylesheet and inject it into the document head + * @returns { shouldRender: boolean } - after the stylesheet is handled and the clients are ready to render + */ + useEffect(() => { + if (!pathToFile) { + handleNoStylesheet(); + return; + } + + // there is already a stylesheet loaded, nothing further to do + if (document.getElementById(scriptTagId)) { + setShouldRender(true); + return; + } + + setShouldRender(false); + + fetchStylesheetData(pathToFile) + .then((data: string | undefined) => { + if (!data) { + console.error('Error loading stylesheet: no data'); + return; + } + return injectStylesheet(data); + }) + .catch((error: unknown) => { + console.error(`Error loading stylesheet: ${error}`); + }) + .finally(() => { + // schedule render for next tick + setTimeout(() => setShouldRender(true), 0); + }); + + /** + * No stylesheet was provided, remove any existing stylesheet + */ + function handleNoStylesheet() { + document.getElementById(scriptTagId)?.remove(); + setShouldRender(true); + } + + /** + * Get data from backend + */ + async function fetchStylesheetData(path: string) { + const response = await fetch(path); + if (response.ok) { + return response.text(); + } + return undefined; + } + + /** + * Add a stylesheet with given content to the document head + */ + async function injectStylesheet(styleContent: string) { + const styleSheet = document.createElement('style'); + styleSheet.setAttribute('id', scriptTagId); + styleSheet.innerHTML = styleContent; + document.head.append(styleSheet); + } + }, [pathToFile]); + + return { shouldRender }; +}; diff --git a/apps/client/src/common/models/ProjectData.ts b/apps/client/src/common/models/ProjectData.ts index a57066cac..8ee964be4 100644 --- a/apps/client/src/common/models/ProjectData.ts +++ b/apps/client/src/common/models/ProjectData.ts @@ -3,8 +3,6 @@ import { ProjectData } from 'ontime-types'; export const projectDataPlaceholder: ProjectData = { title: '', description: '', - publicUrl: '', - publicInfo: '', backstageUrl: '', backstageInfo: '', projectLogo: null, diff --git a/apps/client/src/common/stores/editorSettings.ts b/apps/client/src/common/stores/editorSettings.ts index 9439a25e5..8a102f4c9 100644 --- a/apps/client/src/common/stores/editorSettings.ts +++ b/apps/client/src/common/stores/editorSettings.ts @@ -10,7 +10,6 @@ type EditorSettingsStore = { defaultTimeStrategy: TimeStrategy; defaultWarnTime: string; defaultDangerTime: string; - defaultPublic: boolean; defaultTimerType: TimerType; defaultEndAction: EndAction; setDefaultDuration: (defaultDuration: string) => void; @@ -18,7 +17,6 @@ type EditorSettingsStore = { setTimeStrategy: (timeStrategy: TimeStrategy) => void; setWarnTime: (warnTime: string) => void; setDangerTime: (dangerTime: string) => void; - setDefaultPublic: (defaultPublic: boolean) => void; setDefaultTimerType: (defaultTimerType: TimerType) => void; setDefaultEndAction: (defaultEndAction: EndAction) => void; }; @@ -29,7 +27,6 @@ export const editorSettingsDefaults = { timeStrategy: TimeStrategy.LockDuration, warnTime: '00:02:00', // 120000 same as backend dangerTime: '00:01:00', // 60000 same as backend - isPublic: true, timerType: TimerType.CountDown, endAction: EndAction.None, }; @@ -40,7 +37,6 @@ enum EditorSettingsKeys { DefaultTimeStrategy = 'ontime-time-strategy', DefaultWarnTime = 'ontime-default-warn-time', DefaultDangerTime = 'ontime-default-danger-time', - DefaultPublic = 'ontime-default-public', DefaultTimerType = 'ontime-default-timer-type', DefaultEndAction = 'ontime-default-end-action', } @@ -55,7 +51,6 @@ export const useEditorSettings = create((set) => { ), defaultWarnTime: localStorage.getItem(EditorSettingsKeys.DefaultWarnTime) ?? editorSettingsDefaults.warnTime, defaultDangerTime: localStorage.getItem(EditorSettingsKeys.DefaultDangerTime) ?? editorSettingsDefaults.dangerTime, - defaultPublic: booleanFromLocalStorage(EditorSettingsKeys.DefaultPublic, editorSettingsDefaults.isPublic), defaultTimerType: validateTimerType( localStorage.getItem(EditorSettingsKeys.DefaultTimerType), editorSettingsDefaults.timerType, @@ -92,11 +87,6 @@ export const useEditorSettings = create((set) => { localStorage.setItem(EditorSettingsKeys.DefaultDangerTime, String(defaultDangerTime)); return { defaultDangerTime }; }), - setDefaultPublic: (defaultPublic) => - set(() => { - localStorage.setItem(EditorSettingsKeys.DefaultPublic, String(defaultPublic)); - return { defaultPublic }; - }), setDefaultTimerType: (defaultTimerType) => set(() => { localStorage.setItem(EditorSettingsKeys.DefaultTimerType, String(defaultTimerType)); diff --git a/apps/client/src/common/utils/__tests__/clone.test.ts b/apps/client/src/common/utils/__tests__/clone.test.ts index d16735fc7..adf213ee0 100644 --- a/apps/client/src/common/utils/__tests__/clone.test.ts +++ b/apps/client/src/common/utils/__tests__/clone.test.ts @@ -19,7 +19,6 @@ describe('cloneEvent()', () => { linkStart: false, countToEnd: false, endAction: EndAction.None, - isPublic: false, skip: false, colour: 'F00', revision: 10, @@ -52,7 +51,6 @@ describe('cloneEvent()', () => { countToEnd: original.countToEnd, linkStart: original.linkStart, endAction: original.endAction, - isPublic: original.isPublic, skip: original.skip, colour: original.colour, revision: 0, diff --git a/apps/client/src/common/utils/__tests__/dateConfig.test.js b/apps/client/src/common/utils/__tests__/dateConfig.test.ts similarity index 100% rename from apps/client/src/common/utils/__tests__/dateConfig.test.js rename to apps/client/src/common/utils/__tests__/dateConfig.test.ts diff --git a/apps/client/src/common/utils/__tests__/math.test.js b/apps/client/src/common/utils/__tests__/math.test.ts similarity index 100% rename from apps/client/src/common/utils/__tests__/math.test.js rename to apps/client/src/common/utils/__tests__/math.test.ts diff --git a/apps/client/src/common/utils/clone.ts b/apps/client/src/common/utils/clone.ts index bae03c116..8ef98e545 100644 --- a/apps/client/src/common/utils/clone.ts +++ b/apps/client/src/common/utils/clone.ts @@ -20,7 +20,6 @@ export const cloneEvent = (event: OntimeEvent): ClonedEvent => { countToEnd: event.countToEnd, linkStart: event.linkStart, endAction: event.endAction, - isPublic: event.isPublic, skip: event.skip, colour: event.colour, parent: event.parent, diff --git a/apps/client/src/features/app-settings/panel/automations-panel/automationUtils.ts b/apps/client/src/features/app-settings/panel/automations-panel/automationUtils.ts index 64d650e49..892946389 100644 --- a/apps/client/src/features/app-settings/panel/automations-panel/automationUtils.ts +++ b/apps/client/src/features/app-settings/panel/automations-panel/automationUtils.ts @@ -31,7 +31,6 @@ const staticSelectProperties = [ { value: 'eventNow.title', label: 'Title' }, { value: 'eventNow.cue', label: 'Cue' }, { value: 'eventNow.countToEnd', label: 'Count to end' }, - { value: 'eventNow.isPublic', label: 'Is public' }, { value: 'eventNow.note', label: 'Note' }, { value: 'eventNow.colour', label: 'Colour' }, ]; diff --git a/apps/client/src/features/app-settings/panel/automations-panel/template-input/templateInput.utils.ts b/apps/client/src/features/app-settings/panel/automations-panel/template-input/templateInput.utils.ts index d911709f7..bbc8e389b 100644 --- a/apps/client/src/features/app-settings/panel/automations-panel/template-input/templateInput.utils.ts +++ b/apps/client/src/features/app-settings/panel/automations-panel/template-input/templateInput.utils.ts @@ -38,7 +38,6 @@ const eventStaticPropertiesNow = [ '{{eventNow.timeStart}}', '{{eventNow.timeEnd}}', '{{eventNow.duration}}', - '{{eventNow.isPublic}}', '{{eventNow.colour}}', '{{eventNow.delay}}', ]; @@ -51,7 +50,6 @@ const eventStaticPropertiesNext = [ '{{eventNext.timeStart}}', '{{eventNext.timeEnd}}', '{{eventNext.duration}}', - '{{eventNext.isPublic}}', '{{eventNext.colour}}', '{{eventNext.delay}}', ]; diff --git a/apps/client/src/features/app-settings/panel/interface-panel/EditorSettingsForm.tsx b/apps/client/src/features/app-settings/panel/interface-panel/EditorSettingsForm.tsx index 8772a129e..a080e0956 100644 --- a/apps/client/src/features/app-settings/panel/interface-panel/EditorSettingsForm.tsx +++ b/apps/client/src/features/app-settings/panel/interface-panel/EditorSettingsForm.tsx @@ -13,7 +13,6 @@ export default function EditorSettingsForm() { defaultTimeStrategy, defaultWarnTime, defaultDangerTime, - defaultPublic, defaultTimerType, defaultEndAction, setDefaultDuration, @@ -21,7 +20,6 @@ export default function EditorSettingsForm() { setTimeStrategy, setWarnTime, setDangerTime, - setDefaultPublic, setDefaultTimerType, setDefaultEndAction, } = useEditorSettings((state) => state); @@ -127,17 +125,6 @@ export default function EditorSettingsForm() { /> - - - - setDefaultPublic(event.target.checked)} - /> - - Run mode diff --git a/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx index e7c1deee2..f0cc243c8 100644 --- a/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx +++ b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx @@ -8,7 +8,7 @@ import { PROJECT_LIST } from '../../../../common/api/constants'; import { createProject } from '../../../../common/api/db'; import { maybeAxiosError } from '../../../../common/api/utils'; import { preventEscape } from '../../../../common/utils/keyEvent'; -import { documentationUrl, websiteUrl } from '../../../../externals'; +import { documentationUrl } from '../../../../externals'; import * as Panel from '../../panel-utils/PanelUtils'; import style from './ProjectPanel.module.scss'; @@ -20,8 +20,6 @@ interface ProjectCreateFromProps { type ProjectCreateFormValues = { title?: string; description?: string; - publicInfo?: string; - publicUrl?: string; backstageInfo?: string; backstageUrl?: string; custom?: { title: string; value: string }[]; @@ -120,28 +118,6 @@ export default function ProjectCreateForm(props: ProjectCreateFromProps) { {...register('description')} /> -