2020-03-19 03:25:52 +00:00
|
|
|
import {
|
|
|
|
|
ActionDataState,
|
2021-05-14 06:51:09 +00:00
|
|
|
ActionDataWithMeta,
|
2020-03-19 03:25:52 +00:00
|
|
|
} from "reducers/entityReducers/actionsReducer";
|
2020-02-18 10:41:52 +00:00
|
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
|
import { ActionResponse } from "api/ActionAPI";
|
2020-03-19 03:25:52 +00:00
|
|
|
import { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
|
|
|
|
|
import { MetaState } from "reducers/entityReducers/metaReducer";
|
2020-04-20 05:42:46 +00:00
|
|
|
import { PageListPayload } from "constants/ReduxActionConstants";
|
2020-11-12 11:23:32 +00:00
|
|
|
import { ActionConfig, PluginType } from "entities/Action";
|
2020-08-14 07:43:01 +00:00
|
|
|
import { AppDataState } from "reducers/entityReducers/appReducer";
|
2021-04-26 05:41:32 +00:00
|
|
|
import { DependencyMap, DynamicPath } from "utils/DynamicBindingUtils";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { generateDataTreeAction } from "entities/DataTree/dataTreeAction";
|
2021-09-08 17:32:22 +00:00
|
|
|
import { generateDataTreeJSAction } from "entities/DataTree/dataTreeJSAction";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { generateDataTreeWidget } from "entities/DataTree/dataTreeWidget";
|
2021-09-08 17:32:22 +00:00
|
|
|
import { JSCollectionDataState } from "reducers/entityReducers/jsActionsReducer";
|
2021-07-26 05:50:46 +00:00
|
|
|
import { ValidationConfig } from "constants/PropertyControlConstants";
|
2021-09-08 17:32:22 +00:00
|
|
|
import { Variable } from "entities/JSCollection";
|
2021-08-27 09:25:28 +00:00
|
|
|
import {
|
|
|
|
|
ActionDescription,
|
|
|
|
|
ClearPluginActionDescription,
|
|
|
|
|
RunPluginActionDescription,
|
|
|
|
|
} from "entities/DataTree/actionTriggers";
|
2020-02-18 10:41:52 +00:00
|
|
|
|
2021-08-27 09:25:28 +00:00
|
|
|
export type ActionDispatcher = (
|
|
|
|
|
...args: any[]
|
2021-12-23 14:17:20 +00:00
|
|
|
) => Promise<unknown> | ActionDescription;
|
2020-02-18 10:41:52 +00:00
|
|
|
|
|
|
|
|
export enum ENTITY_TYPE {
|
|
|
|
|
ACTION = "ACTION",
|
|
|
|
|
WIDGET = "WIDGET",
|
2020-08-07 14:24:26 +00:00
|
|
|
APPSMITH = "APPSMITH",
|
2021-09-08 17:32:22 +00:00
|
|
|
JSACTION = "JSACTION",
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-26 05:41:32 +00:00
|
|
|
export enum EvaluationSubstitutionType {
|
|
|
|
|
TEMPLATE = "TEMPLATE",
|
|
|
|
|
PARAMETER = "PARAMETER",
|
|
|
|
|
SMART_SUBSTITUTE = "SMART_SUBSTITUTE",
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-14 06:51:09 +00:00
|
|
|
export interface DataTreeAction
|
|
|
|
|
extends Omit<ActionDataWithMeta, "data" | "config"> {
|
2020-02-18 10:41:52 +00:00
|
|
|
data: ActionResponse["body"];
|
2020-06-29 07:41:53 +00:00
|
|
|
actionId: string;
|
|
|
|
|
config: Partial<ActionConfig>;
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
pluginType: PluginType;
|
|
|
|
|
name: string;
|
2021-08-27 09:25:28 +00:00
|
|
|
run: ActionDispatcher | RunPluginActionDescription | Record<string, unknown>;
|
|
|
|
|
clear:
|
|
|
|
|
| ActionDispatcher
|
|
|
|
|
| ClearPluginActionDescription
|
|
|
|
|
| Record<string, unknown>;
|
2020-11-12 11:23:32 +00:00
|
|
|
dynamicBindingPathList: DynamicPath[];
|
2021-04-26 05:41:32 +00:00
|
|
|
bindingPaths: Record<string, EvaluationSubstitutionType>;
|
2020-02-18 10:41:52 +00:00
|
|
|
ENTITY_TYPE: ENTITY_TYPE.ACTION;
|
2021-04-26 05:41:32 +00:00
|
|
|
dependencyMap: DependencyMap;
|
2021-06-04 07:09:36 +00:00
|
|
|
logBlackList: Record<string, true>;
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
export interface DataTreeJSAction {
|
|
|
|
|
pluginType: PluginType.JS;
|
|
|
|
|
name: string;
|
|
|
|
|
ENTITY_TYPE: ENTITY_TYPE.JSACTION;
|
|
|
|
|
body: string;
|
|
|
|
|
[propName: string]: any;
|
|
|
|
|
meta: Record<string, MetaArgs>;
|
|
|
|
|
dynamicBindingPathList: DynamicPath[];
|
|
|
|
|
bindingPaths: Record<string, EvaluationSubstitutionType>;
|
2021-11-08 06:49:22 +00:00
|
|
|
variables: Array<string>;
|
|
|
|
|
dependencyMap: DependencyMap;
|
2021-09-08 17:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MetaArgs {
|
|
|
|
|
arguments: Variable[];
|
|
|
|
|
}
|
2020-02-18 10:41:52 +00:00
|
|
|
export interface DataTreeWidget extends WidgetProps {
|
2021-04-26 05:41:32 +00:00
|
|
|
bindingPaths: Record<string, EvaluationSubstitutionType>;
|
2021-02-16 10:29:08 +00:00
|
|
|
triggerPaths: Record<string, boolean>;
|
2021-07-26 05:50:46 +00:00
|
|
|
validationPaths: Record<string, ValidationConfig>;
|
2020-02-18 10:41:52 +00:00
|
|
|
ENTITY_TYPE: ENTITY_TYPE.WIDGET;
|
2021-06-04 07:09:36 +00:00
|
|
|
logBlackList: Record<string, true>;
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-24 05:09:47 +00:00
|
|
|
export interface DataTreeAppsmith extends Omit<AppDataState, "store"> {
|
2020-08-07 14:24:26 +00:00
|
|
|
ENTITY_TYPE: ENTITY_TYPE.APPSMITH;
|
2020-10-12 13:06:05 +00:00
|
|
|
store: Record<string, unknown>;
|
2020-08-07 14:24:26 +00:00
|
|
|
}
|
2020-12-30 12:58:57 +00:00
|
|
|
export type DataTreeObjectEntity =
|
2020-02-26 12:44:56 +00:00
|
|
|
| DataTreeAction
|
2021-09-08 17:32:22 +00:00
|
|
|
| DataTreeJSAction
|
2020-02-26 12:44:56 +00:00
|
|
|
| DataTreeWidget
|
2020-12-30 12:58:57 +00:00
|
|
|
| DataTreeAppsmith;
|
|
|
|
|
|
|
|
|
|
export type DataTreeEntity =
|
|
|
|
|
| DataTreeObjectEntity
|
2020-04-20 05:42:46 +00:00
|
|
|
| PageListPayload
|
2021-08-27 09:25:28 +00:00
|
|
|
| ActionDispatcher;
|
2020-02-26 12:44:56 +00:00
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
export type DataTree = {
|
2020-02-26 12:44:56 +00:00
|
|
|
[entityName: string]: DataTreeEntity;
|
2021-08-27 09:25:28 +00:00
|
|
|
};
|
2020-02-18 10:41:52 +00:00
|
|
|
|
2020-03-19 03:25:52 +00:00
|
|
|
type DataTreeSeed = {
|
|
|
|
|
actions: ActionDataState;
|
2021-03-30 05:29:03 +00:00
|
|
|
editorConfigs: Record<string, any[]>;
|
2021-04-26 05:41:32 +00:00
|
|
|
pluginDependencyConfig: Record<string, DependencyMap>;
|
2020-03-19 03:25:52 +00:00
|
|
|
widgets: CanvasWidgetsReduxState;
|
|
|
|
|
widgetsMeta: MetaState;
|
2020-04-20 05:42:46 +00:00
|
|
|
pageList: PageListPayload;
|
2020-08-14 07:43:01 +00:00
|
|
|
appData: AppDataState;
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions: JSCollectionDataState;
|
2020-03-19 03:25:52 +00:00
|
|
|
};
|
|
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
export class DataTreeFactory {
|
2020-10-21 04:25:32 +00:00
|
|
|
static create({
|
|
|
|
|
actions,
|
|
|
|
|
appData,
|
2021-03-30 05:29:03 +00:00
|
|
|
editorConfigs,
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions,
|
2021-05-13 08:35:39 +00:00
|
|
|
pageList,
|
2021-04-26 05:41:32 +00:00
|
|
|
pluginDependencyConfig,
|
2021-05-13 08:35:39 +00:00
|
|
|
widgets,
|
|
|
|
|
widgetsMeta,
|
2020-10-21 04:25:32 +00:00
|
|
|
}: DataTreeSeed): DataTree {
|
2020-02-18 10:41:52 +00:00
|
|
|
const dataTree: DataTree = {};
|
2020-12-24 04:32:25 +00:00
|
|
|
actions.forEach((action) => {
|
2021-03-30 05:29:03 +00:00
|
|
|
const editorConfig = editorConfigs[action.config.pluginId];
|
2021-04-26 05:41:32 +00:00
|
|
|
const dependencyConfig = pluginDependencyConfig[action.config.pluginId];
|
2021-03-30 05:29:03 +00:00
|
|
|
dataTree[action.config.name] = generateDataTreeAction(
|
|
|
|
|
action,
|
|
|
|
|
editorConfig,
|
2021-04-26 05:41:32 +00:00
|
|
|
dependencyConfig,
|
2020-04-17 16:15:09 +00:00
|
|
|
);
|
2021-03-30 05:29:03 +00:00
|
|
|
});
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions.forEach((js) => {
|
|
|
|
|
dataTree[js.config.name] = generateDataTreeJSAction(js);
|
|
|
|
|
});
|
2021-03-30 05:29:03 +00:00
|
|
|
Object.values(widgets).forEach((widget) => {
|
|
|
|
|
dataTree[widget.widgetName] = generateDataTreeWidget(
|
2021-02-16 10:29:08 +00:00
|
|
|
widget,
|
2021-03-30 05:29:03 +00:00
|
|
|
widgetsMeta[widget.widgetId],
|
2021-02-16 10:29:08 +00:00
|
|
|
);
|
2020-02-18 10:41:52 +00:00
|
|
|
});
|
2020-06-19 13:06:45 +00:00
|
|
|
|
2020-04-20 05:42:46 +00:00
|
|
|
dataTree.pageList = pageList;
|
2021-03-24 05:09:47 +00:00
|
|
|
dataTree.appsmith = {
|
|
|
|
|
...appData,
|
|
|
|
|
// combine both persistent and transient state with the transient state
|
|
|
|
|
// taking precedence in case the key is the same
|
|
|
|
|
store: { ...appData.store.persistent, ...appData.store.transient },
|
|
|
|
|
} as DataTreeAppsmith;
|
2020-10-12 13:06:05 +00:00
|
|
|
(dataTree.appsmith as DataTreeAppsmith).ENTITY_TYPE = ENTITY_TYPE.APPSMITH;
|
2020-02-18 10:41:52 +00:00
|
|
|
return dataTree;
|
|
|
|
|
}
|
|
|
|
|
}
|