diff --git a/src/app/CreateRecording/CreateRecording.tsx b/src/app/CreateRecording/CreateRecording.tsx index 0f4ae31ff1..8ec9853edb 100644 --- a/src/app/CreateRecording/CreateRecording.tsx +++ b/src/app/CreateRecording/CreateRecording.tsx @@ -46,6 +46,7 @@ import { CustomRecordingForm } from './CustomRecordingForm'; import { SnapshotRecordingForm } from './SnapshotRecordingForm'; export interface CreateRecordingProps { + restartExisting?: boolean; name?: string; templateName?: string; templateType?: TemplateType; @@ -69,6 +70,7 @@ const Comp: React.FC, StaticContext, C const prefilled = React.useMemo( () => ({ + restartExisting: props.location?.state?.restartExisting, name: props.location?.state?.name, templateName: props.location?.state?.templateName, templateType: props.location?.state?.templateType, diff --git a/src/app/CreateRecording/CustomRecordingForm.tsx b/src/app/CreateRecording/CustomRecordingForm.tsx index e5239ee8d6..fc5fc1e390 100644 --- a/src/app/CreateRecording/CustomRecordingForm.tsx +++ b/src/app/CreateRecording/CustomRecordingForm.tsx @@ -75,6 +75,7 @@ import { EventTemplate } from './CreateRecording'; export interface CustomRecordingFormProps { prefilled?: { + restartExisting?: boolean; name?: string; templateName?: string; templateType?: TemplateType; @@ -102,6 +103,7 @@ export const CustomRecordingForm: React.FC = ({ prefil : ValidatedOptions.error : ValidatedOptions.default ); + const [restartExisting, setRestartExisting] = React.useState(prefilled?.restartExisting || false); const [continuous, setContinuous] = React.useState((prefilled?.duration || 30) < 1); const [archiveOnStop, setArchiveOnStop] = React.useState(true); const [duration, setDuration] = React.useState(prefilled?.duration || 30); @@ -138,6 +140,13 @@ export const CustomRecordingForm: React.FC = ({ prefil [addSubscription, context.api, history, setLoading] ); + const handleRestartExistingChange = React.useCallback( + (checked) => { + setRestartExisting(checked); + }, + [setRestartExisting] + ); + const handleContinuousChange = React.useCallback( (checked) => { setContinuous(checked); @@ -260,6 +269,7 @@ export const CustomRecordingForm: React.FC = ({ prefil } const options: RecordingOptions = { + restart: restartExisting, toDisk: toDisk, maxAge: toDisk ? (continuous ? maxAge * maxAgeUnits : undefined) : undefined, maxSize: toDisk ? maxSize * maxSizeUnits : undefined, @@ -287,6 +297,7 @@ export const CustomRecordingForm: React.FC = ({ prefil nameValid, notifications, recordingName, + restartExisting, toDisk, handleCreateRecording, ]); @@ -408,6 +419,15 @@ export const CustomRecordingForm: React.FC = ({ prefil onChange={handleRecordingNameChange} validated={nameValid} /> + = (props) => { history.push({ pathname: '/recordings/create', state: { + restartExisting: true, name: RECORDING_NAME, templateName: 'Profiling', templateType: 'TARGET', diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 3d8312770a..c4b6805747 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -301,6 +301,9 @@ export class ApiService { form.append('archiveOnStop', String(recordingAttributes.archiveOnStop)); } if (recordingAttributes.options) { + if (recordingAttributes.options.restart) { + form.append('restart', String(recordingAttributes.options.restart)); + } if (recordingAttributes.options.toDisk != null) { form.append('toDisk', String(recordingAttributes.options.toDisk)); } @@ -1351,6 +1354,7 @@ export interface EventTemplate { } export interface RecordingOptions { + restart?: boolean; toDisk?: boolean; maxSize?: number; maxAge?: number; diff --git a/src/test/CreateRecording/CustomRecordingForm.test.tsx b/src/test/CreateRecording/CustomRecordingForm.test.tsx index 639951035e..483190894f 100644 --- a/src/test/CreateRecording/CustomRecordingForm.test.tsx +++ b/src/test/CreateRecording/CustomRecordingForm.test.tsx @@ -145,6 +145,7 @@ describe('', () => { duration: 30, archiveOnStop: true, options: { + restart: false, toDisk: true, maxAge: undefined, maxSize: 0, diff --git a/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap b/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap index 97c5cbf70d..e7e64f90f7 100644 --- a/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap +++ b/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap @@ -60,6 +60,31 @@ Array [ type="text" value="" /> +
+ + +