## Description - Remove the config objects from widget and config maps from the widget factory. - Introduce methods in widget development API to dynamically fetch this items. - freeze the widget configuration. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/26008 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
153 lines
5.8 KiB
TypeScript
153 lines
5.8 KiB
TypeScript
import { getPropertyControlTypes } from "components/propertyControls";
|
|
import type {
|
|
ValidationResponse,
|
|
ValidationTypes,
|
|
} from "constants/WidgetValidation";
|
|
import type { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
|
import type { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
|
import type { UpdateWidgetPropertyPayload } from "actions/controlActions";
|
|
import type { AdditionalDynamicDataTree } from "utils/autocomplete/customTreeTypeDefCreator";
|
|
import type { Stylesheet } from "entities/AppTheming";
|
|
import type { ReduxActionType } from "@appsmith/constants/ReduxActionConstants";
|
|
import type { PropertyUpdates } from "WidgetProvider/constants";
|
|
|
|
const ControlTypes = getPropertyControlTypes();
|
|
export type ControlType = (typeof ControlTypes)[keyof typeof ControlTypes];
|
|
|
|
export type PropertyPaneSectionConfig = {
|
|
sectionName: string;
|
|
id?: string;
|
|
children: PropertyPaneConfig[];
|
|
collapsible?: boolean; // Indicates whether the section could be collapsed or not
|
|
childrenId?: string; // A unique id generated by combining the ids of all the children
|
|
hidden?: (props: any, propertyPath: string) => boolean;
|
|
isDefaultOpen?: boolean;
|
|
propertySectionPath?: string;
|
|
tag?: string; // Used to show a tag right after the section name (only in the search results)
|
|
};
|
|
|
|
export type PanelConfig = {
|
|
editableTitle: boolean;
|
|
titlePropertyName: string;
|
|
panelIdPropertyName: string;
|
|
children?: PropertyPaneConfig[];
|
|
contentChildren?: PropertyPaneConfig[];
|
|
styleChildren?: PropertyPaneConfig[];
|
|
searchConfig?: PropertyPaneConfig[]; // A combination of contentChildren and contentChildren which will be used to display search results
|
|
updateHook: (
|
|
props: any,
|
|
propertyPath: string,
|
|
propertyValue: any,
|
|
) => Array<PropertyUpdates> | undefined;
|
|
};
|
|
|
|
export type PropertyPaneControlConfig = {
|
|
id?: string;
|
|
label: string;
|
|
propertyName: string;
|
|
// Serves in the tooltip
|
|
helpText?: string;
|
|
//Dynamic text serves below the property pane inputs
|
|
helperText?: ((props: any) => string) | string;
|
|
isJSConvertible?: boolean;
|
|
customJSControl?: string;
|
|
controlType: ControlType;
|
|
validationMessage?: string;
|
|
dataTreePath?: string;
|
|
children?: PropertyPaneConfig[];
|
|
panelConfig?: PanelConfig;
|
|
updateRelatedWidgetProperties?: (
|
|
propertyName: string,
|
|
propertyValue: any,
|
|
props: any,
|
|
) => UpdateWidgetPropertyPayload[];
|
|
updateHook?: (
|
|
props: any,
|
|
propertyName: string,
|
|
propertyValue: any,
|
|
) => Array<PropertyUpdates> | undefined;
|
|
hidden?: (props: any, propertyPath: string) => boolean;
|
|
invisible?: boolean;
|
|
isBindProperty: boolean;
|
|
isTriggerProperty: boolean;
|
|
validation?: ValidationConfig;
|
|
useValidationMessage?: boolean;
|
|
additionalAutoComplete?: (props: any) => AdditionalDynamicDataTree;
|
|
evaluationSubstitutionType?: EvaluationSubstitutionType;
|
|
dependencies?: string[];
|
|
evaluatedDependencies?: string[]; // dependencies to be picked from the __evaluated__ object
|
|
expected?: CodeEditorExpected;
|
|
getStylesheetValue?: (
|
|
props: any,
|
|
propertyPath: string,
|
|
stylesheet?: Stylesheet,
|
|
) => Stylesheet[string];
|
|
// TODO(abhinav): To fix this, rename the options property of the controls which use this
|
|
// Alternatively, create a new structure
|
|
options?: any;
|
|
// The following should ideally be used internally
|
|
postUpdateAction?: ReduxActionType;
|
|
onBlur?: () => void;
|
|
onFocus?: () => void;
|
|
isPanelProperty?: boolean;
|
|
// Numeric Input Control
|
|
min?: number;
|
|
// Switch mode ( JS -> Text )
|
|
shouldSwitchToNormalMode?: (
|
|
isDynamic: boolean,
|
|
isToggleDisabled: boolean,
|
|
triggerFlag?: boolean,
|
|
) => boolean;
|
|
};
|
|
|
|
type ValidationConfigParams = {
|
|
min?: number; // min allowed for a number
|
|
max?: number; // max allowed for a number
|
|
natural?: boolean; // is a positive integer
|
|
default?: unknown; // default for any type
|
|
unique?: boolean | string[]; // unique in an array (string if a particular path is unique)
|
|
required?: boolean; // required type
|
|
// required is now used to check if value is an empty string.
|
|
requiredKey?: boolean; //required key
|
|
regex?: RegExp; // validator regex for text type
|
|
allowedKeys?: Array<{
|
|
// Allowed keys in an object type
|
|
name: string;
|
|
type: ValidationTypes;
|
|
params?: ValidationConfigParams;
|
|
}>;
|
|
allowedValues?: unknown[]; // Allowed values in a string and array type
|
|
children?: ValidationConfig; // Children configurations in an ARRAY or OBJECT_ARRAY type
|
|
fn?: (
|
|
value: unknown,
|
|
props: any,
|
|
_?: any,
|
|
moment?: any,
|
|
) => ValidationResponse; // Function in a FUNCTION type
|
|
fnString?: string; // AUTO GENERATED, SHOULD NOT BE SET BY WIDGET DEVELOPER
|
|
expected?: CodeEditorExpected; // FUNCTION type expected type and example
|
|
strict?: boolean; //for strict string validation of TEXT type
|
|
ignoreCase?: boolean; //to ignore the case of key
|
|
type?: ValidationTypes; // Used for ValidationType.ARRAY_OF_TYPE_OR_TYPE to define sub type
|
|
types?: ValidationConfig[]; // Used for ValidationType.UNION to define sub type
|
|
params?: ValidationConfigParams; // Used for ValidationType.ARRAY_OF_TYPE_OR_TYPE to define sub type params
|
|
passThroughOnZero?: boolean; // Used for ValidationType.NUMBER to allow 0 to be passed through. Deafults value is true
|
|
limitLineBreaks?: boolean; // Used for ValidationType.TEXT to limit line breaks in a large json object.
|
|
defaultValue?: unknown; // used for ValidationType.UNION when none the union type validation is success
|
|
defaultErrorMessage?: string; // used for ValidationType.UNION when none the union type validation is success
|
|
};
|
|
|
|
export type ValidationConfig = {
|
|
type: ValidationTypes;
|
|
params?: ValidationConfigParams;
|
|
dependentPaths?: string[];
|
|
};
|
|
|
|
export type PropertyPaneConfig =
|
|
| PropertyPaneSectionConfig
|
|
| PropertyPaneControlConfig;
|
|
|
|
export interface ActionValidationConfigMap {
|
|
[configProperty: string]: ValidationConfig;
|
|
}
|