PromucFlow_constructor/app/client/src/components/formControls/BaseControl.tsx
Nilansh Bansal b3f1805e36
feat: Flagsmith Integration (#24472)
## Description
> This PR integrates Flagsmith feature flagging into the Appsmith
codebase
> It also sets some default traits such as instance_id, tenant_id and
email/hashed email to the new and existing users

#### PR fixes following issue(s)
Fixes #24037 


#### Type of change
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)

## 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
- [ ] 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
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] 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
- [ ] 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
- [ ] 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

---------

Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
2023-06-27 16:15:33 +05:30

108 lines
2.9 KiB
TypeScript

import { Component } from "react";
import type { ControlType } from "constants/PropertyControlConstants";
import type { InputType } from "components/constants";
import type { ConditonalObject } from "reducers/evaluationReducers/formEvaluationReducer";
import type { DropdownOption } from "design-system-old";
import type { ViewTypes } from "./utils";
import type { FeatureFlag } from "@appsmith/entities/FeatureFlag";
// eslint-disable-next-line @typescript-eslint/ban-types
abstract class BaseControl<P extends ControlProps, S = {}> extends Component<
P,
S
> {
abstract getControlType(): ControlType;
}
export type ComparisonOperations =
| "EQUALS"
| "NOT_EQUALS"
| "LESSER"
| "GREATER"
| "IN"
| "NOT_IN"
| "FEATURE_FLAG"
| "VIEW_MODE";
export enum ComparisonOperationsEnum {
VIEW_MODE = "VIEW_MODE",
}
export type HiddenType = boolean | Condition | ConditionObject;
export type ConditionObject = { conditionType: string; conditions: Conditions };
export type Condition = {
path: string;
comparison: ComparisonOperations;
value: any;
flagValue: FeatureFlag;
};
export type Conditions = Array<Condition> | ConditionObject;
export interface ControlBuilder<T extends ControlProps> {
buildPropertyControl(controlProps: T): JSX.Element;
}
export interface ControlProps extends ControlData, ControlFunctions {
key?: string;
extraData?: ControlData[];
formName: string;
nestedFormControl?: boolean;
}
export interface ControlData {
id: string;
label: string;
alternateViewTypes?: ViewTypes[];
tooltipText?: string | Record<string, string>;
configProperty: string;
controlType: ControlType;
propertyValue?: any;
isValid: boolean;
validationMessage?: string;
validationRegex?: string;
dataType?: InputType;
initialValue?:
| string
| boolean
| number
| Record<string, string>
| Array<string>;
info?: string; //helper text
isRequired?: boolean;
conditionals?: ConditonalObject; // Object that contains the conditionals config
hidden?: HiddenType;
placeholderText?: string | Record<string, string>;
schema?: any;
errorText?: string;
showError?: boolean;
encrypted?: boolean;
subtitle?: string;
showLineNumbers?: boolean;
url?: string;
urlText?: string;
logicalTypes?: string[];
comparisonTypes?: string[];
nestedLevels?: number;
customStyles?: any;
propertyName?: string;
identifier?: string;
sectionName?: string;
disabled?: boolean;
staticDependencyPathList?: string[];
validator?: (value: string) => { isValid: boolean; message: string };
isSecretExistsPath?: string;
}
export type FormConfigType = Omit<ControlData, "configProperty"> & {
configProperty?: string;
children?: FormConfigType[];
options?: DropdownOption[];
fetchOptionsConditionally?: boolean;
};
export interface ControlFunctions {
onPropertyChange?: (propertyName: string, propertyValue: string) => void;
}
export default BaseControl;