Skip to content

Commit

Permalink
chore(Settings): Add experimental features
Browse files Browse the repository at this point in the history
  • Loading branch information
lordrip committed Dec 16, 2024
1 parent ae8bfa4 commit abefbeb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/ui/src/assets/settingsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
"default": "onHover",
"type": "string",
"enum": ["onHover", "onSelection"]
},
"experimentalFeatures": {
"title": "Experimental features",
"description": "Enable / disable experimental features",
"type": "object",
"additionalProperties": false,
"properties": {
"enableDragAndDrop": {
"title": "Enable Drag & Drop",
"description": "Control whether to enable drag and drop feature",
"type": "boolean",
"default": false
}
}
}
}
}
4 changes: 4 additions & 0 deletions packages/ui/src/components/Form/CustomAutoForm.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
form.pf-v5-c-form > div {
display: grid;
gap: var(--pf-v5-c-form--GridGap);
}
1 change: 1 addition & 0 deletions packages/ui/src/components/Form/CustomAutoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSchemaBridgeContext } from '../../hooks';
import { IDataTestID } from '../../models';
import { CustomAutoFieldDetector } from './CustomAutoField';
import { CustomAutoFields } from './CustomAutoFields';
import './CustomAutoForm.scss';

interface CustomAutoFormProps extends IDataTestID {
model: unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe('LocalStorageSettingsAdapter', () => {
catalogUrl: 'http://example.com',
nodeLabel: NodeLabelType.Description,
nodeToolbarTrigger: NodeToolbarTrigger.onSelection,
experimentalFeatures: {
enableDragAndDrop: true,
},
};

adapter.saveSettings(newSettings);
Expand All @@ -38,6 +41,9 @@ describe('LocalStorageSettingsAdapter', () => {
catalogUrl: 'http://example.com',
nodeLabel: NodeLabelType.Description,
nodeToolbarTrigger: NodeToolbarTrigger.onSelection,
experimentalFeatures: {
enableDragAndDrop: true,
},
};

adapter.saveSettings(newSettings);
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/src/models/settings/settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export interface ISettingsModel {
catalogUrl: string;
nodeLabel: NodeLabelType;
nodeToolbarTrigger: NodeToolbarTrigger;
experimentalFeatures: {
enableDragAndDrop: boolean;
};
}

export interface AbstractSettingsAdapter {
Expand All @@ -23,6 +26,9 @@ export class SettingsModel implements ISettingsModel {
catalogUrl: string = '';
nodeLabel: NodeLabelType = NodeLabelType.Description;
nodeToolbarTrigger: NodeToolbarTrigger = NodeToolbarTrigger.onHover;
experimentalFeatures = {
enableDragAndDrop: false,
};

constructor(options: Partial<ISettingsModel> = {}) {
Object.assign(this, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ describe('KaotoEditorFactory', () => {
catalogUrl: 'catalog-url',
nodeLabel: NodeLabelType.Id,
nodeToolbarTrigger: NodeToolbarTrigger.onHover,
experimentalFeatures: {
enableDragAndDrop: false,
},
};

const envelopeContext = {
Expand All @@ -41,6 +44,9 @@ describe('KaotoEditorFactory', () => {
catalogUrl: 'catalog-url',
nodeLabel: NodeLabelType.Id,
nodeToolbarTrigger: NodeToolbarTrigger.onHover,
experimentalFeatures: {
enableDragAndDrop: false,
},
};

const getVSCodeKaotoSettingsSpy = jest.fn().mockResolvedValue(settingsModel);
Expand Down Expand Up @@ -91,11 +97,17 @@ describe('KaotoEditorFactory', () => {
catalogUrl: '',
nodeLabel: NodeLabelType.Id,
nodeToolbarTrigger: NodeToolbarTrigger.onHover,
experimentalFeatures: {
enableDragAndDrop: false,
},
};
const expectedSettings: ISettingsModel = {
catalogUrl: 'path-prefix/camel-catalog/index.json',
nodeLabel: NodeLabelType.Id,
nodeToolbarTrigger: NodeToolbarTrigger.onHover,
experimentalFeatures: {
enableDragAndDrop: false,
},
};

const getVSCodeKaotoSettingsSpy = jest.fn().mockResolvedValue(settingsModel);
Expand Down

0 comments on commit abefbeb

Please sign in to comment.