Files
ontime/apps/client/src/views/studio/Studio.tsx
T
Claude 2f29060fa4 refactor: expose aux timer names via runtime store, index in automations
Addresses review feedback on the aux timer naming feature:

- Automation action labels now reference the timers by index
  ("Aux timer 1: start") rather than the custom names, keeping the
  automation config stable regardless of naming.
- Expose the custom names through the consumer-facing runtime interface:
  the aux timer objects broadcast over the websocket now carry a `name`
  field. Names are seeded from the persisted settings at bootstrap and
  kept in sync whenever the settings change, so every consumer (views and
  integrations) reads them from the same runtime data.
- The client control and view consumers now read the name from the
  runtime store instead of querying settings directly; the settings form
  remains the persisted editing source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WCZejVTzuAY3tHTE6nB3JH
2026-07-25 08:49:51 +00:00

57 lines
2.0 KiB
TypeScript

import { OntimeView } from 'ontime-types';
import { useMemo } from 'react';
import EmptyPage from '../../common/components/state/EmptyPage';
import ViewLogo from '../../common/components/view-logo/ViewLogo';
import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor';
import { useWindowTitle } from '../../common/hooks/useWindowTitle';
import { cx } from '../../common/utils/styleUtils';
import { getDefaultFormat } from '../../common/utils/time';
import Loader from '../common/loader/Loader';
import { getStudioOptions, useStudioOptions } from './studio.options';
import StudioClock from './StudioClock';
import StudioTimers from './StudioTimers';
import { StudioData, useStudioData } from './useStudioData';
import './Studio.scss';
export default function StudioLoader() {
const { data, status } = useStudioData();
useWindowTitle('Studio Clock');
if (status === 'pending') {
return <Loader />;
}
if (status === 'error') {
return <EmptyPage text='There was an error fetching data, please refresh the page.' />;
}
return <Studio {...data} />;
}
function Studio({ customFields, projectData, isMirrored, settings, viewSettings }: StudioData) {
const { hideCards } = useStudioOptions();
// gather option data
const defaultFormat = getDefaultFormat(settings?.timeFormat);
const studioOptions = useMemo(() => getStudioOptions(defaultFormat, customFields), [defaultFormat, customFields]);
return (
<div className={cx(['studio', isMirrored && 'mirror'])} data-testid='studio-view'>
<ViewParamsEditor target={OntimeView.StudioClock} viewOptions={studioOptions} />
<div className='project-header'>
{projectData?.logo && <ViewLogo name={projectData.logo} className='logo' />}
<div className='title'>{projectData.title}</div>
</div>
<div className={cx(['studio-contents', hideCards && 'studio-contents--onecol'])}>
<StudioClock hideCards={hideCards} />
{!hideCards && <StudioTimers viewSettings={viewSettings} />}
</div>
</div>
);
}