Skip to content

Commit

Permalink
fix: Separate Plugin Entity from Action (#38582)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu authored Jan 15, 2025
1 parent d7e30e7 commit a23bcbf
Show file tree
Hide file tree
Showing 155 changed files with 320 additions and 331 deletions.
2 changes: 1 addition & 1 deletion app/client/src/IDE/Components/BottomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Resizer, {
ResizerCSS,
} from "components/editorComponents/Debugger/Resizer";
import { CodeEditorWithGutterStyles } from "pages/Editor/JSEditor/styledComponents";
import { ViewDisplayMode, ViewHideBehaviour } from "IDE/Interfaces/View";
import { ViewDisplayMode, ViewHideBehaviour } from "../Interfaces/View";
import { Button } from "@appsmith/ads";
import classNames from "classnames";

Expand Down
2 changes: 1 addition & 1 deletion app/client/src/PluginActionEditor/PluginActionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useMemo,
} from "react";
import type { Action } from "entities/Action";
import type { Plugin } from "api/PluginApi";
import type { Plugin } from "entities/Plugin";
import type { Datasource, EmbeddedRestDatasource } from "entities/Datasource";
import type { ActionResponse } from "api/ActionAPI";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Flex } from "@appsmith/ads";
import { useChangeActionCall } from "./hooks/useChangeActionCall";
import { usePluginActionContext } from "../../PluginActionContext";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "entities/Plugin";
import APIEditorForm from "./components/ApiEditor";
import GraphQLEditorForm from "./components/GraphQLEditor";
import UQIEditorForm from "./components/UQIEditor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "ee/constants/messages";
import { Tag } from "@blueprintjs/core";
import styled from "styled-components";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "entities/Plugin";
import log from "loglevel";
import * as Sentry from "@sentry/react";
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from "react";
import { PluginPackageName } from "entities/Action";
import { PluginPackageName } from "entities/Plugin";
import { merge } from "lodash";
import { getConfigInitialValues } from "components/formControls/utils";
import { diff, type Diff } from "deep-diff";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderHook } from "@testing-library/react-hooks/dom";
import { useDispatch } from "react-redux";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { usePluginActionContext } from "../../../PluginActionContext";
import { changeApi, changeQuery } from "../../../store";
import usePrevious from "utils/hooks/usePrevious";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { usePluginActionContext } from "../../../PluginActionContext";
import { changeApi, changeQuery } from "../../../store";
import usePrevious from "utils/hooks/usePrevious";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getQueryParams } from "utils/URLUtils";
import history from "utils/history";
import { useEditorType } from "ee/hooks";
import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks";
import type { Plugin } from "api/PluginApi";
import type { Plugin } from "entities/Plugin";

