refactor: deprecate presenter and subtitle (#795)

* refactor: deprecate presenter and subtitle

* style: reduce spacing between related sections

* refactor: optional secondary field

* refactor: remove secondary field

* refactor: dynamic data source
This commit is contained in:
Carlos Valente
2024-02-29 18:19:58 +01:00
committed by GitHub
parent d7392b93d2
commit 8df419d835
51 changed files with 735 additions and 731 deletions
@@ -6,8 +6,6 @@ import { coerceString, coerceNumber, coerceBoolean, coerceColour } from '../util
// TODO: handle custom fields
const whitelistedPayload = {
title: coerceString,
subtitle: coerceString,
presenter: coerceString,
note: coerceString,
cue: coerceString,
@@ -10,8 +10,6 @@ import {
export const event: Omit<OntimeEvent, 'id' | 'delay' | 'cue'> = {
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -395,8 +395,6 @@ describe('calculateRuntimeDelays', () => {
const rundown: OntimeRundown = [
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -423,8 +421,6 @@ describe('calculateRuntimeDelays', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -451,8 +447,6 @@ describe('calculateRuntimeDelays', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -479,8 +473,6 @@ describe('calculateRuntimeDelays', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -516,8 +508,6 @@ describe('getDelayAt()', () => {
const delayedRundown: OntimeRundown = [
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -545,8 +535,6 @@ describe('getDelayAt()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -574,8 +562,6 @@ describe('getDelayAt()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -603,8 +589,6 @@ describe('getDelayAt()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -658,8 +642,6 @@ describe('calculateRuntimeDelaysFrom()', () => {
const delayedRundown: OntimeRundown = [
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -687,8 +669,6 @@ describe('calculateRuntimeDelaysFrom()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -716,8 +696,6 @@ describe('calculateRuntimeDelaysFrom()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -745,8 +723,6 @@ describe('calculateRuntimeDelaysFrom()', () => {
},
{
title: '',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.CountDown,
@@ -24,8 +24,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -47,8 +45,6 @@ describe('cellRequestFromEvent()', () => {
type: { row: 1, col: 14 },
cue: { row: 1, col: 15 },
title: { row: 1, col: 16 },
subtitle: { row: 1, col: 17 },
presenter: { row: 1, col: 18 },
note: { row: 1, col: 19 },
timeStart: { row: 1, col: 20 },
timeEnd: { row: 1, col: 21 },
@@ -72,8 +68,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -95,8 +89,6 @@ describe('cellRequestFromEvent()', () => {
type: { row: 1, col: 14 },
cue: { row: 1, col: 15 },
title: { row: 1, col: 16 },
subtitle: { row: 1, col: 17 },
presenter: { row: 1, col: 18 },
note: { row: 1, col: 19 },
timeStart: { row: 1, col: 20 },
timeEnd: { row: 1, col: 21 },
@@ -121,8 +113,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -144,8 +134,6 @@ describe('cellRequestFromEvent()', () => {
type: { row: 1, col: 14 },
cue: { row: 1, col: 15 },
title: { row: 1, col: 16 },
subtitle: { row: 1, col: 17 },
presenter: { row: 1, col: 18 },
note: { row: 1, col: 19 },
timeStart: { row: 1, col: 20 },
timeEnd: { row: 1, col: 21 },
@@ -170,8 +158,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -192,12 +178,10 @@ describe('cellRequestFromEvent()', () => {
const metadata = {
cue: { row: 1, col: 0 },
title: { row: 1, col: 6 },
subtitle: { row: 1, col: 10 },
};
const result = cellRequestFromEvent(event, 1, 1234, metadata);
expect(result.updateCells.rows[0].values[0].userEnteredValue.stringValue).toStrictEqual(event.cue);
expect(result.updateCells.rows[0].values[6].userEnteredValue.stringValue).toStrictEqual(event.title);
expect(result.updateCells.rows[0].values[10].userEnteredValue.stringValue).toStrictEqual(event.subtitle);
});
test('metadata offset from zero', () => {
@@ -205,8 +189,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -227,13 +209,11 @@ describe('cellRequestFromEvent()', () => {
const metadata = {
cue: { row: 1, col: 5 },
title: { row: 1, col: 6 },
subtitle: { row: 1, col: 10 },
user0: { row: 1, col: 16 },
};
const result = cellRequestFromEvent(event, 1, 1234, metadata);
expect(result.updateCells.rows[0].values[0].userEnteredValue.stringValue).toStrictEqual(event.cue);
expect(result.updateCells.rows[0].values[1].userEnteredValue.stringValue).toStrictEqual(event.title);
expect(result.updateCells.rows[0].values[5].userEnteredValue.stringValue).toStrictEqual(event.subtitle);
});
test('sheet setup', () => {
@@ -241,8 +221,6 @@ describe('cellRequestFromEvent()', () => {
type: SupportedEvent.Event,
cue: '1',
title: 'Fancy',
subtitle: 'Wow',
presenter: 'Mr. Presenter',
note: 'Blue button on the right',
timeStart: 46800000,
timeEnd: 57600000,
@@ -263,7 +241,6 @@ describe('cellRequestFromEvent()', () => {
const metadata = {
cue: { row: 10, col: 5 },
title: { row: 10, col: 6 },
subtitle: { row: 1, col: 10 },
};
const result1 = cellRequestFromEvent(event, 1, 1234, metadata);
expect(result1.updateCells.start.sheetId).toStrictEqual(1234);
@@ -28,8 +28,6 @@ describe('test json parser with valid def', () => {
cue: 'Guest Welcoming',
type: SupportedEvent.Event,
title: 'Guest Welcoming',
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.PlayNext,
timerType: TimerType.Clock,
@@ -51,8 +49,6 @@ describe('test json parser with valid def', () => {
cue: 'Good Morning',
type: SupportedEvent.Event,
title: 'Good Morning',
subtitle: 'Days schedule',
presenter: 'Carlos Valente',
note: '',
endAction: EndAction.PlayNext,
timerType: TimerType.CountUp,
@@ -74,8 +70,6 @@ describe('test json parser with valid def', () => {
cue: 'Stage 2 setup',
type: SupportedEvent.Event,
title: 'Stage 2 setup',
subtitle: '',
presenter: '',
note: '',
endAction: 'wrong action' as EndAction, // testing
timerType: TimerType.Clock,
@@ -98,8 +92,6 @@ describe('test json parser with valid def', () => {
cue: 'Working Procedures',
type: SupportedEvent.Event,
title: 'Working Procedures',
subtitle: '',
presenter: 'Filip Johansen',
note: '',
endAction: EndAction.None,
timerType: TimerType.Clock,
@@ -118,8 +110,6 @@ describe('test json parser with valid def', () => {
cue: 'Lunch',
title: 'Lunch',
type: SupportedEvent.Event,
subtitle: '',
presenter: '',
note: '',
endAction: EndAction.None,
timerType: TimerType.Clock,
@@ -141,8 +131,6 @@ describe('test json parser with valid def', () => {
cue: 'A day being carlos',
title: 'A day being carlos',
type: SupportedEvent.Event,
subtitle: 'My life in a song',
presenter: 'Carlos Valente',
note: '',
endAction: EndAction.None,
timerType: TimerType.Clock,
@@ -165,8 +153,6 @@ describe('test json parser with valid def', () => {
cue: 'Hamburgers and Cheese',
title: 'Hamburgers and Cheese',
type: SupportedEvent.Event,
subtitle: '... and other life questions',
presenter: 'Filip Johansen',
note: '',
endAction: EndAction.None,
timerType: TimerType.Clock,
@@ -470,8 +456,6 @@ describe('test event validator', () => {
expect(validated).toEqual(
expect.objectContaining({
title: expect.any(String),
subtitle: expect.any(String),
presenter: expect.any(String),
note: expect.any(String),
timeStart: expect.any(Number),
timeEnd: expect.any(Number),
@@ -496,15 +480,11 @@ describe('test event validator', () => {
it('makes objects strings', () => {
const event = {
title: 2,
subtitle: true,
presenter: 3.2,
note: '1899-12-30T08:00:10.000Z',
};
// @ts-expect-error -- we know this is wrong, testing imports outside domain
const validated = createEvent(event, 'not-used');
expect(typeof validated.title).toEqual('string');
expect(typeof validated.subtitle).toEqual('string');
expect(typeof validated.presenter).toEqual('string');
expect(typeof validated.note).toEqual('string');
});
@@ -697,8 +677,6 @@ describe('test import of v2 datamodel', () => {
id: expect.any(String),
cue: expect.any(String),
title: expect.any(String),
subtitle: expect.any(String),
presenter: expect.any(String),
note: expect.any(String),
endAction: expect.any(String),
timerType: expect.any(String),
@@ -757,8 +735,6 @@ describe('getCustomFieldData()', () => {
duration: 'duration',
cue: 'cue',
title: 'title',
presenter: 'presenter',
subtitle: 'subtitle',
isPublic: 'public',
skip: 'skip',
note: 'notes',
@@ -811,8 +787,6 @@ describe('parseExcel()', () => {
'Time Start',
'Time End',
'Title',
'Presenter',
'Subtitle',
'End Action',
'Timer type',
'Public',
@@ -835,8 +809,6 @@ describe('parseExcel()', () => {
'1899-12-30T07:00:00.000Z',
'1899-12-30T08:00:10.000Z',
'Guest Welcome',
'Carlos',
'Getting things started',
'',
'',
'x',
@@ -859,8 +831,6 @@ describe('parseExcel()', () => {
'1899-12-30T08:00:00.000Z',
'1899-12-30T08:30:00.000Z',
'A song from the hearth',
'Still Carlos',
'Derailing early',
'load-next',
'clock',
'',
@@ -904,8 +874,6 @@ describe('parseExcel()', () => {
//timeStart: 28800000,
//timeEnd: 32410000,
title: 'Guest Welcome',
presenter: 'Carlos',
subtitle: 'Getting things started',
timerType: 'count-down',
endAction: 'none',
isPublic: true,
@@ -931,8 +899,6 @@ describe('parseExcel()', () => {
//timeStart: 32400000,
//timeEnd: 34200000,
title: 'A song from the hearth',
presenter: 'Still Carlos',
subtitle: 'Derailing early',
timerType: 'clock',
endAction: 'load-next',
isPublic: false,
@@ -1014,8 +980,6 @@ describe('parseExcel()', () => {
'Time Start',
'Time End',
'Title',
'Presenter',
'Subtitle',
'End Action',
'Timer type',
'Public',
@@ -1038,8 +1002,6 @@ describe('parseExcel()', () => {
'1899-12-30T07:00:00.000Z',
'1899-12-30T08:00:10.000Z',
'Guest Welcome',
'Carlos',
'Getting things started',
'',
'',
'x',
@@ -1062,8 +1024,6 @@ describe('parseExcel()', () => {
'1899-12-30T08:00:00.000Z',
'1899-12-30T08:30:00.000Z',
'A song from the hearth',
'Still Carlos',
'Derailing early',
'load-next',
'clock',
'',
@@ -1099,8 +1059,6 @@ describe('parseExcel()', () => {
//timeStart: 28800000,
//timeEnd: 32410000,
title: 'Guest Welcome',
presenter: 'Carlos',
subtitle: 'Getting things started',
timerType: 'count-down',
endAction: 'none',
isPublic: true,
@@ -1115,8 +1073,6 @@ describe('parseExcel()', () => {
//timeStart: 32400000,
//timeEnd: 34200000,
title: 'A song from the hearth',
presenter: 'Still Carlos',
subtitle: 'Derailing early',
timerType: 'clock',
endAction: 'load-next',
isPublic: false,
-16
View File
@@ -91,8 +91,6 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ImportMap>)
// title stuff: strings
let titleIndex: number | null = null;
let cueIndex: number | null = null;
let presenterIndex: number | null = null;
let subtitleIndex: number | null = null;
let notesIndex: number | null = null;
let colourIndex: number | null = null;
@@ -142,14 +140,6 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ImportMap>)
titleIndex = col;
rundownMetadata['title'] = { row, col };
},
[importMap.presenter]: (row: number, col: number) => {
presenterIndex = col;
rundownMetadata['presenter'] = { row, col };
},
[importMap.subtitle]: (row: number, col: number) => {
subtitleIndex = col;
rundownMetadata['subtitle'] = { row, col };
},
[importMap.isPublic]: (row: number, col: number) => {
isPublicIndex = col;
rundownMetadata['isPublic'] = { row, col };
@@ -217,10 +207,6 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ImportMap>)
event.duration = parseExcelDate(column);
} else if (j === cueIndex) {
event.cue = makeString(column, '');
} else if (j === presenterIndex) {
event.presenter = makeString(column, '');
} else if (j === subtitleIndex) {
event.subtitle = makeString(column, '');
} else if (j === isPublicIndex) {
event.isPublic = column == 'x' ? true : coerceBoolean(column);
} else if (j === skipIndex) {
@@ -337,8 +323,6 @@ export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<Onti
id: originalEvent.id,
type: SupportedEvent.Event,
title: makeString(patchEvent.title, originalEvent.title),
subtitle: makeString(patchEvent.subtitle, originalEvent.subtitle),
presenter: makeString(patchEvent.presenter, originalEvent.presenter),
timeStart,
timeEnd,
duration,