PromucFlow_constructor/app/client/src/components/formControls/utils.ts

520 lines
15 KiB
TypeScript
Raw Normal View History

feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
import { DATA_BIND_REGEX_GLOBAL } from "constants/BindingsConstants";
import { isBoolean, get, set, isString } from "lodash";
import {
ConditionalOutput,
FormConfigEvalObject,
FormEvalOutput,
} from "reducers/evaluationReducers/formEvaluationReducer";
import { FormConfigType, HiddenType } from "./BaseControl";
import { diff, Diff } from "deep-diff";
import { MongoDefaultActionConfig } from "constants/DatasourceEditorConstants";
import { Action } from "@sentry/react/dist/types";
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
import { klona } from "klona/full";
2021-04-05 10:11:04 +00:00
export const evaluateCondtionWithType = (
conditions: Array<boolean> | undefined,
type: string | undefined,
) => {
if (conditions) {
let flag;
//this is where each conditions gets evaluated
if (conditions.length > 1) {
if (type === "AND") {
flag = conditions.reduce((acc: any, item: boolean) => {
return acc && item;
}, conditions[0]);
} else if (type === "OR") {
flag = conditions.reduce((acc: any, item: boolean) => {
return acc || item;
}, undefined);
}
} else {
flag = conditions[0];
}
return flag;
}
};
export const isHiddenConditionsEvaluation = (
values: any,
hidden?: HiddenType,
): any => {
if (!!hidden && !isBoolean(hidden)) {
//if nested condtions are there recursively from bottom to top call this function on each condtion
let conditionType, conditions;
if ("conditionType" in hidden) {
conditionType = hidden.conditionType;
}
if ("conditions" in hidden) {
conditions = hidden.conditions;
}
if (Array.isArray(conditions)) {
conditions = conditions.map((rule: any) => {
return isHiddenConditionsEvaluation(values, rule);
});
} else {
return caculateIsHidden(values, hidden);
}
return evaluateCondtionWithType(conditions, conditionType);
}
};
export const caculateIsHidden = (values: any, hiddenConfig?: HiddenType) => {
if (!!hiddenConfig && !isBoolean(hiddenConfig)) {
2021-04-05 10:11:04 +00:00
let valueAtPath;
let value, comparison;
if ("path" in hiddenConfig) {
valueAtPath = get(values, hiddenConfig.path);
}
if ("value" in hiddenConfig) {
value = hiddenConfig.value;
}
if ("comparison" in hiddenConfig) {
comparison = hiddenConfig.comparison;
}
2021-04-05 10:11:04 +00:00
switch (comparison) {
case "EQUALS":
return valueAtPath === value;
case "NOT_EQUALS":
return valueAtPath !== value;
case "GREATER":
return valueAtPath > value;
case "LESSER":
return valueAtPath < value;
case "IN":
return Array.isArray(value) && value.includes(valueAtPath);
case "NOT_IN":
return Array.isArray(value) && !value.includes(valueAtPath);
default:
return true;
}
}
2021-04-05 10:11:04 +00:00
};
2021-04-05 10:11:04 +00:00
export const isHidden = (values: any, hiddenConfig?: HiddenType) => {
if (!!hiddenConfig && !isBoolean(hiddenConfig)) {
if ("conditionType" in hiddenConfig) {
//check if nested conditions exist
return isHiddenConditionsEvaluation(values, hiddenConfig);
} else {
return caculateIsHidden(values, hiddenConfig);
}
}
return !!hiddenConfig;
};
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
export enum ViewTypes {
JSON = "json",
COMPONENT = "component",
}
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
export const alternateViewTypeInputConfig = () => {
return {
label: "",
isValid: true,
controlType: "QUERY_DYNAMIC_INPUT_TEXT",
evaluationSubstitutionType: "TEMPLATE",
inputType: "TEXT_WITH_BINDING",
// showLineNumbers: true,
};
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
};
export const getViewType = (values: any, configProperty: string) => {
if (
configProperty.startsWith("actionConfiguration.formData") &&
configProperty.endsWith(".data")
) {
const pathForViewType = configProperty.replace(".data", ".viewType");
return get(values, pathForViewType, ViewTypes.COMPONENT);
} else {
return ViewTypes.COMPONENT;
}
};
export const switchViewType = (
values: any,
configProperty: string,
viewType: string,
formName: string,
changeFormValue: (formName: string, path: string, value: any) => void,
) => {
const newViewType =
viewType === ViewTypes.JSON ? ViewTypes.COMPONENT : ViewTypes.JSON;
const pathForJsonData = configProperty.replace(".data", ".jsonData");
const pathForComponentData = configProperty.replace(
".data",
".componentData",
);
const jsonData = get(values, pathForJsonData);
const componentData = get(values, pathForComponentData);
const currentData = get(values, configProperty, "");
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
const stringifiedCurrentData = JSON.stringify(currentData, null, "\t");
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
if (newViewType === ViewTypes.JSON) {
changeFormValue(formName, pathForComponentData, currentData);
if (!!jsonData) {
changeFormValue(formName, configProperty, jsonData);
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
} else {
changeFormValue(
formName,
configProperty,
isString(currentData)
? currentData
: stringifiedCurrentData.replace(/\\/g, ""),
);
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
}
} else {
changeFormValue(formName, pathForJsonData, currentData);
if (!!componentData) {
changeFormValue(formName, configProperty, componentData);
}
}
changeFormValue(
formName,
configProperty.replace(".data", ".viewType"),
newViewType,
);
};
// Function that extracts the initial value from the JSON configs
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
export const getConfigInitialValues = (
config: Record<string, any>[],
multipleViewTypesSupported = false,
) => {
const configInitialValues: Record<string, any> = {};
// We expect the JSON configs to be an array of objects
if (!Array.isArray(config)) return configInitialValues;
// Function to loop through the configs and extract the initial values
const parseConfig = (section: any): any => {
if ("initialValue" in section) {
if (section.controlType === "KEYVALUE_ARRAY") {
section.initialValue.forEach(
(initialValue: string | number, index: number) => {
const configProperty = section.configProperty.replace("*", index);
set(configInitialValues, configProperty, initialValue);
},
);
} else {
set(configInitialValues, section.configProperty, section.initialValue);
}
} else if (section.controlType === "WHERE_CLAUSE") {
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
let logicalTypes = [];
if ("logicalTypes" in section && section.logicalTypes.length > 0) {
logicalTypes = section.logicalTypes;
} else {
logicalTypes = [
{
label: "OR",
value: "OR",
},
{
label: "AND",
value: "AND",
},
];
}
set(
configInitialValues,
`${section.configProperty}.condition`,
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
logicalTypes[0].value,
);
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
if (
multipleViewTypesSupported &&
section.configProperty.includes(".data")
) {
set(
configInitialValues,
section.configProperty.replace(".data", ".viewType"),
"component",
);
set(
configInitialValues,
section.configProperty.replace(".data", ".componentData.condition"),
logicalTypes[0].value,
);
}
}
if ("children" in section) {
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
section.children.forEach((childSection: any) => {
parseConfig(childSection);
});
} else if ("schema" in section) {
section.schema.forEach((childSection: any) => {
parseConfig(childSection);
});
feat: Switch to JSON view functionality for form components (#11786) * Update: Added flag check for evals - Only running init form evals if the form is of new UQI config * Create: Separated Form config logic - Created a new file to render the form configs of any form component * Update: Enum and getter for view types - Added enum for view types - Added a function to extract the view type of current component * Update: Handling initial values of form - Added checks and updated the default data tree for the components of UQI forms - This is to allow to switch these components to the new data type * Update: updated type of control data - Added viewTypes to the type of form component's control data * Create: Function to change viewType - Added function that will check the current data and switch to the new view type * Update FormControl.tsx - Split the logic of form config to a new file - Updated the memo component to a function so custom config can be passed in it - Added conditional check for the final component * Create: wrapper component to switch view - Component added to change between GUI and JSON view types * Update: Variable name for alternate view types - Changed variable name for alternate view types from viewTypes to alternateViewTypes * Update: Added checks to init section - Added a check for the required values in where clause component * Update: Usage of useMemo hook - Moved the useMemo hook to the top so it is not called conditionally * Update ToggleComponentToJson.tsx - Moved toggled input text view as a constant variable * Update utils.ts - Moved toggled input text view as a constant variable * Update actionProperties.ts - Added switched view type input text to binding path list Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-21 05:51:50 +00:00
} else if (
"configProperty" in section &&
multipleViewTypesSupported &&
section.configProperty.includes(".data")
) {
set(
configInitialValues,
section.configProperty.replace(".data", ".viewType"),
"component",
);
if (section.configProperty in configInitialValues) {
set(
configInitialValues,
section.configProperty.replace(".data", ".componentData"),
configInitialValues[section.configProperty],
);
}
}
};
config.forEach((section: any) => {
parseConfig(section);
});
return configInitialValues;
};
Introducing Google Sheets Plugin (#3517) * cherry pick -make new * revert to enable fix from release * attempt to hook into existing datasource editor * gSheets plugin skeleton from Rest API * Changes for database migration * fix for auth code * separate it out * action page loads! * add to explorer * create action from datasource * Editor JSON WIP * working query form * Editor JSON WIP * import to * fix toast message * redirect from datasource and editor pages * fix onboarding * fix imports and constants * refactor form out * refactor queryForm * Merge branch 'release' into feature/google-sheets * Merge branch 'release' into feature/google-sheets * initial values from settings, editor and form * Check * remove dangling code around lightTheme * Safety net * remove class * try mouseover solve * force click * changes from review * fix action form name on import * Merge branch 'release' into feature/google-sheets * minor cleanup * Merge branch 'release' into feature/google-sheets * WIP * Google sheets changes * Merge conflicts * Merging and fixes, needs refactoring * Check * Merge branch 'release' into feature/google-sheets * Fixed tests * Add cloud services env variable * Clean up saga * Clean up * Refactoring * Deleted svg file * Minor fixes * Modified design to allow behaviour in google sheets methods (#3486) * Modified design to allow behaviour in google sheets methods * Review changes * Removed sysout * Added handling of edge cases with table data * Merge branch 'release' into feature/google-sheets * Fixes * Fixes * Added validations * Improved tests * Removed extraneous injected bean * Review changes * Fixed bug with method * Changes to Google sheets plugin's request and response structures (#3692) * Method changes * Removed logging * Renaming options * Reverting pom version * Modified type of collection variables, fixed errors * Converted row offset field to one that supports dynamic bindings * Review changes * List SAAS plugin type actions under lightning menu apis (#3820) * list saas plugin type actions under lightning menu apis * combine saas plugin type actions in the other sub menu of lightning menu Co-authored-by: Hetu Nandu <hetunandu@gmail.com> * Fix merge issues * Prettified query editor and a few fixes w/ ux * Test fixes * Reformatting request * code for REST added (#3876) Co-authored-by: hetunandu <hetu@appsmith.com> * Renamed body to row object * Renamed placeholder for range * Renamed range heading * Modifications to handle range semantics * Use spreadsheet Url instead of id * Ordering of methods * Removed logging * Add tests for Dynamic text controls * Add tests for url helpers * Fix coverage config * Nevermind * Interface changes * There is no body here * Yay to hints * Delete row field is separately handled as row index * placeholder support (#4001) * Fixed tests, typos and creating new sheets with random rows * Switched to using 'rowIndex' throughout * binding path added for query input field (#4016) * - Fixed QA bugs (#4032) - Split delete sheet into two - Removed dynamic query input types from hidden keys * Proper exceptions * Removed extra logging * Throw exception if update method does not match any of the columns * Same for bulk update * Zero-indexed delete row * I'm a space bound rocket ship * Logic to register installations with cs (#4062) * Logic to register installations with cs * Clean up * Casting to string * Checking to see if this makes the test pass * Added an extra null check Co-authored-by: Piyush <piyush@codeitout.com> Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com>
2021-04-22 03:30:09 +00:00
export const actionPathFromName = (
actionName: string,
name: string,
): string => {
const ActionConfigStarts = "actionConfiguration.";
let path = name;
if (path.startsWith(ActionConfigStarts)) {
path = "config." + path.slice(ActionConfigStarts.length);
Introducing Google Sheets Plugin (#3517) * cherry pick -make new * revert to enable fix from release * attempt to hook into existing datasource editor * gSheets plugin skeleton from Rest API * Changes for database migration * fix for auth code * separate it out * action page loads! * add to explorer * create action from datasource * Editor JSON WIP * working query form * Editor JSON WIP * import to * fix toast message * redirect from datasource and editor pages * fix onboarding * fix imports and constants * refactor form out * refactor queryForm * Merge branch 'release' into feature/google-sheets * Merge branch 'release' into feature/google-sheets * initial values from settings, editor and form * Check * remove dangling code around lightTheme * Safety net * remove class * try mouseover solve * force click * changes from review * fix action form name on import * Merge branch 'release' into feature/google-sheets * minor cleanup * Merge branch 'release' into feature/google-sheets * WIP * Google sheets changes * Merge conflicts * Merging and fixes, needs refactoring * Check * Merge branch 'release' into feature/google-sheets * Fixed tests * Add cloud services env variable * Clean up saga * Clean up * Refactoring * Deleted svg file * Minor fixes * Modified design to allow behaviour in google sheets methods (#3486) * Modified design to allow behaviour in google sheets methods * Review changes * Removed sysout * Added handling of edge cases with table data * Merge branch 'release' into feature/google-sheets * Fixes * Fixes * Added validations * Improved tests * Removed extraneous injected bean * Review changes * Fixed bug with method * Changes to Google sheets plugin's request and response structures (#3692) * Method changes * Removed logging * Renaming options * Reverting pom version * Modified type of collection variables, fixed errors * Converted row offset field to one that supports dynamic bindings * Review changes * List SAAS plugin type actions under lightning menu apis (#3820) * list saas plugin type actions under lightning menu apis * combine saas plugin type actions in the other sub menu of lightning menu Co-authored-by: Hetu Nandu <hetunandu@gmail.com> * Fix merge issues * Prettified query editor and a few fixes w/ ux * Test fixes * Reformatting request * code for REST added (#3876) Co-authored-by: hetunandu <hetu@appsmith.com> * Renamed body to row object * Renamed placeholder for range * Renamed range heading * Modifications to handle range semantics * Use spreadsheet Url instead of id * Ordering of methods * Removed logging * Add tests for Dynamic text controls * Add tests for url helpers * Fix coverage config * Nevermind * Interface changes * There is no body here * Yay to hints * Delete row field is separately handled as row index * placeholder support (#4001) * Fixed tests, typos and creating new sheets with random rows * Switched to using 'rowIndex' throughout * binding path added for query input field (#4016) * - Fixed QA bugs (#4032) - Split delete sheet into two - Removed dynamic query input types from hidden keys * Proper exceptions * Removed extra logging * Throw exception if update method does not match any of the columns * Same for bulk update * Zero-indexed delete row * I'm a space bound rocket ship * Logic to register installations with cs (#4062) * Logic to register installations with cs * Clean up * Casting to string * Checking to see if this makes the test pass * Added an extra null check Co-authored-by: Piyush <piyush@codeitout.com> Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com>
2021-04-22 03:30:09 +00:00
}
return `${actionName}.${path}`;
};
export enum PaginationSubComponent {
Limit = "limit",
Offset = "offset",
}
export enum SortingSubComponent {
Column = "column",
Order = "order",
}
export enum WhereClauseSubComponent {
Condition = "condition",
Children = "children",
Key = "key",
Value = "value",
}
export const allowedControlTypes = ["DROP_DOWN", "QUERY_DYNAMIC_INPUT_TEXT"];
feat: Simplified Google Sheets queries (#14869) * Client changes 1 * add DSL functionality * Temp commit for refactoring changes * Do I even know what I'm doing here? * chore: Second GS layout * Update: Visibility conditional outputs for schemas - Added the output from conditional outputs for schema children too * Update: Entity selector visibility control - Added logic for controlling visibility of sub components via the JS expressions system * Update: Passing disabled prop to toggle button * Update: Passing disabled prop to toggle btn * Update: Styled component for toggle button - Added disabled styles based on the disabled prop sent to the toggle form view JSON button * Update: configProperty role in Entity Selector - Removed dependance of the configProperty of the entity selector children to it's parent component * Update: type of placeholder key - Made placeholder key from form config JSON to accept either string or an object - Earlier only string was accepted - This is for pagination component * Update: Added placeholder control for pagination * Client changes 1 * add DSL functionality * Do I even know what I'm doing here? * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * temp triggers * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design (#12395) * fix: updated uqi forms ui, clubbed JS switch button to ads, updated tooltip design * fix: updated tooltip component for wrong ui on entity explore * fix: updated tooltip ui, where condition placement, sort by ui * temp form data access logic * fix: updated sorting type width ui * fix: updated ui for spacing, width and text issues * Update: Type for tooltip of UQI forms - Added option to send an object to the tooltipText object. - This allows for composite components like pagination to have tooltips for each sub component * Update: tooltip for pagination component - Added handling to parse the tooltip for multiple components. - This allows for composite components like pagination to have tooltips for each sub component * Update: Type cast for tooltip component - Made the content passed to tooltip component as a string only * Update: Fixed tooltip component CSS * Update: Dropdown option component - Added a tooltip wrapper to each option - This is to show on hover text like disabled state * fix: updated ẇhere clause broken ui for condition * Add: functions to check and extract expressions - Loop through the formConfig and find any keys that have a value that is bindable - Used pre defined regex to check if value is a moustache binding * Add: Types for evaluated form configs - Added types for the form configs to be evaluated and their output post eval * Add: Flow to run the form config - Run the form config and update the result to the redux state * Update: Name of the type for formconfigs - Updated since it was clashing with a component of the same name * Add: Function to enforce config type checks - This is done so that the improper configs can be weeded out and the rest of the form can be shown * Add: Function to update evaluated config - Added option to update the config if it's values needed evaluation * Add: Type check for schema sections * Update: Error handling for invalid control type - We were throwing an exception till now, changed it to a warning text * Add: Exposed tooltip for dropdown option disabled state * Update: switch to json mode functionality - Added logic to convert data to a string rather than an object when the first switch to JSON mode happens * Update: Added key to tooltip for dropdown options * Trigger API modification * Add: function to fetch default trigger URL * Update: Made URL optional in dynamic trigger config * Update: Dynamic trigger API call - Made the API call for dynamic triggers have URL as optional field - Added type check to the response of the API call * Update: resp type for trigger APIs * Update: Moved code to utils folder - Moved functions for UQI form eval processing to utils file * Update: passing original controltype to JS switch * Update: config for JSON editor mode - Updated the config to have different options for JSON mode depending on the original control type * Update: Connected line numbers flag to config * Revert: CSS changes for tooltip * Refactor: Removed consle * Add: type for the config of dynamic values * Add: Feature to evaluate config for triggers * Refactor: fix type check errors * fix: dropdown ui width with text alignment * Update: fixed selector for dynamic values * Update: selector call for fetchDynamicValues * Add table header index prop for columns selector * migration partial commit * migration partial commit * Refactor: removed unused import * Update: reused function for checking dynamic value * Update: removed unused import * Fix format JSON issues * Retrieve binding paths from entity selector components * Fixes 6 remaining issues with UQI implementation * Fix dropdown issues * Fix dropdown height issues and fixes triggering of APIs when option is deselected * Migration changes * Fix QA generated UQI issues * Fix projection component height and route change logic * Fix multi select dropdown placeholder text issue and json stringify issue with switching view types * Reset entity type value when command value changes * Test changes * Review comments * Moved migrations around * Corrected import statement * Added JSON schema migration * Updated schema version * perf improvements and filter dropdown options feature * Fix Code mirror component config for toggleComponentToJson input fields. * Fix prettier issues * fix prettier issues * Fix style issues as a result of the merged conflicts * Fix failing test case * Fixed a few other flows (#14225) * Fixed a few other flows * Review comments * Fix generate CRUD, fix evaluation of dynamic bindings and fix various styling issues. * More fixes (#14367) * Factor in the root formconfig parent key. * Fix flickering issues, and evaluatedFormConfig issues * fix: Teeny bugs (#14455) * Teeny bugs * Added previous functionality as is * Improvements in the way we fetch dynamic values * Fix stringiification issue and cyclic dependency issues * Resolve projection component values deletion * Resolve merge conflicts and fix prettier issues * fix: Tsc issues * Fix property pane connection navigation * updating ee locator * updating inputfield locator * dropdown locator update * Merge conflict not properly resolved. * Fix s3 spec * Fix Mongo Spec * Fix some more tests * fix: prevent cyclic dependency when switching to js mode (#14668) * add delete events for change from array to string in diff * add test to assert absence of cyclic dependency error when switching to js in switchgroup widget * Assert that evaluation is not disabled when no cyclic dependency happens * Cypress test preparations for google sheets and form controls * Fixed a few test errors (#14874) * Add: unit tests for uqi UI updates - view type tests - conditional output extraction - processing conditional output to handle view/enabled state of the component * Add: completed isValidFormConfig test * Update: improved tests for update config - These tests cover the functionality to update a section config after it's components are done evaluating * Fix failing cypress tests and cyclic dependency issue * Fixes some more tests * Fixed migration of row objects (#14896) * Bumped the version of design system package * Update: reverted change to EE selector * Fix deletion pointer * Update: selector for js on load spec - Synced with changes related to ADS dropdown * Fix mongoDBShoppingCart spec * Remove comments * Fix: mongo shopping cart test failures * fix: mongo shopping cart spec * Dummy push to retrigger vercel * fix: mongo shopping cart spec * Update MongoDBShoppingCart_spec.js * fix: removed unused click away * dummy commit * Update: moved helper functions to separate file * Add: added tests for saga functions - Worked on testing for - extractFetchDynamicValueFormConfigs - extractQueueOfValuesToBeFetched * Add if check for queueOfValuesToBeFetched * Resolve review comments * Empty-Commit Co-authored-by: Irongade <adeoluayangade@yahoo.com> Co-authored-by: Ayush Pahwa <ayush@appsmith.com> Co-authored-by: Aman Agarwal <aman@appsmith.com> Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com> Co-authored-by: Albin <albin@appsmith.com>
2022-07-04 05:43:27 +00:00
const extractExpressionObject = (
config: string,
path: any,
parentPath: string,
): FormConfigEvalObject => {
const bindingPaths: FormConfigEvalObject = {};
const expressions = config.match(DATA_BIND_REGEX_GLOBAL);
if (Array.isArray(expressions) && expressions.length > 0) {
const completePath = parentPath.length > 0 ? `${parentPath}.${path}` : path;
expressions.forEach((exp) => {
bindingPaths[completePath] = {
expression: exp,
output: "",
};
});
}
return bindingPaths;
};
export const extractEvalConfigFromFormConfig = (
formConfig: FormConfigType,
paths: string[],
parentPath = "",
bindingsFound: FormConfigEvalObject = {},
) => {
paths.forEach((path: string) => {
if (!(path in formConfig)) return;
const config = get(formConfig, path, "");
if (typeof config === "string") {
bindingsFound = {
...bindingsFound,
...extractExpressionObject(config, path, parentPath),
};
} else if (typeof config === "object") {
bindingsFound = {
...bindingsFound,
...extractEvalConfigFromFormConfig(
config,
Object.keys(config),
parentPath.length > 0 ? `${parentPath}.${path}` : path,
bindingsFound,
),
};
}
});
return bindingsFound;
};
// Extract the output of conditionals attached to the form from the state
export const extractConditionalOutput = (
section: any,
formEvaluationState: FormEvalOutput,
): ConditionalOutput => {
let conditionalOutput: ConditionalOutput = {};
if (
section.hasOwnProperty("propertyName") &&
formEvaluationState.hasOwnProperty(section.propertyName)
) {
conditionalOutput = formEvaluationState[section.propertyName];
} else if (
section.hasOwnProperty("configProperty") &&
formEvaluationState.hasOwnProperty(section.configProperty)
) {
conditionalOutput = formEvaluationState[section.configProperty];
} else if (
section.hasOwnProperty("identifier") &&
!!section.identifier &&
formEvaluationState.hasOwnProperty(section.identifier)
) {
conditionalOutput = formEvaluationState[section.identifier];
}
return conditionalOutput;
};
// Function to check if the section config is allowed to render (Only for UQI forms)
export const checkIfSectionCanRender = (
conditionalOutput: ConditionalOutput,
) => {
// By default, allow the section to render. This is to allow for the case where no conditional is provided.
// The evaluation state disallows the section to render if the condition is not met. (Checkout formEval.ts)
let allowToRender = true;
if (
conditionalOutput.hasOwnProperty("visible") &&
typeof conditionalOutput.visible === "boolean"
) {
allowToRender = conditionalOutput.visible;
}
if (
conditionalOutput.hasOwnProperty("evaluateFormConfig") &&
!!conditionalOutput.evaluateFormConfig &&
conditionalOutput.evaluateFormConfig.hasOwnProperty(
"updateEvaluatedConfig",
) &&
typeof conditionalOutput.evaluateFormConfig.updateEvaluatedConfig ===
"boolean"
) {
allowToRender = conditionalOutput.evaluateFormConfig.updateEvaluatedConfig;
}
return allowToRender;
};
// Function to check if the section config is enabled (Only for UQI forms)
export const checkIfSectionIsEnabled = (
conditionalOutput: ConditionalOutput,
) => {
// By default, the section is enabled. This is to allow for the case where no conditional is provided.
// The evaluation state disables the section if the condition is not met. (Checkout formEval.ts)
let enabled = true;
if (
conditionalOutput.hasOwnProperty("enabled") &&
typeof conditionalOutput.enabled === "boolean"
) {
enabled = conditionalOutput.enabled;
}
return enabled;
};
// Function to modify the section config based on the output of evaluations
export const modifySectionConfig = (section: any, enabled: boolean): any => {
if (!enabled) {
section.disabled = true;
} else {
section.disabled = false;
}
return section;
};
export const updateEvaluatedSectionConfig = (
section: any,
conditionalOutput: ConditionalOutput,
enabled = true,
) => {
// we deep clone the section coming from the editorConfig to prevent any mutations of
// the editorConfig in the redux state.
// just spreading the object does a shallow clone(top level cloning), so we use the klona package to deep clone
// klona is faster than deepClone from lodash.
// leaving the commented code as a reminder of the above observation.
// const updatedSection = { ...section };
const updatedSection = klona(section);
let evaluatedConfig: FormConfigEvalObject = {};
if (
conditionalOutput.hasOwnProperty("evaluateFormConfig") &&
!!conditionalOutput.evaluateFormConfig &&
conditionalOutput.evaluateFormConfig.hasOwnProperty(
"updateEvaluatedConfig",
) &&
typeof conditionalOutput.evaluateFormConfig.updateEvaluatedConfig ===
"boolean" &&
conditionalOutput.evaluateFormConfig.updateEvaluatedConfig
) {
evaluatedConfig =
conditionalOutput.evaluateFormConfig.evaluateFormConfigObject;
const paths = Object.keys(evaluatedConfig);
paths.forEach((path: string) => {
set(updatedSection, path, evaluatedConfig[path].output);
});
}
return modifySectionConfig(updatedSection, enabled);
};
export function fixActionPayloadForMongoQuery(
action?: Action,
): Action | undefined {
if (!action) return action;
/* eslint-disable */
//@ts-nocheck
try {
let actionObjectDiff: undefined | Diff<any, any>[] = diff(
action,
MongoDefaultActionConfig,
);
if (actionObjectDiff) {
actionObjectDiff = actionObjectDiff.filter((diff) => diff.kind === "N");
for (let i = 0; i < actionObjectDiff.length; i++) {
let path = "";
let value = "";
//kind = N indicates a newly added property/element
//This property is present in initialValues but not in action object
if (
actionObjectDiff &&
actionObjectDiff[i].hasOwnProperty("kind") &&
actionObjectDiff[i].path &&
Array.isArray(actionObjectDiff[i].path) &&
actionObjectDiff[i]?.path?.length &&
actionObjectDiff[i]?.kind === "N"
) {
// @ts-expect-error: Types are not available
if (typeof actionObjectDiff[i]?.path[0] === "string") {
// @ts-expect-error: Types are not available
path = actionObjectDiff[i]?.path?.join(".");
}
// @ts-expect-error: Types are not available
value = actionObjectDiff[i]?.rhs;
// @ts-expect-error: Types are not available
set(action, path, value);
}
}
}
return action;
//@ts-check
} catch (error) {
console.error("Error adding default paths in Mongo query");
return action;
}
}