interface Props {
datasourceId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { UIComponentTypes, type Plugin } from "api/PluginApi";
import { type Plugin, UIComponentTypes } from "entities/Plugin";
import ApiDatasourceSelector from "./ApiDatasourceSelector";
import QueryDatasourceSelector from "./QueryDatasourceSelector";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { AppState } from "ee/reducers";
import { fetchDatasourceStructure } from "actions/datasourceActions";
import history from "utils/history";
import { datasourcesEditorIdURL } from "ee/RouteBuilder";
import { DatasourceComponentTypes } from "api/PluginApi";
import { DatasourceComponentTypes } from "entities/Plugin";
import { getPluginActionDebuggerState } from "PluginActionEditor/store";
import { SchemaDisplayStatus, StatusDisplay } from "./StatusDisplay";
import { DatasourceTables } from "./DatasourceTables";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { refreshDatasourceStructure } from "actions/datasourceActions";
import { useDispatch } from "react-redux";
import { SchemaTableContainer } from "./styles";
import DatasourceInfo from "./DatasourceInfo";
import type { Plugin } from "api/PluginApi";
import type { Plugin } from "entities/Plugin";

interface Props {
datasourceId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { render } from "@testing-library/react";
import { Provider } from "react-redux";
import configureStore from "redux-mock-store";
import { Response } from "./Response";
import { PluginType, type Action } from "entities/Action";
import { type Action } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { lightTheme } from "selectors/themeSelectors";
import { ThemeProvider } from "styled-components";
import { BrowserRouter as Router } from "react-router-dom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { Callout, Tooltip, type CalloutLinkProps } from "@appsmith/ads";
import type { ActionResponse } from "api/ActionAPI";
import ActionExecutionInProgressView from "components/editorComponents/ActionExecutionInProgressView";
import type { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import { PluginType, type Action } from "entities/Action";
import { type Action } from "entities/Action";
import { PluginType } from "entities/Plugin";

import { setActionResponseDisplayFormat } from "actions/pluginActionActions";
import { actionResponseDisplayDataFormats } from "pages/Editor/utils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PluginType, type Action } from "entities/Action";
import { type Action } from "entities/Action";
import { PluginType } from "entities/Plugin";

export function checkForPreparedStatement(action: Action) {
const { actionConfiguration } = action;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ActionResponse } from "api/ActionAPI";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { DEFAULT_ERROR_MESSAGE } from "../constants";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getPluginDatasourceComponentFromId,
getPluginNameFromId,
} from "ee/selectors/entitiesSelector";
import { DatasourceComponentTypes } from "api/PluginApi";
import { DatasourceComponentTypes } from "entities/Plugin";
import { SCHEMALESS_PLUGINS } from "pages/Editor/DatasourceInfo/DatasourceStructureContainer";
import { useSelector } from "react-redux";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "entities/Plugin";
import { usePluginActionContext } from "../../PluginActionContext";
import ApiSettings from "./ApiSettings";
import QuerySettings from "./QuerySettings";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
transformRestAction,
} from "./RestActionTransformer";
import type { ApiAction } from "entities/Action";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import {
HTTP_PROTOCOL,
MultiPartOptionTypes,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/WidgetQueryGenerators/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginPackageName } from "entities/Action";
import { PluginPackageName } from "entities/Plugin";
import WidgetQueryGeneratorRegistry from "utils/WidgetQueryGeneratorRegistry";
import GSheets from "./GSheets";
import MongoDB from "./MongoDB";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/datasourceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
FilePickerActionStatus,
MockDatasource,
} from "entities/Datasource";
import type { PluginType } from "entities/Action";
import type { PluginType } from "entities/Plugin";
import type { ApiResponse, ResponseMeta } from "api/ApiResponses";
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
import {
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/pluginActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import type { ApiResponse } from "api/ApiResponses";
import type { PluginFormPayload } from "api/PluginApi";
import type { DependencyMap } from "utils/DynamicBindingUtils";
import type { Plugin } from "api/PluginApi";
import type { Plugin } from "entities/Plugin";

export const fetchPlugins = (payload?: {
workspaceId?: string;
Expand Down
42 changes: 1 addition & 41 deletions app/client/src/api/PluginApi.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
import Api from "api/Api";
import type { AxiosPromise } from "axios";
import type { ApiResponse } from "api/ApiResponses";
import type { PluginPackageName, PluginType } from "entities/Action";
import type { DependencyMap } from "utils/DynamicBindingUtils";
import { FILE_UPLOAD_TRIGGER_TIMEOUT_MS } from "ee/constants/ApiConstants";

export type PluginId = string;
export type GenerateCRUDEnabledPluginMap = Record<PluginId, PluginPackageName>;

export enum UIComponentTypes {
DbEditorForm = "DbEditorForm",
UQIDbEditorForm = "UQIDbEditorForm",
ApiEditorForm = "ApiEditorForm",
JsEditorForm = "JsEditorForm",
GraphQLEditorForm = "GraphQLEditorForm",
}

export enum DatasourceComponentTypes {
RestAPIDatasourceForm = "RestAPIDatasourceForm",
AutoForm = "AutoForm",
}
export interface Plugin {
id: string;
name: string;
type: PluginType;
packageName: PluginPackageName;
iconLocation?: string;
uiComponent: UIComponentTypes;
datasourceComponent: DatasourceComponentTypes;
allowUserDatasources?: boolean;
templates: Record<string, string>;
responseType?: "TABLE" | "JSON";
documentationLink?: string;
generateCRUDPageComponent?: string;
// We need to know if the plugin requires a datasource (Eg Workflows plugin does not require a datasource to create queries)
requiresDatasource: boolean;
}
import type { DefaultPlugin, Plugin } from "entities/Plugin";

export interface PluginFormPayload {
// TODO: Fix this the next time the file is edited
Expand All @@ -51,14 +19,6 @@ export interface PluginFormPayload {
formButton: string[];
}

export interface DefaultPlugin {
id: string;
name: string;
packageName: string;
iconLocation?: string;
allowUserDatasources?: boolean;
}

class PluginsApi extends Api {
static url = "v1/plugins";
static defaultDynamicTriggerURL(datasourceId: string): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/constants";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { usePluginActionContext } from "PluginActionEditor";
import useShowSchema from "PluginActionEditor/components/PluginActionResponse/hooks/useShowSchema";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "ee/constants/messages";
import ErrorLogs from "components/editorComponents/Debugger/Errors";
import DebuggerLogs from "components/editorComponents/Debugger/DebuggerLogs";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { ApiResponseHeaders } from "PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders";
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import { getErrorCount } from "selectors/debuggerSelectors";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getHasExecuteActionPermission } from "ee/utils/BusinessFeatures/permiss
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { DEFAULT_DATASOURCE_NAME } from "PluginActionEditor/constants/ApiEditorConstants";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "entities/Plugin";
import { SQL_DATASOURCES } from "constants/QueryEditorConstants";
import { usePluginActionContext } from "PluginActionEditor/PluginActionContext";

Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/api/JSActionAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AxiosPromise } from "axios";
import type { JSCollection } from "entities/JSCollection";
import type { ApiResponse } from "api/ApiResponses";
import type { Variable, JSAction } from "entities/JSCollection";
import type { PluginType } from "entities/Action";
import type { PluginType } from "entities/Plugin";
import type { FetchActionsPayload } from "api/ActionAPI";
import type { ActionParentEntityTypeInterface } from "ee/entities/Engine/actionHelpers";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FunctionComponent } from "react";
import React from "react";
import type { LogItemProps } from "components/editorComponents/Debugger/ErrorLogs/ErrorLogItem";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import WidgetIcon from "pages/Editor/Explorer/Widgets/WidgetIcon";
import {
ApiMethodIcon,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/constants/ModuleConstants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginType } from "entities/Action";
import type { PluginType } from "entities/Plugin";

type ID = string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import { generateDataTreeJSAction } from "./dataTreeJSAction";
import type { JSCollectionData } from "ee/reducers/entityReducers/jsActionsReducer";

Expand Down
4 changes: 2 additions & 2 deletions app/client/src/ce/entities/DataTree/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ActionResponse } from "api/ActionAPI";
import type { PluginId } from "api/PluginApi";
import type { PluginType, PluginId } from "entities/Plugin";
import type { ValidationConfig } from "constants/PropertyControlConstants";
import type { ActionConfig, PluginType } from "entities/Action";
import type { ActionConfig } from "entities/Action";
import type { ActionDescription } from "ee/workers/Evaluation/fns";
import type { Variable } from "entities/JSCollection";
import type { DependencyMap, DynamicPath } from "utils/DynamicBindingUtils";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/entities/Engine/actionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { DependentFeatureFlags } from "ee/selectors/engineSelectors";
import { fetchDatasources } from "actions/datasourceActions";
import { fetchPageDSLs } from "actions/pageActions";
import { fetchPlugins } from "actions/pluginActions";
import type { Plugin } from "api/PluginApi";
import type { Plugin } from "entities/Plugin";
import { useSelector } from "react-redux";
import { useParams } from "react-router";
import type { EditConsolidatedApi } from "sagas/InitSagas";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/entities/IDE/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SAAS_EDITOR_API_ID_PATH,
SAAS_EDITOR_DATASOURCE_ID_PATH,
} from "pages/Editor/SaaSEditor/constants";
import type { PluginType } from "entities/Action";
import type { PluginType } from "entities/Plugin";
import type { ComponentType, ReactNode } from "react";
import type { IDESidebarButton } from "@appsmith/ads";

Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/navigation/FocusElements/AppIDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
DEFAULT_ENTITY_EXPLORER_WIDTH,
DEFAULT_PROPERTY_PANE_WIDTH,
} from "constants/AppConstants";
import { PluginPackageName } from "entities/Action";
import { PluginPackageName } from "entities/Plugin";
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
import { getExplorerWidth } from "selectors/explorerSelector";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/navigation/FocusSetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
datasourcesEditorIdURL,
jsCollectionIdURL,
} from "ee/RouteBuilder";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import type { FocusEntityInfo } from "navigation/FocusEntity";
import { FocusEntity } from "navigation/FocusEntity";
import { getQueryEntityItemUrl } from "../pages/Editor/IDE/EditorPane/Query/utils";
Expand Down
3 changes: 1 addition & 2 deletions app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import history from "utils/history";
import { builderURL } from "ee/RouteBuilder";
import { getDatasource, getPlugin } from "ee/selectors/entitiesSelector";
import type { Plugin } from "api/PluginApi";
import { PluginPackageName, PluginType } from "entities/Action";
import { type Plugin, PluginPackageName, PluginType } from "entities/Plugin";
import DataSourceEditor from "pages/Editor/DataSourceEditor";
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
import { fetchMockDatasources } from "actions/datasourceActions";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/pages/Editor/Explorer/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "pages/Editor/SaaSEditor/constants";
import type { ActionData } from "ee/reducers/entityReducers/actionsReducer";
import type { JSCollectionData } from "ee/reducers/entityReducers/jsActionsReducer";
import type { PluginType } from "entities/Action";
import type { PluginType } from "entities/Plugin";
import localStorage from "utils/localStorage";
import { EDITOR_PATHS } from "ee/entities/IDE/utils";
import type { Match } from "path-to-regexp";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getJSEntityItemUrl, getJSUrl } from "./utils";
import urlBuilder from "ee/entities/URLRedirect/URLAssembly";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";
import type { FocusEntityInfo } from "navigation/FocusEntity";
import { FocusEntity } from "navigation/FocusEntity";
import { EditorState } from "ee/entities/IDE/constants";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getQueryEntityItemUrl, getQueryUrl } from "./utils";
import type { FocusEntityInfo } from "navigation/FocusEntity";
import { FocusEntity } from "navigation/FocusEntity";
import { EditorState } from "ee/entities/IDE/constants";
import { PluginPackageName, PluginType } from "entities/Action";
import { PluginPackageName, PluginType } from "entities/Plugin";
import urlBuilder from "ee/entities/URLRedirect/URLAssembly";

