mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
refactor: migrate project data
This commit is contained in:
committed by
Carlos Valente
parent
1fc6f9b3ea
commit
6f34e1006b
@@ -38,7 +38,7 @@ const SMinimalTimer = withPreset(withData(MinimalTimerView));
|
||||
const SClock = withPreset(withData(ClockView));
|
||||
const SCountdown = withPreset(withData(Countdown));
|
||||
const SBackstage = withPreset(withData(Backstage));
|
||||
const SProjectInfo = withPreset(withData(ProjectInfo));
|
||||
const SProjectInfo = withPreset(ProjectInfo); // NOTE: ProjectInfo does not use the viewWrapper since it has no options
|
||||
const SLowerThird = withPreset(withData(Lower));
|
||||
const SStudio = withPreset(withData(StudioClock));
|
||||
const STimeline = withPreset(withData(Timeline));
|
||||
|
||||
@@ -8,11 +8,11 @@ import useViewEditor from './useViewEditor';
|
||||
|
||||
interface ViewNavigationMenuProps {
|
||||
isLockable?: boolean;
|
||||
supressSettings?: boolean;
|
||||
suppressSettings?: boolean;
|
||||
}
|
||||
|
||||
export default memo(ViewNavigationMenu);
|
||||
function ViewNavigationMenu({ isLockable, supressSettings }: ViewNavigationMenuProps) {
|
||||
function ViewNavigationMenu({ isLockable, suppressSettings }: ViewNavigationMenuProps) {
|
||||
const [isMenuOpen, menuHandler] = useDisclosure();
|
||||
const { showEditFormDrawer, isViewLocked } = useViewEditor({ isLockable });
|
||||
|
||||
@@ -28,7 +28,7 @@ function ViewNavigationMenu({ isLockable, supressSettings }: ViewNavigationMenuP
|
||||
[
|
||||
'mod + ,',
|
||||
() => {
|
||||
if (isViewLocked || supressSettings) return;
|
||||
if (isViewLocked || suppressSettings) return;
|
||||
showEditFormDrawer();
|
||||
},
|
||||
{ preventDefault: true },
|
||||
@@ -43,7 +43,7 @@ function ViewNavigationMenu({ isLockable, supressSettings }: ViewNavigationMenuP
|
||||
<>
|
||||
<FloatingNavigation
|
||||
toggleMenu={menuHandler.toggle}
|
||||
toggleSettings={supressSettings ? undefined : () => showEditFormDrawer()}
|
||||
toggleSettings={suppressSettings ? undefined : () => showEditFormDrawer()}
|
||||
/>
|
||||
<NavigationMenu isOpen={isMenuOpen} onClose={menuHandler.close} />
|
||||
</>
|
||||
|
||||
@@ -3,8 +3,8 @@ import { ProjectData } from 'ontime-types';
|
||||
export const projectDataPlaceholder: ProjectData = {
|
||||
title: '',
|
||||
description: '',
|
||||
backstageUrl: '',
|
||||
backstageInfo: '',
|
||||
projectLogo: null,
|
||||
url: '',
|
||||
info: '',
|
||||
logo: null,
|
||||
custom: [],
|
||||
};
|
||||
|
||||
@@ -22,8 +22,8 @@ interface ProjectCreateFromProps {
|
||||
type ProjectCreateFormValues = {
|
||||
title?: string;
|
||||
description?: string;
|
||||
backstageInfo?: string;
|
||||
backstageUrl?: string;
|
||||
info?: string;
|
||||
url?: string;
|
||||
custom?: { title: string; value: string }[];
|
||||
};
|
||||
|
||||
@@ -107,18 +107,12 @@ export default function ProjectCreateForm(props: ProjectCreateFromProps) {
|
||||
<Input fluid maxLength={100} placeholder='Euro Love, Malmö 2024' {...register('description')} />
|
||||
</label>
|
||||
<label>
|
||||
Backstage info
|
||||
<Textarea
|
||||
fluid
|
||||
maxLength={150}
|
||||
placeholder='Wi-Fi password: 1234'
|
||||
resize='vertical'
|
||||
{...register('backstageInfo')}
|
||||
/>
|
||||
Project info
|
||||
<Textarea fluid maxLength={150} placeholder='Wi-Fi password: 1234' resize='vertical' {...register('info')} />
|
||||
</label>
|
||||
<label>
|
||||
Backstage QR code Url
|
||||
<Input fluid placeholder={documentationUrl} {...register('backstageUrl')} />
|
||||
Project QR code URL
|
||||
<Input fluid placeholder={documentationUrl} {...register('url')} />
|
||||
</label>
|
||||
<Panel.Section>
|
||||
<Panel.ListItem>
|
||||
|
||||
@@ -61,16 +61,16 @@ export default function ProjectData() {
|
||||
validateLogo(file);
|
||||
const response = await uploadProjectLogo(file);
|
||||
|
||||
setValue('projectLogo', response.data.logoFilename, {
|
||||
setValue('logo', response.data.logoFilename, {
|
||||
shouldDirty: true,
|
||||
});
|
||||
} catch (error) {
|
||||
const message = maybeAxiosError(error);
|
||||
setError('projectLogo', { message });
|
||||
setError('logo', { message });
|
||||
}
|
||||
};
|
||||
|
||||
const { ref, ...projectLogoRest } = register('projectLogo');
|
||||
const { ref, ...projectLogoRest } = register('logo');
|
||||
|
||||
const uploadInputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
@@ -81,7 +81,7 @@ export default function ProjectData() {
|
||||
const handleDeleteLogo = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setValue('projectLogo', null, {
|
||||
setValue('logo', null, {
|
||||
shouldDirty: true,
|
||||
});
|
||||
};
|
||||
@@ -149,12 +149,12 @@ export default function ProjectData() {
|
||||
onChange={handleUploadProjectLogo}
|
||||
/>
|
||||
<Panel.Card className={style.uploadLogoCard}>
|
||||
{watch('projectLogo') ? (
|
||||
{watch('logo') ? (
|
||||
<>
|
||||
<img src={`${projectLogoPath}/${watch('projectLogo')}`} />
|
||||
<img src={`${projectLogoPath}/${watch('logo')}`} />
|
||||
<Button
|
||||
variant='subtle-destructive'
|
||||
disabled={isSubmitting || !watch('projectLogo')}
|
||||
disabled={isSubmitting || !watch('logo')}
|
||||
onClick={handleDeleteLogo}
|
||||
>
|
||||
<IoTrash />
|
||||
@@ -167,7 +167,7 @@ export default function ProjectData() {
|
||||
Upload logo
|
||||
</Button>
|
||||
)}
|
||||
{errors?.projectLogo?.message && <Panel.Error>{errors.projectLogo.message}</Panel.Error>}
|
||||
{errors?.logo?.message && <Panel.Error>{errors.logo.message}</Panel.Error>}
|
||||
</Panel.Card>
|
||||
</label>
|
||||
</Panel.Section>
|
||||
@@ -177,18 +177,18 @@ export default function ProjectData() {
|
||||
<Input fluid maxLength={100} placeholder='Euro Love, Malmö 2024' {...register('description')} />
|
||||
</label>
|
||||
<label>
|
||||
Backstage info
|
||||
Project info
|
||||
<Textarea
|
||||
fluid
|
||||
maxLength={150}
|
||||
placeholder='Wi-Fi password: 1234'
|
||||
resize='vertical'
|
||||
{...register('backstageInfo')}
|
||||
{...register('info')}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Backstage QR code URL
|
||||
<Input fluid placeholder={documentationUrl} {...register('backstageUrl')} />
|
||||
Project QR code URL
|
||||
<Input fluid placeholder={documentationUrl} {...register('url')} />
|
||||
</label>
|
||||
<Panel.Section style={{ marginTop: 0 }}>
|
||||
<Panel.ListItem>
|
||||
|
||||
@@ -20,7 +20,7 @@ function MessageControlExport() {
|
||||
<ProtectRoute permission='editor'>
|
||||
<div className={style.messages} data-testid='panel-messages-control'>
|
||||
{!isExtracted && <Corner onClick={(event) => handleLinks('messagecontrol', event)} />}
|
||||
{isExtracted && <ViewNavigationMenu supressSettings />}
|
||||
{isExtracted && <ViewNavigationMenu suppressSettings />}
|
||||
|
||||
<div className={classes}>
|
||||
<ErrorBoundary>
|
||||
|
||||
@@ -18,7 +18,7 @@ function TimerControlExport() {
|
||||
<ProtectRoute permission='editor'>
|
||||
<div className={style.playback} data-testid='panel-timer-control'>
|
||||
{!isExtracted && <Corner onClick={(event) => handleLinks('timercontrol', event)} />}
|
||||
{isExtracted && <ViewNavigationMenu supressSettings />}
|
||||
{isExtracted && <ViewNavigationMenu suppressSettings />}
|
||||
|
||||
<div className={style.content}>
|
||||
<ErrorBoundary>
|
||||
|
||||
@@ -36,7 +36,7 @@ function RundownExport() {
|
||||
data-testid='panel-rundown'
|
||||
>
|
||||
<FinderPlacement />
|
||||
<ViewNavigationMenu supressSettings />
|
||||
<ViewNavigationMenu suppressSettings />
|
||||
<div className={style.content}>
|
||||
<ErrorBoundary>
|
||||
<ContextMenu>
|
||||
|
||||
@@ -125,7 +125,7 @@ export default function Clock(props: ClockProps) {
|
||||
}}
|
||||
data-testid='clock-view'
|
||||
>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
<ViewParamsEditor viewOptions={clockOptions} />
|
||||
<SuperscriptTime
|
||||
time={clock}
|
||||
|
||||
@@ -160,7 +160,7 @@ export default function MinimalTimer(props: MinimalTimerProps) {
|
||||
}}
|
||||
data-testid='minimal-timer'
|
||||
>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
<ViewParamsEditor viewOptions={MINIMAL_TIMER_OPTIONS} />
|
||||
{showEndMessage ? (
|
||||
<div className='end-message'>{viewSettings.endMessage}</div>
|
||||
|
||||
@@ -25,6 +25,6 @@ export const langDe: TranslationObject = {
|
||||
'timeline.followedby': 'Gefolgt von',
|
||||
'project.title': 'Titel',
|
||||
'project.description': 'Beschreibung',
|
||||
'project.backstage_info': 'Backstage-Informationen',
|
||||
'project.backstage_url': 'Backstage-URL',
|
||||
'project.info': 'Projektinfo',
|
||||
'project.url': 'Projekt-URL',
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ export const langEn = {
|
||||
'timeline.followedby': 'Followed by',
|
||||
'project.title': 'Title',
|
||||
'project.description': 'Description',
|
||||
'project.backstage_info': 'Backstage Info',
|
||||
'project.backstage_url': 'Backstage URL',
|
||||
'project.info': 'Project Info',
|
||||
'project.url': 'Project URL',
|
||||
};
|
||||
|
||||
export type TranslationObject = Record<keyof typeof langEn, string>;
|
||||
|
||||
@@ -25,6 +25,6 @@ export const langEs: TranslationObject = {
|
||||
'timeline.followedby': 'Seguido por',
|
||||
'project.title': 'Título',
|
||||
'project.description': 'Descripción',
|
||||
'project.backstage_info': 'Información de backstage',
|
||||
'project.backstage_url': 'URL de backstage',
|
||||
'project.info': 'Información del proyecto',
|
||||
'project.url': 'URL del proyecto',
|
||||
};
|
||||
|
||||
@@ -25,7 +25,6 @@ export const langFr: TranslationObject = {
|
||||
'timeline.followedby': 'Suivi de',
|
||||
'project.title': 'Titre',
|
||||
'project.description': 'Description',
|
||||
'project.backstage_info': 'Informations des coulisses',
|
||||
'project.backstage_url': 'URL des coulisses',
|
||||
|
||||
'project.info': 'Informations du projet',
|
||||
'project.url': 'URL du projet',
|
||||
};
|
||||
|
||||
@@ -25,6 +25,6 @@ export const langIt: TranslationObject = {
|
||||
'timeline.followedby': 'Seguito da',
|
||||
'project.title': 'Titolo',
|
||||
'project.description': 'Descrizione',
|
||||
'project.backstage_info': 'Informazioni di backstage',
|
||||
'project.backstage_url': 'URL di backstage',
|
||||
'project.info': 'Informazioni sul progetto',
|
||||
'project.url': 'URL del progetto',
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ export default function Backstage(props: BackstageProps) {
|
||||
<div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'>
|
||||
<ViewParamsEditor viewOptions={backstageOptions} />
|
||||
<div className='project-header'>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
<div className='title'>{general.title}</div>
|
||||
<div className='clock-container'>
|
||||
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
||||
@@ -171,8 +171,8 @@ export default function Backstage(props: BackstageProps) {
|
||||
{showSchedule && <ScheduleExport selectedId={selectedId} />}
|
||||
|
||||
<div className={cx(['info', !showSchedule && 'info--stretch'])}>
|
||||
{general.backstageUrl && <QRCode value={general.backstageUrl} size={qrSize} level='L' className='qr' />}
|
||||
{general.backstageInfo && <div className='info__message'>{general.backstageInfo}</div>}
|
||||
{general.url && <QRCode value={general.url} size={qrSize} level='L' className='qr' />}
|
||||
{general.info && <div className='info__message'>{general.info}</div>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function Countdown({
|
||||
<div className={`countdown ${isMirrored ? 'mirror' : ''}`} data-testid='countdown-view'>
|
||||
<ViewParamsEditor viewOptions={countdownOptions} />
|
||||
<div className='project-header'>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
<div className='title'>{general.title}</div>
|
||||
<div className='clock-container'>
|
||||
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('makeTable()', () => {
|
||||
const headerData = {
|
||||
title: 'test title',
|
||||
description: 'test description',
|
||||
projectLogo: 'test logo',
|
||||
logo: 'test logo',
|
||||
};
|
||||
const tableData = [
|
||||
{
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
white-space: break-spaces;
|
||||
}
|
||||
|
||||
a.info__value {
|
||||
.link.info__value {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
color: $action-text-color;
|
||||
|
||||
&:hover {
|
||||
|
||||
@@ -1,37 +1,30 @@
|
||||
import { ProjectData } from 'ontime-types';
|
||||
import { Fragment } from 'react/jsx-runtime';
|
||||
import { IoOpenOutline } from 'react-icons/io5';
|
||||
|
||||
import Empty from '../../common/components/state/Empty';
|
||||
import ViewNavigationMenu from '../../common/components/navigation-menu/ViewNavigationMenu';
|
||||
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 useProjectData from '../../common/hooks-query/useProjectData';
|
||||
import { useViewOptionsStore } from '../../common/stores/viewOptions';
|
||||
import { useTranslation } from '../../translation/TranslationProvider';
|
||||
|
||||
import BackstageInfo from './backstage-info/BackstageInfo';
|
||||
import CustomInfo from './custom-info/CustomInfo';
|
||||
import { projectInfoOptions } from './projectInfo.options';
|
||||
|
||||
import './ProjectInfo.scss';
|
||||
|
||||
interface ProjectInfoProps {
|
||||
general: ProjectData;
|
||||
isMirrored: boolean;
|
||||
}
|
||||
|
||||
export default function ProjectInfo(props: ProjectInfoProps) {
|
||||
const { general, isMirrored } = props;
|
||||
export default function ProjectInfo() {
|
||||
// persisted app state
|
||||
const isMirrored = useViewOptionsStore((state) => state.mirror);
|
||||
const { data, status } = useProjectData();
|
||||
const { getLocalizedString } = useTranslation();
|
||||
|
||||
useWindowTitle('Project info');
|
||||
|
||||
if (!general) {
|
||||
return <Empty text={getLocalizedString('common.no_data')} />;
|
||||
}
|
||||
|
||||
if (!general) {
|
||||
if (status === 'pending' || !data) {
|
||||
return (
|
||||
<>
|
||||
<ViewParamsEditor viewOptions={projectInfoOptions} />
|
||||
<ViewNavigationMenu isLockable suppressSettings />
|
||||
<ViewParamsEditor viewOptions={[]} />
|
||||
<EmptyPage text={getLocalizedString('common.no_data')} />;
|
||||
</>
|
||||
);
|
||||
@@ -41,13 +34,12 @@ export default function ProjectInfo(props: ProjectInfoProps) {
|
||||
* Check if there is data to show at all
|
||||
* We need a special check for the project fields which can be an empty array
|
||||
*/
|
||||
const isEmpty = Object.values(general).every(
|
||||
(value) => !value || (value && Array.isArray(value) && value.length === 0),
|
||||
);
|
||||
const isEmpty = Object.values(data).every((value) => !value || (value && Array.isArray(value) && value.length === 0));
|
||||
if (isEmpty) {
|
||||
return (
|
||||
<>
|
||||
<ViewParamsEditor viewOptions={projectInfoOptions} />
|
||||
<ViewNavigationMenu isLockable suppressSettings />
|
||||
<ViewParamsEditor viewOptions={[]} />
|
||||
<EmptyPage text={getLocalizedString('common.no_data')} />;
|
||||
</>
|
||||
);
|
||||
@@ -55,23 +47,47 @@ export default function ProjectInfo(props: ProjectInfoProps) {
|
||||
|
||||
return (
|
||||
<div className={`project ${isMirrored ? 'mirror' : ''}`} data-testid='project-view'>
|
||||
<ViewParamsEditor viewOptions={projectInfoOptions} />
|
||||
{general.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
<ViewNavigationMenu isLockable suppressSettings />
|
||||
<ViewParamsEditor viewOptions={[]} />
|
||||
{data.logo && <ViewLogo name={data.logo} className='logo' />}
|
||||
<div className='info'>
|
||||
{general.title && (
|
||||
{data.title && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.title')}</div>
|
||||
<div className='info__value'>{general.title}</div>
|
||||
<div className='info__value'>{data.title}</div>
|
||||
</>
|
||||
)}
|
||||
{general.description && (
|
||||
{data.description && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.description')}</div>
|
||||
<div className='info__value'>{general.description}</div>
|
||||
<div className='info__value'>{data.description}</div>
|
||||
</>
|
||||
)}
|
||||
<BackstageInfo general={general} />
|
||||
<CustomInfo general={general} />
|
||||
{data.info && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.info')}</div>
|
||||
<div className='info__value'>{data.info}</div>
|
||||
</>
|
||||
)}
|
||||
{data.url && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.url')}</div>
|
||||
<a href={data.url} target='_blank' rel='noreferrer' className='info__value link'>
|
||||
{data.url} <IoOpenOutline style={{ fontSize: '1em' }} />
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
{data.custom.map((info, idx) => {
|
||||
if (!info.title || !info.value) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Fragment key={`${info.title}-${idx}`}>
|
||||
<div className='info__label'>{info.title}</div>
|
||||
<div className='info__value'>{info.value}</div>
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { ProjectData } from 'ontime-types';
|
||||
|
||||
import { isStringBoolean } from '../../../features/viewers/common/viewUtils';
|
||||
import { useTranslation } from '../../../translation/TranslationProvider';
|
||||
|
||||
interface BackstageInfoProps {
|
||||
general: ProjectData;
|
||||
}
|
||||
|
||||
export default function BackstageInfo(props: BackstageInfoProps) {
|
||||
const { general } = props;
|
||||
const [searchParams] = useSearchParams();
|
||||
const { getLocalizedString } = useTranslation();
|
||||
|
||||
const showBackstage = isStringBoolean(searchParams.get('showBackstage'));
|
||||
|
||||
if (!showBackstage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{general.backstageInfo && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.backstage_info')}</div>
|
||||
<div className='info__value'>{general.backstageInfo}</div>
|
||||
</>
|
||||
)}
|
||||
{general.backstageUrl && (
|
||||
<>
|
||||
<div className='info__label'>{getLocalizedString('project.backstage_url')}</div>
|
||||
<a href={general.backstageUrl} target='_blank' rel='noreferrer' className='info__value'>
|
||||
{general.backstageUrl}
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Fragment } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { ProjectData } from 'ontime-types';
|
||||
|
||||
import { isStringBoolean } from '../../../features/viewers/common/viewUtils';
|
||||
|
||||
interface CustomInfoProps {
|
||||
general: ProjectData;
|
||||
}
|
||||
|
||||
export default function CustomInfo(props: CustomInfoProps) {
|
||||
const { general } = props;
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const showCustom = isStringBoolean(searchParams.get('showCustom'));
|
||||
|
||||
if (!showCustom || general.custom === undefined || general.custom.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{general.custom.map((info, idx) => {
|
||||
if (!info.title || !info.value) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Fragment key={`${info.title}-${idx}`}>
|
||||
<div className='info__label'>{info.title}</div>
|
||||
<div className='info__value'>{info.value}</div>
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { OptionTitle } from '../../common/components/view-params-editor/constants';
|
||||
import { ViewOption } from '../../common/components/view-params-editor/viewParams.types';
|
||||
|
||||
export const projectInfoOptions: ViewOption[] = [
|
||||
{
|
||||
title: OptionTitle.BehaviourOptions,
|
||||
collapsible: true,
|
||||
options: [
|
||||
{
|
||||
id: 'showBackstage',
|
||||
title: 'Show backstage Data',
|
||||
description: 'Whether to show fields related to the backstage views',
|
||||
type: 'boolean',
|
||||
defaultValue: false,
|
||||
},
|
||||
{
|
||||
id: 'showCustom',
|
||||
title: 'Show Custom Data',
|
||||
description: 'Whether to show fields related to the custom data',
|
||||
type: 'boolean',
|
||||
defaultValue: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -50,7 +50,7 @@ export default function Studio({
|
||||
<ViewParamsEditor viewOptions={studioOptions} />
|
||||
|
||||
<div className='project-header'>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
<div className='title'>{general.title}</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function TimelinePage(props: TimelinePageProps) {
|
||||
<div className='timeline' data-testid='timeline-view'>
|
||||
<ViewParamsEditor viewOptions={progressOptions} />
|
||||
<div className='project-header'>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
{general.title}
|
||||
<div className='clock-container'>
|
||||
<div className='label'>{getLocalizedString('common.time_now')}</div>
|
||||
|
||||
@@ -131,7 +131,7 @@ export default function Timer(props: TimerProps) {
|
||||
className={cx(['stage-timer', isMirrored && 'mirror', showFinished && 'stage-timer--finished'])}
|
||||
data-testid='timer-view'
|
||||
>
|
||||
{general?.projectLogo && <ViewLogo name={general.projectLogo} className='logo' />}
|
||||
{general?.logo && <ViewLogo name={general.logo} className='logo' />}
|
||||
|
||||
<ViewParamsEditor viewOptions={timerOptions} />
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ export async function createProjectFile(req: Request, res: Response<{ filename:
|
||||
project: {
|
||||
title: req.body?.title ?? '',
|
||||
description: req.body?.description ?? '',
|
||||
backstageUrl: req.body?.backstageUrl ?? '',
|
||||
backstageInfo: req.body?.backstageInfo ?? '',
|
||||
projectLogo: req.body?.projectLogo ?? null,
|
||||
url: req.body?.url ?? '',
|
||||
info: req.body?.info ?? '',
|
||||
logo: req.body?.logo ?? null,
|
||||
custom: req.body?.custom ?? [],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -11,10 +11,9 @@ export const validateNewProject = [
|
||||
body('filename').optional().isString().trim(),
|
||||
body('title').optional().isString().trim(),
|
||||
body('description').optional().isString().trim(),
|
||||
body('backstageUrl').optional().isString().trim(),
|
||||
body('backstageInfo').optional().isString().trim(),
|
||||
body('projectLogo').optional().isString().trim(),
|
||||
body('endMessage').optional().isString().trim(),
|
||||
body('url').optional().isString().trim(),
|
||||
body('info').optional().isString().trim(),
|
||||
body('logo').optional().isString().trim(),
|
||||
body('custom').optional().isArray(),
|
||||
|
||||
requestValidationFunction,
|
||||
|
||||
@@ -17,9 +17,9 @@ export function parseProjectData(data: Partial<DatabaseModel>, emitError?: Error
|
||||
return {
|
||||
title: data.project.title ?? dbModel.project.title,
|
||||
description: data.project.description ?? dbModel.project.description,
|
||||
backstageUrl: data.project.backstageUrl ?? dbModel.project.backstageUrl,
|
||||
backstageInfo: data.project.backstageInfo ?? dbModel.project.backstageInfo,
|
||||
projectLogo: data.project.projectLogo ?? dbModel.project.projectLogo,
|
||||
url: data.project.url ?? dbModel.project.url,
|
||||
info: data.project.info ?? dbModel.project.info,
|
||||
logo: data.project.logo ?? dbModel.project.logo,
|
||||
custom: data.project.custom ?? dbModel.project.custom,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ router.post('/', projectSanitiser, async (req: Request, res: Response<ProjectDat
|
||||
const newData: Partial<ProjectData> = removeUndefined({
|
||||
title: req.body?.title,
|
||||
description: req.body?.description,
|
||||
backstageUrl: req.body?.backstageUrl,
|
||||
backstageInfo: req.body?.backstageInfo,
|
||||
endMessage: req.body?.endMessage,
|
||||
projectLogo: req.body?.projectLogo,
|
||||
url: req.body?.url,
|
||||
info: req.body?.info,
|
||||
logo: req.body?.logo,
|
||||
custom: req.body?.custom,
|
||||
});
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@ export const projectSanitiser = [
|
||||
body().notEmpty().withMessage('No object found in request'),
|
||||
body('title').optional().isString().trim(),
|
||||
body('description').optional().isString().trim(),
|
||||
body('backstageUrl').optional().isString().trim(),
|
||||
body('backstageInfo').optional().isString().trim(),
|
||||
body('endMessage').optional().isString().trim(),
|
||||
body('projectLogo').optional({ nullable: true }).isString().trim(), //this is not the logo itself but then name of the logo
|
||||
body('url').optional().isString().trim(),
|
||||
body('info').optional().isString().trim(),
|
||||
body('logo').optional({ nullable: true }).isString().trim(), //this is not the logo itself but then name of the logo
|
||||
body('custom').optional().isArray(),
|
||||
body('custom.*.title').optional().isString().trim().notEmpty(),
|
||||
body('custom.*.value').optional().isString().trim().notEmpty(),
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('safeMerge', () => {
|
||||
const mergedData = safeMerge(demoDb, {
|
||||
project: {
|
||||
title: 'new title',
|
||||
backstageInfo: 'new backstage info',
|
||||
info: 'new backstage info',
|
||||
custom: [
|
||||
{
|
||||
title: 'new custom title',
|
||||
@@ -55,9 +55,9 @@ describe('safeMerge', () => {
|
||||
expect(mergedData.project).toStrictEqual({
|
||||
title: 'new title',
|
||||
description: 'Turin 2022',
|
||||
backstageUrl: 'www.github.com/cpvalente/ontime',
|
||||
backstageInfo: 'new backstage info',
|
||||
projectLogo: null,
|
||||
url: 'www.github.com/cpvalente/ontime',
|
||||
info: 'new backstage info',
|
||||
logo: null,
|
||||
custom: [
|
||||
{
|
||||
title: 'new custom title',
|
||||
|
||||
@@ -17,9 +17,9 @@ export const dbModel: DatabaseModel = {
|
||||
project: {
|
||||
title: '',
|
||||
description: '',
|
||||
backstageUrl: '',
|
||||
backstageInfo: '',
|
||||
projectLogo: null,
|
||||
url: '',
|
||||
info: '',
|
||||
logo: null,
|
||||
custom: [],
|
||||
},
|
||||
settings: {
|
||||
|
||||
@@ -504,9 +504,9 @@ export const demoDb: DatabaseModel = {
|
||||
project: {
|
||||
title: 'Eurovision Song Contest',
|
||||
description: 'Turin 2022',
|
||||
backstageUrl: 'www.github.com/cpvalente/ontime',
|
||||
backstageInfo: 'Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal',
|
||||
projectLogo: null,
|
||||
url: 'www.github.com/cpvalente/ontime',
|
||||
info: 'Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal',
|
||||
logo: null,
|
||||
custom: [],
|
||||
},
|
||||
settings: {
|
||||
|
||||
@@ -322,8 +322,8 @@ export async function editCurrentProjectData(newData: Partial<ProjectData>) {
|
||||
const updatedProjectData = await getDataProvider().setProjectData(newData);
|
||||
|
||||
// Delete the old logo if the logo has been removed
|
||||
if (!updatedProjectData.projectLogo && currentProjectData.projectLogo) {
|
||||
const filePath = join(publicDir.logoDir, currentProjectData.projectLogo);
|
||||
if (!updatedProjectData.logo && currentProjectData.logo) {
|
||||
const filePath = join(publicDir.logoDir, currentProjectData.logo);
|
||||
|
||||
deleteFile(filePath).catch((_error) => {
|
||||
/** we do not handle this error */
|
||||
|
||||
@@ -452,9 +452,9 @@
|
||||
"project": {
|
||||
"title": "Eurovision Song Contest",
|
||||
"description": "Turin 2022",
|
||||
"backstageUrl": "www.github.com/cpvalente/ontime",
|
||||
"backstageInfo": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal",
|
||||
"projectLogo": null,
|
||||
"url": "www.github.com/cpvalente/ontime",
|
||||
"info": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal",
|
||||
"logo": null,
|
||||
"custom": []
|
||||
},
|
||||
"settings": {
|
||||
|
||||
Vendored
+3
-3
@@ -469,9 +469,9 @@
|
||||
"project": {
|
||||
"title": "Eurovision Song Contest",
|
||||
"description": "Turin 2022",
|
||||
"backstageUrl": "www.github.com/cpvalente/ontime",
|
||||
"backstageInfo": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal",
|
||||
"projectLogo": null,
|
||||
"url": "www.github.com/cpvalente/ontime",
|
||||
"info": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal",
|
||||
"logo": null,
|
||||
"custom": []
|
||||
},
|
||||
"settings": {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export type ProjectData = {
|
||||
title: string;
|
||||
description: string;
|
||||
backstageUrl: string;
|
||||
backstageInfo: string;
|
||||
projectLogo: string | null;
|
||||
url: string;
|
||||
info: string;
|
||||
logo: string | null;
|
||||
custom: { title: string; value: string }[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user