feat: Add Jest Test for propertyPaneConfiguration validation (#8773)
This commit is contained in:
parent
cc426f1455
commit
ef9c8e0aa3
|
|
@ -107,7 +107,7 @@
|
||||||
"momentDate": "{{moment()}}",
|
"momentDate": "{{moment()}}",
|
||||||
"defaultRowIndexBinding": "{{Table1.selectedRowIndex",
|
"defaultRowIndexBinding": "{{Table1.selectedRowIndex",
|
||||||
"bindingAlign": "{{currentRow.userName.indexOf('Michael') > -1 ? 'LEFT' : 'RIGHT'}}",
|
"bindingAlign": "{{currentRow.userName.indexOf('Michael') > -1 ? 'LEFT' : 'RIGHT'}}",
|
||||||
"bindingSize": "{{currentRow.userName.indexOf('Michael') > -1 ? 'PARAGRAGH' : 'HEADING1'}}",
|
"bindingSize": "{{currentRow.userName.indexOf('Michael') > -1 ? 'PARAGRAPH' : 'HEADING1'}}",
|
||||||
"bindingVerticalAlig": "{{currentRow.userName.indexOf('Michael') > -1 ? 'TOP' : 'BOTTOM'}}",
|
"bindingVerticalAlig": "{{currentRow.userName.indexOf('Michael') > -1 ? 'TOP' : 'BOTTOM'}}",
|
||||||
"bindingTextColor": "{{currentRow.userName.indexOf('Michael') > -1 ? 'GREEN' : 'RED'}}",
|
"bindingTextColor": "{{currentRow.userName.indexOf('Michael') > -1 ? 'GREEN' : 'RED'}}",
|
||||||
"bindingButton": "{{currentRow.userName.indexOf('Michael') > -1 ? 'Discount' : 'NoDiscount'}}",
|
"bindingButton": "{{currentRow.userName.indexOf('Michael') > -1 ? 'Discount' : 'NoDiscount'}}",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import tablePropertyPaneConfig from "widgets/TableWidget/widget/propertyConfig";
|
||||||
import chartPorpertyConfig from "widgets/ChartWidget/widget/propertyConfig";
|
import chartPorpertyConfig from "widgets/ChartWidget/widget/propertyConfig";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
||||||
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
|
|
||||||
describe("getAllPathsFromPropertyConfig", () => {
|
describe("getAllPathsFromPropertyConfig", () => {
|
||||||
it("works as expected for table widget", () => {
|
it("works as expected for table widget", () => {
|
||||||
|
|
@ -219,6 +220,222 @@ describe("getAllPathsFromPropertyConfig", () => {
|
||||||
default: [],
|
default: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"primaryColumns.createdAt.isCellVisible": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.isCellVisible": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.status.isCellVisible": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.status.isDisabled": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.inputFormat": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"Epoch",
|
||||||
|
"Milliseconds",
|
||||||
|
"YYYY-MM-DD",
|
||||||
|
"YYYY-MM-DD HH:mm",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss.sssZ",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss",
|
||||||
|
"YYYY-MM-DD hh:mm:ss",
|
||||||
|
"Do MMM YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YYYY HH:mm",
|
||||||
|
"LLL",
|
||||||
|
"LL",
|
||||||
|
"D MMMM, YYYY",
|
||||||
|
"H:mm A D MMMM, YYYY",
|
||||||
|
"MM-DD-YYYY",
|
||||||
|
"DD-MM-YYYY",
|
||||||
|
"MM/DD/YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YY",
|
||||||
|
"MM/DD/YY",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.outputFormat": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"Epoch",
|
||||||
|
"Milliseconds",
|
||||||
|
"YYYY-MM-DD",
|
||||||
|
"YYYY-MM-DD HH:mm",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss.sssZ",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss",
|
||||||
|
"YYYY-MM-DD hh:mm:ss",
|
||||||
|
"Do MMM YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YYYY HH:mm",
|
||||||
|
"LLL",
|
||||||
|
"LL",
|
||||||
|
"D MMMM, YYYY",
|
||||||
|
"H:mm A D MMMM, YYYY",
|
||||||
|
"MM-DD-YYYY",
|
||||||
|
"DD-MM-YYYY",
|
||||||
|
"MM/DD/YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YY",
|
||||||
|
"MM/DD/YY",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.horizontalAlignment": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["LEFT", "CENTER", "RIGHT"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.horizontalAlignment": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["LEFT", "CENTER", "RIGHT"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.textSize": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"HEADING1",
|
||||||
|
"HEADING2",
|
||||||
|
"HEADING3",
|
||||||
|
"PARAGRAPH",
|
||||||
|
"PARAGRAPH2",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.textSize": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"HEADING1",
|
||||||
|
"HEADING2",
|
||||||
|
"HEADING3",
|
||||||
|
"PARAGRAPH",
|
||||||
|
"PARAGRAPH2",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.fontStyle": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.fontStyle": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.verticalAlignment": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["TOP", "CENTER", "BOTTOM"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.verticalAlignment": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["TOP", "CENTER", "BOTTOM"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.textColor": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.textColor": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.createdAt.cellBackground": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.name.cellBackground": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.status.buttonColor": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"primaryColumns.status.buttonLabelColor": {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { registerWidget } from "./WidgetRegisterHelpers";
|
import { registerWidget, WidgetConfiguration } from "./WidgetRegisterHelpers";
|
||||||
import CanvasWidget, {
|
import CanvasWidget, {
|
||||||
CONFIG as CANVAS_WIDGET_CONFIG,
|
CONFIG as CANVAS_WIDGET_CONFIG,
|
||||||
} from "widgets/CanvasWidget";
|
} from "widgets/CanvasWidget";
|
||||||
|
|
@ -123,53 +123,59 @@ import MapChartWidget, {
|
||||||
|
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
|
|
||||||
|
export const ALL_WDIGETS_AND_CONFIG = [
|
||||||
|
[CanvasWidget, CANVAS_WIDGET_CONFIG],
|
||||||
|
[SkeletonWidget, SKELETON_WIDGET_CONFIG],
|
||||||
|
[ContainerWidget, CONTAINER_WIDGET_CONFIG],
|
||||||
|
[TextWidget, TEXT_WIDGET_CONFIG],
|
||||||
|
[TableWidget, TABLE_WIDGET_CONFIG],
|
||||||
|
[CheckboxWidget, CHECKBOX_WIDGET_CONFIG],
|
||||||
|
[RadioGroupWidget, RADIO_GROUP_WIDGET_CONFIG],
|
||||||
|
[ButtonWidget, BUTTON_WIDGET_CONFIG],
|
||||||
|
[DropdownWidget, DROPDOWN_WIDGET_CONFIG],
|
||||||
|
[ImageWidget, IMAGE_WIDGET_CONFIG],
|
||||||
|
[VideoWidget, VIDEO_WIDGET_CONFIG],
|
||||||
|
[TabsWidget, TABS_WIDGET_CONFIG],
|
||||||
|
[InputWidget, INPUT_WIDGET_CONFIG],
|
||||||
|
[ModalWidget, MODAL_WIDGET_CONFIG],
|
||||||
|
[ChartWidget, CHART_WIDGET_CONFIG],
|
||||||
|
[MapWidget, MAP_WIDGET_CONFIG],
|
||||||
|
[FilePickerWidget, FILEPICKER_WIDGET_CONFIG],
|
||||||
|
[RichTextEditorWidget, RICH_TEXT_EDITOR_WIDGET_CONFIG],
|
||||||
|
[DatePickerWidget, DATE_PICKER_WIDGET_CONFIG],
|
||||||
|
[DatePickerWidget2, DATE_PICKER_WIDGET_2_CONFIG],
|
||||||
|
[SwitchWidget, SWITCH_WIDGET_CONFIG],
|
||||||
|
[FormWidget, FORM_WIDGET_CONFIG],
|
||||||
|
[FormButtonWidget, FORM_BUTTON_WIDGET_CONFIG],
|
||||||
|
[IconWidget, ICON_WIDGET_CONFIG],
|
||||||
|
[ListWidget, LIST_WIDGET_CONFIG],
|
||||||
|
[RateWidget, RATE_WIDGET_CONFIG],
|
||||||
|
[IframeWidget, IFRAME_WIDGET_CONFIG],
|
||||||
|
[TabsMigratorWidget, TABS_MIGRATOR_WIDGET_CONFIG],
|
||||||
|
[DividerWidget, DIVIDER_WIDGET_CONFIG],
|
||||||
|
[MenuButtonWidget, MENU_BUTTON_WIDGET_CONFIG],
|
||||||
|
[MultiSelectWidget, MULTI_SELECT_WIDGET_CONFIG],
|
||||||
|
[IconButtonWidget, ICON_BUTTON_WIDGET_CONFIG],
|
||||||
|
[CheckboxGroupWidget, CHECKBOX_GROUP_WIDGET_CONFIG],
|
||||||
|
[FilePickerWidgetV2, FILEPICKER_WIDGET_V2_CONFIG],
|
||||||
|
[StatboxWidget, STATBOX_WIDGET_CONFIG],
|
||||||
|
[AudioRecorderWidget, AUDIO_RECORDER_WIDGET_CONFIG],
|
||||||
|
[DocumentViewerWidget, DOCUMENT_VIEWER_WIDGET_CONFIG],
|
||||||
|
[ButtonGroupWidget, BUTTON_GROUP_CONFIG],
|
||||||
|
[MultiSelectTreeWidget, MULTI_SELECT_TREE_WIDGET_CONFIG],
|
||||||
|
[SingleSelectTreeWidget, SINGLE_SELECT_TREE_WIDGET_CONFIG],
|
||||||
|
[SwitchGroupWidget, SWITCH_GROUP_WIDGET_CONFIG],
|
||||||
|
[AudioWidget, AUDIO_WIDGET_CONFIG],
|
||||||
|
[ProgressBarWidget, PROGRESSBAR_WIDGET_CONFIG],
|
||||||
|
[CameraWidget, CAMERA_WIDGET_CONFIG],
|
||||||
|
[MapChartWidget, MAP_CHART_WIDGET_CONFIG],
|
||||||
|
];
|
||||||
|
|
||||||
export const registerWidgets = () => {
|
export const registerWidgets = () => {
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
registerWidget(CanvasWidget, CANVAS_WIDGET_CONFIG);
|
for (const widget of ALL_WDIGETS_AND_CONFIG) {
|
||||||
registerWidget(SkeletonWidget, SKELETON_WIDGET_CONFIG);
|
registerWidget(widget[0], widget[1] as WidgetConfiguration);
|
||||||
registerWidget(ContainerWidget, CONTAINER_WIDGET_CONFIG);
|
}
|
||||||
registerWidget(TextWidget, TEXT_WIDGET_CONFIG);
|
|
||||||
registerWidget(TableWidget, TABLE_WIDGET_CONFIG);
|
|
||||||
registerWidget(CheckboxWidget, CHECKBOX_WIDGET_CONFIG);
|
|
||||||
registerWidget(RadioGroupWidget, RADIO_GROUP_WIDGET_CONFIG);
|
|
||||||
registerWidget(ButtonWidget, BUTTON_WIDGET_CONFIG);
|
|
||||||
registerWidget(DropdownWidget, DROPDOWN_WIDGET_CONFIG);
|
|
||||||
registerWidget(ImageWidget, IMAGE_WIDGET_CONFIG);
|
|
||||||
registerWidget(VideoWidget, VIDEO_WIDGET_CONFIG);
|
|
||||||
registerWidget(TabsWidget, TABS_WIDGET_CONFIG);
|
|
||||||
registerWidget(InputWidget, INPUT_WIDGET_CONFIG);
|
|
||||||
registerWidget(ModalWidget, MODAL_WIDGET_CONFIG);
|
|
||||||
registerWidget(ChartWidget, CHART_WIDGET_CONFIG);
|
|
||||||
registerWidget(MapWidget, MAP_WIDGET_CONFIG);
|
|
||||||
registerWidget(FilePickerWidget, FILEPICKER_WIDGET_CONFIG);
|
|
||||||
registerWidget(RichTextEditorWidget, RICH_TEXT_EDITOR_WIDGET_CONFIG);
|
|
||||||
registerWidget(DatePickerWidget, DATE_PICKER_WIDGET_CONFIG);
|
|
||||||
registerWidget(DatePickerWidget2, DATE_PICKER_WIDGET_2_CONFIG);
|
|
||||||
registerWidget(SwitchWidget, SWITCH_WIDGET_CONFIG);
|
|
||||||
registerWidget(FormWidget, FORM_WIDGET_CONFIG);
|
|
||||||
registerWidget(FormButtonWidget, FORM_BUTTON_WIDGET_CONFIG);
|
|
||||||
registerWidget(IconWidget, ICON_WIDGET_CONFIG);
|
|
||||||
registerWidget(ListWidget, LIST_WIDGET_CONFIG);
|
|
||||||
registerWidget(RateWidget, RATE_WIDGET_CONFIG);
|
|
||||||
registerWidget(IframeWidget, IFRAME_WIDGET_CONFIG);
|
|
||||||
registerWidget(TabsMigratorWidget, TABS_MIGRATOR_WIDGET_CONFIG);
|
|
||||||
registerWidget(DividerWidget, DIVIDER_WIDGET_CONFIG);
|
|
||||||
registerWidget(MenuButtonWidget, MENU_BUTTON_WIDGET_CONFIG);
|
|
||||||
registerWidget(MultiSelectWidget, MULTI_SELECT_WIDGET_CONFIG);
|
|
||||||
registerWidget(IconButtonWidget, ICON_BUTTON_WIDGET_CONFIG);
|
|
||||||
registerWidget(CheckboxGroupWidget, CHECKBOX_GROUP_WIDGET_CONFIG);
|
|
||||||
registerWidget(FilePickerWidgetV2, FILEPICKER_WIDGET_V2_CONFIG);
|
|
||||||
registerWidget(StatboxWidget, STATBOX_WIDGET_CONFIG);
|
|
||||||
registerWidget(AudioRecorderWidget, AUDIO_RECORDER_WIDGET_CONFIG);
|
|
||||||
registerWidget(DocumentViewerWidget, DOCUMENT_VIEWER_WIDGET_CONFIG);
|
|
||||||
registerWidget(ButtonGroupWidget, BUTTON_GROUP_CONFIG);
|
|
||||||
registerWidget(MultiSelectTreeWidget, MULTI_SELECT_TREE_WIDGET_CONFIG);
|
|
||||||
registerWidget(SingleSelectTreeWidget, SINGLE_SELECT_TREE_WIDGET_CONFIG);
|
|
||||||
registerWidget(SwitchGroupWidget, SWITCH_GROUP_WIDGET_CONFIG);
|
|
||||||
registerWidget(AudioWidget, AUDIO_WIDGET_CONFIG);
|
|
||||||
registerWidget(ProgressBarWidget, PROGRESSBAR_WIDGET_CONFIG);
|
|
||||||
registerWidget(CameraWidget, CAMERA_WIDGET_CONFIG);
|
|
||||||
registerWidget(MapChartWidget, MAP_CHART_WIDGET_CONFIG);
|
|
||||||
|
|
||||||
log.debug("Widget registration took: ", performance.now() - start, "ms");
|
log.debug("Widget registration took: ", performance.now() - start, "ms");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
89
app/client/src/utils/testPropertyPaneConfig.test.ts
Normal file
89
app/client/src/utils/testPropertyPaneConfig.test.ts
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
import {
|
||||||
|
PropertyPaneConfig,
|
||||||
|
PropertyPaneControlConfig,
|
||||||
|
ValidationConfig,
|
||||||
|
} from "constants/PropertyControlConstants";
|
||||||
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
|
import { ALL_WDIGETS_AND_CONFIG } from "./WidgetRegistry";
|
||||||
|
|
||||||
|
function validatePropertyPaneConfig(config: PropertyPaneConfig[]) {
|
||||||
|
for (const sectionOrControlConfig of config) {
|
||||||
|
if (sectionOrControlConfig.children) {
|
||||||
|
for (const propertyControlConfig of sectionOrControlConfig.children) {
|
||||||
|
const propertyControlValidation = validatePropertyControl(
|
||||||
|
propertyControlConfig,
|
||||||
|
);
|
||||||
|
if (propertyControlValidation !== true)
|
||||||
|
return propertyControlValidation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePropertyControl(config: PropertyPaneConfig): boolean | string {
|
||||||
|
const _config = config as PropertyPaneControlConfig;
|
||||||
|
const controls = ["INPUT_TEXT"];
|
||||||
|
|
||||||
|
if (
|
||||||
|
(_config.isJSConvertible || controls.includes(_config.controlType)) &&
|
||||||
|
!_config.isTriggerProperty
|
||||||
|
) {
|
||||||
|
if (!_config.isBindProperty)
|
||||||
|
return `${
|
||||||
|
_config.propertyName
|
||||||
|
}: isBindProperty should be true if isJSConvertible is true or when control type is [${controls.join(
|
||||||
|
" | ",
|
||||||
|
)}]`;
|
||||||
|
if (!_config.validation)
|
||||||
|
return `${
|
||||||
|
_config.propertyName
|
||||||
|
}: validation should be defined if isJSConvertible is true or when control type is [${controls.join(
|
||||||
|
" | ",
|
||||||
|
)}]`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_config.validation !== undefined) {
|
||||||
|
const res = validateValidationStructure(_config.validation);
|
||||||
|
if (res !== true) return `${_config.propertyName}: ${res}`;
|
||||||
|
}
|
||||||
|
if (_config.children) {
|
||||||
|
for (const child of _config.children) {
|
||||||
|
const res = validatePropertyControl(child);
|
||||||
|
if (res !== true) return `${_config.propertyName}.${res}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_config.panelConfig) {
|
||||||
|
const res = validatePropertyPaneConfig(_config.panelConfig.children);
|
||||||
|
if (res !== true) return `${_config.propertyName}.${res}`;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateValidationStructure(
|
||||||
|
config: ValidationConfig,
|
||||||
|
): boolean | string {
|
||||||
|
if (
|
||||||
|
config.type === ValidationTypes.FUNCTION &&
|
||||||
|
config.params &&
|
||||||
|
config.params.fn
|
||||||
|
) {
|
||||||
|
if (!config.params.expected)
|
||||||
|
return `For a ${ValidationTypes.FUNCTION} type validation, expected type and example are mandatory`;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("Tests all widget's propertyPane config", () => {
|
||||||
|
ALL_WDIGETS_AND_CONFIG.forEach((widgetAndConfig) => {
|
||||||
|
const widget: any = widgetAndConfig[0];
|
||||||
|
it(`Checks ${widget.getWidgetType()}'s propertyPaneConfig`, () => {
|
||||||
|
const propertyPaneConfig = widget.getPropertyPaneConfig();
|
||||||
|
const validatedPropertyPaneConfig = validatePropertyPaneConfig(
|
||||||
|
propertyPaneConfig,
|
||||||
|
);
|
||||||
|
expect(validatedPropertyPaneConfig).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -132,9 +132,14 @@ class ButtonGroupWidget extends BaseWidget<
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
validation: { type: ValidationTypes.TEXT },
|
validation: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["SIMPLE", "MENU"],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "buttonColor",
|
propertyName: "buttonColor",
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ class DatePickerWidget extends BaseWidget<DatePickerWidgetProps, WidgetState> {
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
dateFormat: { type: ValidationTypes.TEXT },
|
validation: { type: ValidationTypes.TEXT },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "isRequired",
|
propertyName: "isRequired",
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,15 @@ class DividerWidget extends BaseWidget<DividerWidgetProps, WidgetState> {
|
||||||
propertyName: "dividerColor",
|
propertyName: "dividerColor",
|
||||||
label: "Divider Color",
|
label: "Divider Color",
|
||||||
controlType: "COLOR_PICKER",
|
controlType: "COLOR_PICKER",
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
helpText: "Controls the type of divider cap",
|
helpText: "Controls the type of divider cap",
|
||||||
|
|
@ -136,8 +142,16 @@ class DividerWidget extends BaseWidget<DividerWidgetProps, WidgetState> {
|
||||||
iconSize: "large",
|
iconSize: "large",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["nc", "arrow", "dot"],
|
||||||
|
required: true,
|
||||||
|
default: "arrow",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
helpText:
|
helpText:
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class FormButtonWidget extends ButtonWidget {
|
||||||
label: "Disabled Invalid Forms",
|
label: "Disabled Invalid Forms",
|
||||||
controlType: "SWITCH",
|
controlType: "SWITCH",
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
validation: { type: ValidationTypes.BOOLEAN },
|
validation: { type: ValidationTypes.BOOLEAN },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,12 @@ class ProgressBarWidget extends BaseWidget<
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,12 @@ export default [
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "isDisabled",
|
propertyName: "isDisabled",
|
||||||
|
|
@ -208,6 +214,12 @@ export default [
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"primaryColumns",
|
"primaryColumns",
|
||||||
"derivedColumns",
|
"derivedColumns",
|
||||||
|
|
@ -230,6 +242,12 @@ export default [
|
||||||
customJSControl: "COMPUTE_VALUE",
|
customJSControl: "COMPUTE_VALUE",
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.BOOLEAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"primaryColumns",
|
"primaryColumns",
|
||||||
|
|
@ -347,6 +365,36 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"Epoch",
|
||||||
|
"Milliseconds",
|
||||||
|
"YYYY-MM-DD",
|
||||||
|
"YYYY-MM-DD HH:mm",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss.sssZ",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss",
|
||||||
|
"YYYY-MM-DD hh:mm:ss",
|
||||||
|
"Do MMM YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YYYY HH:mm",
|
||||||
|
"LLL",
|
||||||
|
"LL",
|
||||||
|
"D MMMM, YYYY",
|
||||||
|
"H:mm A D MMMM, YYYY",
|
||||||
|
"MM-DD-YYYY",
|
||||||
|
"DD-MM-YYYY",
|
||||||
|
"MM/DD/YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YY",
|
||||||
|
"MM/DD/YY",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -454,6 +502,36 @@ export default [
|
||||||
"columnType",
|
"columnType",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"Epoch",
|
||||||
|
"Milliseconds",
|
||||||
|
"YYYY-MM-DD",
|
||||||
|
"YYYY-MM-DD HH:mm",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss.sssZ",
|
||||||
|
"YYYY-MM-DDTHH:mm:ss",
|
||||||
|
"YYYY-MM-DD hh:mm:ss",
|
||||||
|
"Do MMM YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YYYY HH:mm",
|
||||||
|
"LLL",
|
||||||
|
"LL",
|
||||||
|
"D MMMM, YYYY",
|
||||||
|
"H:mm A D MMMM, YYYY",
|
||||||
|
"MM-DD-YYYY",
|
||||||
|
"DD-MM-YYYY",
|
||||||
|
"MM/DD/YYYY",
|
||||||
|
"DD/MM/YYYY",
|
||||||
|
"DD/MM/YY",
|
||||||
|
"MM/DD/YY",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -526,6 +604,15 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["LEFT", "CENTER", "RIGHT"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -574,6 +661,21 @@ export default [
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: [
|
||||||
|
"HEADING1",
|
||||||
|
"HEADING2",
|
||||||
|
"HEADING3",
|
||||||
|
"PARAGRAPH",
|
||||||
|
"PARAGRAPH2",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "fontStyle",
|
propertyName: "fontStyle",
|
||||||
|
|
@ -603,6 +705,12 @@ export default [
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "verticalAlignment",
|
propertyName: "verticalAlignment",
|
||||||
|
|
@ -632,6 +740,15 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["TOP", "CENTER", "BOTTOM"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -647,6 +764,15 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -662,6 +788,15 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -797,6 +932,15 @@ export default [
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -872,12 +1016,15 @@ export default [
|
||||||
"derivedColumns",
|
"derivedColumns",
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
validation: {
|
validation: {
|
||||||
type: ValidationTypes.TEXT,
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
params: {
|
params: {
|
||||||
allowedValues: ["CIRCLE", "SHARP", "ROUNDED"],
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
allowedValues: ["CIRCLE", "SHARP", "ROUNDED"],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -899,19 +1046,22 @@ export default [
|
||||||
"derivedColumns",
|
"derivedColumns",
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
validation: {
|
validation: {
|
||||||
type: ValidationTypes.TEXT,
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
params: {
|
params: {
|
||||||
allowedValues: [
|
type: ValidationTypes.TEXT,
|
||||||
"NONE",
|
params: {
|
||||||
"VARIANT1",
|
allowedValues: [
|
||||||
"VARIANT2",
|
"NONE",
|
||||||
"VARIANT3",
|
"VARIANT1",
|
||||||
"VARIANT4",
|
"VARIANT2",
|
||||||
"VARIANT5",
|
"VARIANT3",
|
||||||
],
|
"VARIANT4",
|
||||||
|
"VARIANT5",
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -932,7 +1082,16 @@ export default [
|
||||||
"derivedColumns",
|
"derivedColumns",
|
||||||
"columnOrder",
|
"columnOrder",
|
||||||
],
|
],
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -954,6 +1113,15 @@ export default [
|
||||||
updateHook: updateDerivedColumnsHook,
|
updateHook: updateDerivedColumnsHook,
|
||||||
isBindProperty: true,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -962,11 +1130,19 @@ export default [
|
||||||
"Sets the custom color preset based on the menu button variant",
|
"Sets the custom color preset based on the menu button variant",
|
||||||
label: "Menu Color",
|
label: "Menu Color",
|
||||||
controlType: "COLOR_PICKER",
|
controlType: "COLOR_PICKER",
|
||||||
isBindProperty: false,
|
isBindProperty: true,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
isJSConvertible: true,
|
isJSConvertible: true,
|
||||||
placeholderText: "#FFFFFF / Gray / rgb(255, 99, 71)",
|
placeholderText: "#FFFFFF / Gray / rgb(255, 99, 71)",
|
||||||
validation: { type: ValidationTypes.TEXT },
|
validation: {
|
||||||
|
type: ValidationTypes.TABLE_PROPERTY,
|
||||||
|
params: {
|
||||||
|
type: ValidationTypes.TEXT,
|
||||||
|
params: {
|
||||||
|
regex: /^(?![<|{{]).+/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
hidden: (props: TableWidgetProps, propertyPath: string) => {
|
hidden: (props: TableWidgetProps, propertyPath: string) => {
|
||||||
return hideByColumnType(props, propertyPath, [
|
return hideByColumnType(props, propertyPath, [
|
||||||
ColumnTypes.MENU_BUTTON,
|
ColumnTypes.MENU_BUTTON,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user