Skip to content

Commit

Permalink
feat(eventtemplates): support preset event template type
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Dec 4, 2024
1 parent 2e5202b commit cf56da6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/app/Shared/Components/SelectTemplateSelectorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,23 @@ export const SelectTemplateSelectorForm: React.FC<SelectTemplateSelectorFormProp
})),
},
{
groupLabel: 'Custom Templates',
groupLabel: 'Custom templates',
options: templates
.filter((t) => t.type === 'CUSTOM')
.map((t) => ({
value: `${t.name},${t.type}`,
label: t.name,
})),
},
{
groupLabel: 'Preset templates',
options: templates
.filter((t) => t.type === 'PRESET')
.map((t) => ({
value: `${t.name},${t.type}`,
label: t.name,
})),
},
] as TemplateSelectionGroup[],
[templates],
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/Shared/Services/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export interface EventType {
options: { [key: string]: OptionDescriptor }[];
}

export type TemplateType = 'TARGET' | 'CUSTOM';
export type TemplateType = 'TARGET' | 'CUSTOM' | 'PRESET';

export interface EventTemplate {
name: string;
Expand Down
9 changes: 8 additions & 1 deletion src/test/Events/EventTemplates.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ const mockCustomEventTemplate: EventTemplate = {

const mockAnotherTemplate = { ...mockCustomEventTemplate, name: 'anotherEventTemplate' };

const mockPresetEventTemplate: EventTemplate = {
name: 'presetEventTemplate',
description: 'Some Description',
provider: 'Cryostat',
type: 'PRESET',
};

const mockCreateTemplateNotification = {
meta: {
category: 'TemplateCreated',
Expand Down Expand Up @@ -73,7 +80,7 @@ jest.spyOn(defaultServices.api, 'addCustomEventTemplate').mockReturnValue(of(tru
jest.spyOn(defaultServices.api, 'deleteCustomEventTemplate').mockReturnValue(of(true));
jest.spyOn(defaultServices.api, 'downloadTemplate').mockReturnValue(void 0);

jest.spyOn(defaultServices.api, 'getTargetEventTemplates').mockReturnValue(of([mockCustomEventTemplate]));
jest.spyOn(defaultServices.api, 'getTargetEventTemplates').mockReturnValue(of([mockCustomEventTemplate, mockPresetEventTemplate]));

jest.spyOn(defaultServices.target, 'target').mockReturnValue(of(mockTarget));
jest.spyOn(defaultServices.target, 'authFailure').mockReturnValue(of());
Expand Down

0 comments on commit cf56da6

Please sign in to comment.