describe("getQueryEntityItemUrl", () => {
Expand Down
9 changes: 7 additions & 2 deletions app/client/src/ce/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ import localStorage from "utils/localStorage";
import log from "loglevel";
import { APPSMITH_TOKEN_STORAGE_KEY } from "pages/Editor/SaaSEditor/constants";
import { checkAndGetPluginFormConfigsSaga } from "sagas/PluginSagas";
import { type Action, PluginPackageName, PluginType } from "entities/Action";
import { type Action } from "entities/Action";
import LOG_TYPE from "entities/AppsmithConsole/logtype";
import { isDynamicValue } from "utils/DynamicBindingUtils";
import { getQueryParams } from "utils/URLUtils";
import type { GenerateCRUDEnabledPluginMap, Plugin } from "api/PluginApi";
import {
type GenerateCRUDEnabledPluginMap,
type Plugin,
PluginPackageName,
PluginType,
} from "entities/Plugin";
import { getIsGeneratePageInitiator } from "utils/GenerateCrudUtil";
import {
klonaLiteWithTelemetry,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/selectors/appIDESelectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EntityItem } from "ee/entities/IDE/constants";
import { groupAndSortEntitySegmentList } from "./appIDESelectors";
import { PluginType } from "entities/Action";
import { PluginType } from "entities/Plugin";

describe("groupAndSortEntitySegmentList", () => {
it("should group and sort entity segment list alphabetically", () => {
Expand Down
Loading

0 comments on commit a23bcbf

Please sign in to comment.