From c655aea15cc685afc81015c823084706fb49d7b0 Mon Sep 17 00:00:00 2001 From: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:00:18 +0530 Subject: [PATCH 01/11] chore: Import debugger fixes (#31080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description To add debugger error for import path for module instance on EE, this PR enables code to be extended on EE #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **Refactor** - Updated import paths and references for `ENTITY_TYPE` to `EntityTypeValue` across various components and utilities for improved code consistency. - Reorganized import statements related to `AppsmithConsole` utilities and constants to enhance code maintainability. - Adjusted usage of enums and types, specifically for entity and platform error handling, to align with updated import paths. - **New Features** - Introduced utility functions for handling entity types and platform errors in AppsmithConsole, including new constants and error retrieval functions. - Added a new enum value `MISSING_MODULE` to better categorize log types in debugging scenarios. - **Bug Fixes** - Implemented changes to error logging and handling mechanisms, including the addition of new case handling for `LOG_TYPE.MISSING_MODULE` in debugger logs, to improve the debugging experience. --- app/client/src/actions/debuggerActions.ts | 8 ++---- app/client/src/actions/pageActions.tsx | 2 +- .../Debugger/entityTypeLinkMap.tsx | 2 +- .../src/ce/entities/AppsmithConsole/utils.ts | 27 +++++++++++++++++++ app/client/src/ce/sagas/JSActionSagas.ts | 2 +- .../editorComponents/ApiResponseView.tsx | 2 +- .../CodeEditor/codeEditorUtils.ts | 2 +- .../editorComponents/Debugger/ActionLink.tsx | 2 +- .../Debugger/DebuggerEntityLink.tsx | 7 ++--- .../Debugger/EntityDependecies.tsx | 2 +- .../Debugger/JSCollectionLink.tsx | 2 +- .../editorComponents/Debugger/WidgetLink.tsx | 2 +- .../Debugger/hooks/debuggerHooks.ts | 2 +- .../Debugger/hooks/useGetEntityInfo.tsx | 2 +- .../editorComponents/JSResponseView.tsx | 2 +- .../src/ee/entities/AppsmithConsole/utils.ts | 1 + .../src/entities/AppsmithConsole/index.ts | 16 +++-------- .../src/entities/AppsmithConsole/logtype.ts | 1 + .../Replay/ReplayEntity/ReplayCanvas.ts | 2 +- .../Replay/ReplayEntity/ReplayEditor.ts | 2 +- app/client/src/entities/Replay/index.ts | 2 +- .../anvil/utils/widgetAdditionUtils.ts | 2 +- .../RestAPIDatasourceForm.tsx | 2 +- .../pages/Editor/EntityNavigation/factory.ts | 2 +- .../pages/Editor/EntityNavigation/types.ts | 2 +- .../Editor/PropertyPane/PropertyControl.tsx | 2 +- .../PropertyPane/PropertyPaneConnections.tsx | 2 +- .../Editor/QueryEditor/EditorJSONtoForm.tsx | 2 +- .../sagas/ActionExecution/PluginActionSaga.ts | 5 +++- app/client/src/sagas/ActionSagas.ts | 2 +- app/client/src/sagas/ApiPaneSagas.ts | 2 +- app/client/src/sagas/AppThemingSaga.tsx | 2 +- app/client/src/sagas/DatasourcesSagas.ts | 2 +- app/client/src/sagas/DebuggerSagas.ts | 7 ++++- app/client/src/sagas/EvalErrorHandler.ts | 18 ++++++++++++- app/client/src/sagas/EvaluationsSaga.ts | 2 +- app/client/src/sagas/JSPaneSagas.ts | 5 +++- app/client/src/sagas/OneClickBindingSaga.ts | 2 +- app/client/src/sagas/PostEvaluationSagas.ts | 5 +++- app/client/src/sagas/PostLintingSagas.ts | 5 ++-- app/client/src/sagas/QueryPaneSagas.ts | 2 +- app/client/src/sagas/ReplaySaga.ts | 2 +- app/client/src/sagas/WidgetAdditionSagas.ts | 2 +- app/client/src/sagas/WidgetDeletionSagas.ts | 2 +- app/client/src/sagas/helper.ts | 5 ++-- .../src/selectors/debuggerSelectors.test.ts | 3 ++- app/client/src/utils/JSPaneUtils.tsx | 2 +- app/client/src/widgets/BaseWidget.tsx | 2 +- app/client/src/widgets/MetaHOC.tsx | 2 +- .../Evaluation/fns/overrides/console.ts | 3 ++- 50 files changed, 116 insertions(+), 70 deletions(-) create mode 100644 app/client/src/ce/entities/AppsmithConsole/utils.ts create mode 100644 app/client/src/ee/entities/AppsmithConsole/utils.ts diff --git a/app/client/src/actions/debuggerActions.ts b/app/client/src/actions/debuggerActions.ts index 557e80e4a6b..d34292ca605 100644 --- a/app/client/src/actions/debuggerActions.ts +++ b/app/client/src/actions/debuggerActions.ts @@ -1,10 +1,6 @@ import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants"; -import type { - ENTITY_TYPE, - Log, - Message, - SourceEntity, -} from "entities/AppsmithConsole"; +import type { Log, Message, SourceEntity } from "entities/AppsmithConsole"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { DebuggerContext } from "reducers/uiReducers/debuggerReducer"; import type { EventName } from "@appsmith/utils/analyticsUtilTypes"; import type { APP_MODE } from "entities/App"; diff --git a/app/client/src/actions/pageActions.tsx b/app/client/src/actions/pageActions.tsx index 25f72403103..6c7a7e63eda 100644 --- a/app/client/src/actions/pageActions.tsx +++ b/app/client/src/actions/pageActions.tsx @@ -26,7 +26,7 @@ import type { UrlDataState } from "reducers/entityReducers/appReducer"; import type { APP_MODE } from "entities/App"; import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer"; import type { GenerateTemplatePageRequest } from "api/PageApi"; -import type { ENTITY_TYPE } from "entities/AppsmithConsole"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { Replayable } from "entities/Replay/ReplayEntity/ReplayEditor"; import * as Sentry from "@sentry/react"; diff --git a/app/client/src/ce/components/editorComponents/Debugger/entityTypeLinkMap.tsx b/app/client/src/ce/components/editorComponents/Debugger/entityTypeLinkMap.tsx index 56df3b7b90a..1e9f4a6469f 100644 --- a/app/client/src/ce/components/editorComponents/Debugger/entityTypeLinkMap.tsx +++ b/app/client/src/ce/components/editorComponents/Debugger/entityTypeLinkMap.tsx @@ -2,7 +2,7 @@ import ActionLink from "components/editorComponents/Debugger/ActionLink"; import DatasourceLink from "components/editorComponents/Debugger/DataSourceLink"; import WidgetLink from "components/editorComponents/Debugger/WidgetLink"; import JSCollectionLink from "components/editorComponents/Debugger/JSCollectionLink"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; export const entityTypeLinkMap = { [ENTITY_TYPE.WIDGET]: WidgetLink, diff --git a/app/client/src/ce/entities/AppsmithConsole/utils.ts b/app/client/src/ce/entities/AppsmithConsole/utils.ts new file mode 100644 index 00000000000..63a5104d27a --- /dev/null +++ b/app/client/src/ce/entities/AppsmithConsole/utils.ts @@ -0,0 +1,27 @@ +import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes"; +import type { DataTreeEntityConfig } from "../DataTree/types"; + +export enum ENTITY_TYPE { + ACTION = "ACTION", + DATASOURCE = "DATASOURCE", + WIDGET = "WIDGET", + JSACTION = "JSACTION", +} + +export enum PLATFORM_ERROR { + PLUGIN_EXECUTION = "PLUGIN_EXECUTION", + JS_FUNCTION_EXECUTION = "JS_FUNCTION_EXECUTION", +} + +// export type PlatformErrorTypeValue = ValueOf; + +export const getModuleInstanceInvalidErrors = ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + entity: DataTreeEntity, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + entityConfig: DataTreeEntityConfig, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + propertyPath: string, +) => { + return []; +}; diff --git a/app/client/src/ce/sagas/JSActionSagas.ts b/app/client/src/ce/sagas/JSActionSagas.ts index b6a02487f58..33d450319c1 100644 --- a/app/client/src/ce/sagas/JSActionSagas.ts +++ b/app/client/src/ce/sagas/JSActionSagas.ts @@ -51,7 +51,7 @@ import { updateCanvasWithDSL } from "@appsmith/sagas/PageSagas"; import type { JSCollectionData } from "@appsmith/reducers/entityReducers/jsActionsReducer"; import type { ApiResponse } from "api/ApiResponses"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { CreateJSCollectionRequest } from "@appsmith/api/JSActionAPI"; import * as log from "loglevel"; diff --git a/app/client/src/components/editorComponents/ApiResponseView.tsx b/app/client/src/components/editorComponents/ApiResponseView.tsx index 217de1f1bde..6d1f3d6697f 100644 --- a/app/client/src/components/editorComponents/ApiResponseView.tsx +++ b/app/client/src/components/editorComponents/ApiResponseView.tsx @@ -7,7 +7,7 @@ import type { ActionResponse } from "api/ActionAPI"; import { formatBytes } from "utils/helpers"; import type { SourceEntity } from "entities/AppsmithConsole"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import ReadOnlyEditor from "components/editorComponents/ReadOnlyEditor"; import { isArray, isEmpty, isString } from "lodash"; import { diff --git a/app/client/src/components/editorComponents/CodeEditor/codeEditorUtils.ts b/app/client/src/components/editorComponents/CodeEditor/codeEditorUtils.ts index 61e300aa457..56b756fcd80 100644 --- a/app/client/src/components/editorComponents/CodeEditor/codeEditorUtils.ts +++ b/app/client/src/components/editorComponents/CodeEditor/codeEditorUtils.ts @@ -1,5 +1,5 @@ import type CodeMirror from "codemirror"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { WidgetEntity, ActionEntity, diff --git a/app/client/src/components/editorComponents/Debugger/ActionLink.tsx b/app/client/src/components/editorComponents/Debugger/ActionLink.tsx index 1a21f708abb..97e0d0b3034 100644 --- a/app/client/src/components/editorComponents/Debugger/ActionLink.tsx +++ b/app/client/src/components/editorComponents/Debugger/ActionLink.tsx @@ -1,5 +1,5 @@ import { PluginType } from "entities/Action"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import React, { useCallback } from "react"; import { useDispatch, useSelector } from "react-redux"; import type { AppState } from "@appsmith/reducers"; diff --git a/app/client/src/components/editorComponents/Debugger/DebuggerEntityLink.tsx b/app/client/src/components/editorComponents/Debugger/DebuggerEntityLink.tsx index bcc5c37a1c8..a6ce8b38e23 100644 --- a/app/client/src/components/editorComponents/Debugger/DebuggerEntityLink.tsx +++ b/app/client/src/components/editorComponents/Debugger/DebuggerEntityLink.tsx @@ -1,12 +1,9 @@ -import type { - ENTITY_TYPE, - Message, - SourceEntity, -} from "entities/AppsmithConsole"; +import type { Message, SourceEntity } from "entities/AppsmithConsole"; import React, { useCallback } from "react"; import type LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { Plugin } from "api/PluginApi"; import { Link } from "design-system"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; export enum DebuggerLinkUI { ENTITY_TYPE, diff --git a/app/client/src/components/editorComponents/Debugger/EntityDependecies.tsx b/app/client/src/components/editorComponents/Debugger/EntityDependecies.tsx index 8ad58d23ee2..ea24274a3b8 100644 --- a/app/client/src/components/editorComponents/Debugger/EntityDependecies.tsx +++ b/app/client/src/components/editorComponents/Debugger/EntityDependecies.tsx @@ -17,7 +17,7 @@ import { getDependenciesFromInverseDependencies } from "./helpers"; import { useSelectedEntity, useEntityLink } from "./hooks/debuggerHooks"; import AnalyticsUtil from "utils/AnalyticsUtil"; import { thinScrollbar } from "constants/DefaultTheme"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { useGetEntityInfo } from "./hooks/useGetEntityInfo"; import { Button, Icon, Tooltip } from "design-system"; import { importSvg } from "design-system-old"; diff --git a/app/client/src/components/editorComponents/Debugger/JSCollectionLink.tsx b/app/client/src/components/editorComponents/Debugger/JSCollectionLink.tsx index 3f40876b432..675a3d7e0a2 100644 --- a/app/client/src/components/editorComponents/Debugger/JSCollectionLink.tsx +++ b/app/client/src/components/editorComponents/Debugger/JSCollectionLink.tsx @@ -3,7 +3,7 @@ import { DebuggerEntityLink, type EntityLinkProps } from "./DebuggerEntityLink"; import { useCallback } from "react"; import { navigateToEntity } from "actions/editorActions"; import AnalyticsUtil from "utils/AnalyticsUtil"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; export default function JSCollectionLink(props: EntityLinkProps) { const dispatch = useDispatch(); diff --git a/app/client/src/components/editorComponents/Debugger/WidgetLink.tsx b/app/client/src/components/editorComponents/Debugger/WidgetLink.tsx index 4c2ea2f5d79..90069d39111 100644 --- a/app/client/src/components/editorComponents/Debugger/WidgetLink.tsx +++ b/app/client/src/components/editorComponents/Debugger/WidgetLink.tsx @@ -1,4 +1,4 @@ -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import React, { useCallback } from "react"; import { useDispatch } from "react-redux"; import AnalyticsUtil from "utils/AnalyticsUtil"; diff --git a/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts b/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts index 74c4c45ce98..4d46282e3fb 100644 --- a/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts +++ b/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts @@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from "react"; import { useSelector } from "react-redux"; import { useParams } from "react-router"; import type { Log } from "entities/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { AppState } from "@appsmith/reducers"; import { getWidget } from "sagas/selectors"; import { diff --git a/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx b/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx index 53c17e66ddd..76f7dcfdb53 100644 --- a/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx +++ b/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx @@ -1,5 +1,5 @@ import { isStoredDatasource } from "entities/Action"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { keyBy } from "lodash"; import equal from "fast-deep-equal/es6"; import { getPluginIcon, jsIcon } from "pages/Editor/Explorer/ExplorerIcons"; diff --git a/app/client/src/components/editorComponents/JSResponseView.tsx b/app/client/src/components/editorComponents/JSResponseView.tsx index fd990323d4d..915f218d294 100644 --- a/app/client/src/components/editorComponents/JSResponseView.tsx +++ b/app/client/src/components/editorComponents/JSResponseView.tsx @@ -50,7 +50,7 @@ import { import LogHelper from "./Debugger/ErrorLogs/components/LogHelper"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { SourceEntity, Log } from "entities/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { CloseDebugger } from "./Debugger/DebuggerTabs"; const ResponseContainer = styled.div` diff --git a/app/client/src/ee/entities/AppsmithConsole/utils.ts b/app/client/src/ee/entities/AppsmithConsole/utils.ts new file mode 100644 index 00000000000..e9771abad37 --- /dev/null +++ b/app/client/src/ee/entities/AppsmithConsole/utils.ts @@ -0,0 +1 @@ +export * from "ce/entities/AppsmithConsole/utils"; diff --git a/app/client/src/entities/AppsmithConsole/index.ts b/app/client/src/entities/AppsmithConsole/index.ts index 9402ccba1f7..03cba1b9fc7 100644 --- a/app/client/src/entities/AppsmithConsole/index.ts +++ b/app/client/src/entities/AppsmithConsole/index.ts @@ -3,18 +3,10 @@ import type LOG_TYPE from "./logtype"; import type { PropertyEvaluationErrorType } from "utils/DynamicBindingUtils"; import type { PluginType } from "entities/Action"; import type { HTTP_METHOD } from "constants/ApiEditorConstants/CommonApiConstants"; - -export enum ENTITY_TYPE { - ACTION = "ACTION", - DATASOURCE = "DATASOURCE", - WIDGET = "WIDGET", - JSACTION = "JSACTION", -} - -export enum PLATFORM_ERROR { - PLUGIN_EXECUTION = "PLUGIN_EXECUTION", - JS_FUNCTION_EXECUTION = "JS_FUNCTION_EXECUTION", -} +import type { + ENTITY_TYPE, + PLATFORM_ERROR, +} from "@appsmith/entities/AppsmithConsole/utils"; export type Methods = | "log" diff --git a/app/client/src/entities/AppsmithConsole/logtype.ts b/app/client/src/entities/AppsmithConsole/logtype.ts index 33f59bc3a3f..b810a24f2f8 100644 --- a/app/client/src/entities/AppsmithConsole/logtype.ts +++ b/app/client/src/entities/AppsmithConsole/logtype.ts @@ -13,6 +13,7 @@ enum LOG_TYPE { JS_PARSE_SUCCESS, CYCLIC_DEPENDENCY_ERROR, LINT_ERROR, + MISSING_MODULE, } export default LOG_TYPE; diff --git a/app/client/src/entities/Replay/ReplayEntity/ReplayCanvas.ts b/app/client/src/entities/Replay/ReplayEntity/ReplayCanvas.ts index 0134501aa19..4ae382c66c2 100644 --- a/app/client/src/entities/Replay/ReplayEntity/ReplayCanvas.ts +++ b/app/client/src/entities/Replay/ReplayEntity/ReplayCanvas.ts @@ -11,7 +11,7 @@ import { WIDGETS, } from "../replayUtils"; import type { AppTheme } from "entities/AppTheming"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; export interface Canvas { widgets: CanvasWidgetsReduxState; diff --git a/app/client/src/entities/Replay/ReplayEntity/ReplayEditor.ts b/app/client/src/entities/Replay/ReplayEntity/ReplayEditor.ts index 364b201ba2d..34ae062ea59 100644 --- a/app/client/src/entities/Replay/ReplayEntity/ReplayEditor.ts +++ b/app/client/src/entities/Replay/ReplayEntity/ReplayEditor.ts @@ -4,7 +4,7 @@ import ReplayEntity from ".."; import { pathArrayToString } from "../replayUtils"; import type { JSActionConfig } from "entities/JSCollection"; import type { Datasource } from "entities/Datasource"; -import type { ENTITY_TYPE } from "entities/AppsmithConsole"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import isEmpty from "lodash/isEmpty"; import type { Canvas } from "./ReplayCanvas"; diff --git a/app/client/src/entities/Replay/index.ts b/app/client/src/entities/Replay/index.ts index 5429d5ca734..8f165a47ec8 100644 --- a/app/client/src/entities/Replay/index.ts +++ b/app/client/src/entities/Replay/index.ts @@ -4,7 +4,7 @@ import type { Diff } from "deep-diff"; import { diff as deepDiff, applyChange, revertChange } from "deep-diff"; import { getPathsFromDiff } from "./replayUtils"; -import type { ENTITY_TYPE } from "entities/AppsmithConsole"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; const _DIFF_ = "diff"; type ReplayType = "UNDO" | "REDO"; diff --git a/app/client/src/layoutSystems/anvil/utils/widgetAdditionUtils.ts b/app/client/src/layoutSystems/anvil/utils/widgetAdditionUtils.ts index c16db8c5af4..3577fc8cd20 100644 --- a/app/client/src/layoutSystems/anvil/utils/widgetAdditionUtils.ts +++ b/app/client/src/layoutSystems/anvil/utils/widgetAdditionUtils.ts @@ -2,7 +2,7 @@ import type { FlattenedWidgetProps } from "WidgetProvider/constants"; import type { WidgetAddChild } from "actions/pageActions"; import { WidgetReduxActionTypes } from "@appsmith/constants/ReduxActionConstants"; import { GridDefaults } from "constants/WidgetConstants"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer"; import { call, put } from "redux-saga/effects"; import { diff --git a/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx b/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx index b519889d9ed..9cc44743271 100644 --- a/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx +++ b/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx @@ -36,7 +36,7 @@ import _ from "lodash"; import FormLabel from "components/editorComponents/FormLabel"; import CopyToClipBoard from "components/designSystems/appsmith/CopyToClipBoard"; import { updateReplayEntity } from "actions/pageActions"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { TEMP_DATASOURCE_ID } from "constants/Datasource"; import { Form } from "./DBForm"; import { selectFeatureFlagCheck } from "@appsmith/selectors/featureFlagsSelectors"; diff --git a/app/client/src/pages/Editor/EntityNavigation/factory.ts b/app/client/src/pages/Editor/EntityNavigation/factory.ts index cf969c878ff..216c01096b8 100644 --- a/app/client/src/pages/Editor/EntityNavigation/factory.ts +++ b/app/client/src/pages/Editor/EntityNavigation/factory.ts @@ -2,7 +2,7 @@ import PropertyPaneNavigation from "./PropertyPane"; import ActionPaneNavigation from "./ActionPane"; import type { EntityInfo } from "./types"; import { call } from "redux-saga/effects"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type PaneNavigation from "./PaneNavigation"; import JSObjectsPaneNavigation from "./JSObjectsPane"; diff --git a/app/client/src/pages/Editor/EntityNavigation/types.ts b/app/client/src/pages/Editor/EntityNavigation/types.ts index b2069e41f95..7be2289c595 100644 --- a/app/client/src/pages/Editor/EntityNavigation/types.ts +++ b/app/client/src/pages/Editor/EntityNavigation/types.ts @@ -1,5 +1,5 @@ import type { PropertyPaneConfig } from "constants/PropertyControlConstants"; -import type { ENTITY_TYPE } from "entities/AppsmithConsole"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { JSEditorTab } from "reducers/uiReducers/jsPaneReducer"; export interface EntityInfo { diff --git a/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx b/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx index cfedc02a9e1..7d07d2d5717 100644 --- a/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx +++ b/app/client/src/pages/Editor/PropertyPane/PropertyControl.tsx @@ -33,7 +33,7 @@ import { import type { EnhancementFns } from "selectors/widgetEnhancementSelectors"; import type { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import { getExpectedValue } from "utils/validation/common"; import type { ControlData } from "components/propertyControls/BaseControl"; diff --git a/app/client/src/pages/Editor/PropertyPane/PropertyPaneConnections.tsx b/app/client/src/pages/Editor/PropertyPane/PropertyPaneConnections.tsx index fa82669f696..547fc556b25 100644 --- a/app/client/src/pages/Editor/PropertyPane/PropertyPaneConnections.tsx +++ b/app/client/src/pages/Editor/PropertyPane/PropertyPaneConnections.tsx @@ -15,7 +15,7 @@ import { } from "components/editorComponents/Debugger/helpers"; import { getFilteredErrors } from "selectors/debuggerSelectors"; import type { Log } from "entities/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { DebugButton } from "components/editorComponents/Debugger/DebugCTA"; import { showDebugger } from "actions/debuggerActions"; import AnalyticsUtil from "utils/AnalyticsUtil"; diff --git a/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx b/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx index 3a75188dba6..717ec8c330b 100644 --- a/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx +++ b/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx @@ -41,7 +41,7 @@ import { showDebuggerFlag, } from "selectors/debuggerSelectors"; import type { SourceEntity } from "entities/AppsmithConsole"; -import { ENTITY_TYPE as SOURCE_ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE as SOURCE_ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { DocsLink, openDoc } from "../../../constants/DocumentationLinks"; import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; diff --git a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts index 3fd78855e1d..5cfc7abbddd 100644 --- a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts +++ b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts @@ -63,7 +63,10 @@ import { unset, } from "lodash"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE, PLATFORM_ERROR } from "entities/AppsmithConsole"; +import { + ENTITY_TYPE, + PLATFORM_ERROR, +} from "@appsmith/entities/AppsmithConsole/utils"; import { extractClientDefinedErrorMetadata, validateResponse, diff --git a/app/client/src/sagas/ActionSagas.ts b/app/client/src/sagas/ActionSagas.ts index 327a1cf470b..17bc3799f8d 100644 --- a/app/client/src/sagas/ActionSagas.ts +++ b/app/client/src/sagas/ActionSagas.ts @@ -95,7 +95,7 @@ import { getConfigInitialValues, } from "components/formControls/utils"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import { createNewApiAction, diff --git a/app/client/src/sagas/ApiPaneSagas.ts b/app/client/src/sagas/ApiPaneSagas.ts index fa864ec9ee2..8c683caf7e5 100644 --- a/app/client/src/sagas/ApiPaneSagas.ts +++ b/app/client/src/sagas/ApiPaneSagas.ts @@ -67,7 +67,7 @@ import { queryParamsRegEx, } from "utils/ApiPaneUtils"; import { updateReplayEntity } from "actions/pageActions"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { Plugin } from "api/PluginApi"; import { getDisplayFormat } from "selectors/apiPaneSelectors"; import { diff --git a/app/client/src/sagas/AppThemingSaga.tsx b/app/client/src/sagas/AppThemingSaga.tsx index 3eb1f5c9f02..92b83d71d02 100644 --- a/app/client/src/sagas/AppThemingSaga.tsx +++ b/app/client/src/sagas/AppThemingSaga.tsx @@ -22,7 +22,7 @@ import { SAVE_APP_THEME, SET_DEFAULT_SELECTED_THEME, } from "@appsmith/constants/messages"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { updateReplayEntity } from "actions/pageActions"; import { getCanvasWidgets } from "@appsmith/selectors/entitiesSelector"; import { getAppMode } from "@appsmith/selectors/applicationSelectors"; diff --git a/app/client/src/sagas/DatasourcesSagas.ts b/app/client/src/sagas/DatasourcesSagas.ts index 43c93234953..845ba2467aa 100644 --- a/app/client/src/sagas/DatasourcesSagas.ts +++ b/app/client/src/sagas/DatasourcesSagas.ts @@ -117,7 +117,7 @@ import { OAUTH_AUTHORIZATION_SUCCESSFUL, } from "@appsmith/constants/messages"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import localStorage from "utils/localStorage"; import log from "loglevel"; import { APPSMITH_TOKEN_STORAGE_KEY } from "pages/Editor/SaaSEditor/constants"; diff --git a/app/client/src/sagas/DebuggerSagas.ts b/app/client/src/sagas/DebuggerSagas.ts index af8f9e24235..ed9bbc83f20 100644 --- a/app/client/src/sagas/DebuggerSagas.ts +++ b/app/client/src/sagas/DebuggerSagas.ts @@ -12,7 +12,8 @@ import type { LogActionPayload, LogObject, } from "entities/AppsmithConsole"; -import { ENTITY_TYPE, LOG_CATEGORY } from "entities/AppsmithConsole"; +import { LOG_CATEGORY } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { all, call, @@ -378,6 +379,10 @@ function* debuggerLogSaga(action: ReduxAction) { case LOG_TYPE.ENTITY_DELETED: yield fork(onEntityDeleteSaga, payload); break; + case LOG_TYPE.MISSING_MODULE: + yield put(addErrorLogs(payload)); + yield put(debuggerLog(payload)); + break; default: otherLogs = otherLogs.concat(payload); } diff --git a/app/client/src/sagas/EvalErrorHandler.ts b/app/client/src/sagas/EvalErrorHandler.ts index 87636297150..0dde75ec270 100644 --- a/app/client/src/sagas/EvalErrorHandler.ts +++ b/app/client/src/sagas/EvalErrorHandler.ts @@ -1,4 +1,8 @@ -import type { Log, ENTITY_TYPE } from "entities/AppsmithConsole"; +import type { Log } from "entities/AppsmithConsole"; +import { + getModuleInstanceInvalidErrors, + type ENTITY_TYPE, +} from "@appsmith/entities/AppsmithConsole/utils"; import { Severity } from "entities/AppsmithConsole"; import type { ConfigTree, DataTree } from "entities/DataTree/dataTreeTypes"; import { @@ -74,6 +78,18 @@ function logLatestEvalPropertyErrors( const payloadInfo = getEntityPayloadInfo[entityType](entityConfig); const entityNameToDisplay = payloadInfo.entityName || entityName; + const moduleInstanceErrors = getModuleInstanceInvalidErrors( + entity, + entityConfig, + propertyPath, + ); + + if (moduleInstanceErrors.length) { + moduleInstanceErrors.forEach((instanceError) => { + errorsToAdd.push(instanceError); + }); + } + if (!payloadInfo) continue; const debuggerKeys = [ diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index 618d63785e0..4eb3546e1eb 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -73,7 +73,7 @@ import { REPLAY_DELAY } from "entities/Replay/replayUtils"; import type { EvaluationVersion } from "@appsmith/api/ApplicationApi"; import type { LogObject } from "entities/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { Replayable } from "entities/Replay/ReplayEntity/ReplayEditor"; import type { FormEvaluationState } from "reducers/evaluationReducers/formEvaluationReducer"; import type { FormEvalActionPayload } from "./FormEvaluationSaga"; diff --git a/app/client/src/sagas/JSPaneSagas.ts b/app/client/src/sagas/JSPaneSagas.ts index 07cf7517fc7..79777228e2a 100644 --- a/app/client/src/sagas/JSPaneSagas.ts +++ b/app/client/src/sagas/JSPaneSagas.ts @@ -69,7 +69,10 @@ import { } from "@appsmith/constants/messages"; import { validateResponse } from "./ErrorSagas"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE, PLATFORM_ERROR } from "entities/AppsmithConsole"; +import { + ENTITY_TYPE, + PLATFORM_ERROR, +} from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { FetchPageRequest, FetchPageResponse } from "api/PageApi"; import PageApi from "api/PageApi"; diff --git a/app/client/src/sagas/OneClickBindingSaga.ts b/app/client/src/sagas/OneClickBindingSaga.ts index bf74bbee0e6..8cb4c6e3861 100644 --- a/app/client/src/sagas/OneClickBindingSaga.ts +++ b/app/client/src/sagas/OneClickBindingSaga.ts @@ -44,7 +44,7 @@ import ActionAPI from "api/ActionAPI"; import { validateResponse } from "./ErrorSagas"; import AnalyticsUtil from "utils/AnalyticsUtil"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { fetchActions, runAction } from "actions/pluginActionActions"; import { Toaster, Variant } from "design-system-old"; import WidgetFactory from "WidgetProvider/factory"; diff --git a/app/client/src/sagas/PostEvaluationSagas.ts b/app/client/src/sagas/PostEvaluationSagas.ts index e5fdd9a76e7..3716422c959 100644 --- a/app/client/src/sagas/PostEvaluationSagas.ts +++ b/app/client/src/sagas/PostEvaluationSagas.ts @@ -1,4 +1,7 @@ -import { ENTITY_TYPE, PLATFORM_ERROR } from "entities/AppsmithConsole"; +import { + ENTITY_TYPE, + PLATFORM_ERROR, +} from "@appsmith/entities/AppsmithConsole/utils"; import type { WidgetEntity, WidgetEntityConfig, diff --git a/app/client/src/sagas/PostLintingSagas.ts b/app/client/src/sagas/PostLintingSagas.ts index 5e9e7b679d5..7bf8997c941 100644 --- a/app/client/src/sagas/PostLintingSagas.ts +++ b/app/client/src/sagas/PostLintingSagas.ts @@ -1,4 +1,4 @@ -import { Severity, type ENTITY_TYPE } from "entities/AppsmithConsole"; +import { Severity } from "entities/AppsmithConsole"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { DataTree } from "entities/DataTree/dataTreeTypes"; import { isEmpty } from "lodash"; @@ -7,6 +7,7 @@ import { getEntityNameAndPropertyPath } from "@appsmith/workers/Evaluation/evalu import type { LintErrorsStore } from "reducers/lintingReducers/lintErrorsReducers"; import isLintErrorLoggingEnabledForEntity from "@appsmith/plugins/Linting/utils/isLintErrorLoggingEnabledForEntity"; import getEntityUniqueIdForLogs from "@appsmith/plugins/Linting/utils/getEntityUniqueIdForLogs"; +import type { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; // We currently only log lint errors in JSObjects export function* logLatestLintPropertyErrors({ @@ -52,7 +53,7 @@ export function* logLatestLintPropertyErrors({ source: { id: uniqueId, name: entityName, - type: entity.ENTITY_TYPE as unknown as ENTITY_TYPE, + type: entity.ENTITY_TYPE as ENTITY_TYPE, propertyPath, }, }, diff --git a/app/client/src/sagas/QueryPaneSagas.ts b/app/client/src/sagas/QueryPaneSagas.ts index 94994a41bac..dd757fac7c5 100644 --- a/app/client/src/sagas/QueryPaneSagas.ts +++ b/app/client/src/sagas/QueryPaneSagas.ts @@ -58,7 +58,7 @@ import { startFormEvaluations, } from "actions/evaluationActions"; import { updateReplayEntity } from "actions/pageActions"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { EventLocation } from "@appsmith/utils/analyticsUtilTypes"; import AnalyticsUtil from "utils/AnalyticsUtil"; import { diff --git a/app/client/src/sagas/ReplaySaga.ts b/app/client/src/sagas/ReplaySaga.ts index e26414358ce..aafd1b98fe3 100644 --- a/app/client/src/sagas/ReplaySaga.ts +++ b/app/client/src/sagas/ReplaySaga.ts @@ -62,7 +62,7 @@ import { API_EDITOR_TABS } from "constants/ApiEditorConstants/CommonApiConstants import { EDITOR_TABS } from "constants/QueryEditorConstants"; import _, { isEmpty } from "lodash"; import type { ReplayEditorUpdate } from "entities/Replay/ReplayEntity/ReplayEditor"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { Datasource } from "entities/Datasource"; import { initialize } from "redux-form"; import { diff --git a/app/client/src/sagas/WidgetAdditionSagas.ts b/app/client/src/sagas/WidgetAdditionSagas.ts index be042fb4095..fec9e8ba161 100644 --- a/app/client/src/sagas/WidgetAdditionSagas.ts +++ b/app/client/src/sagas/WidgetAdditionSagas.ts @@ -7,7 +7,7 @@ import { WidgetReduxActionTypes, } from "@appsmith/constants/ReduxActionConstants"; import { RenderModes } from "constants/WidgetConstants"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { CanvasWidgetsReduxState, FlattenedWidgetProps, diff --git a/app/client/src/sagas/WidgetDeletionSagas.ts b/app/client/src/sagas/WidgetDeletionSagas.ts index 88926eb7682..0a59e03df32 100644 --- a/app/client/src/sagas/WidgetDeletionSagas.ts +++ b/app/client/src/sagas/WidgetDeletionSagas.ts @@ -13,7 +13,7 @@ import { ReduxActionTypes, WidgetReduxActionTypes, } from "@appsmith/constants/ReduxActionConstants"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import { flattenDeep, omit, orderBy } from "lodash"; import type { diff --git a/app/client/src/sagas/helper.ts b/app/client/src/sagas/helper.ts index d025e9a1a84..c007c4d00cc 100644 --- a/app/client/src/sagas/helper.ts +++ b/app/client/src/sagas/helper.ts @@ -7,12 +7,11 @@ import type { import AppsmithConsole from "utils/AppsmithConsole"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { Log } from "entities/AppsmithConsole"; +import { LOG_CATEGORY, Severity } from "entities/AppsmithConsole"; import { ENTITY_TYPE, - LOG_CATEGORY, PLATFORM_ERROR, - Severity, -} from "entities/AppsmithConsole"; +} from "@appsmith/entities/AppsmithConsole/utils"; import { toast } from "design-system"; import { ReduxActionTypes, diff --git a/app/client/src/selectors/debuggerSelectors.test.ts b/app/client/src/selectors/debuggerSelectors.test.ts index 366a2bff907..0ecf4a9c9af 100644 --- a/app/client/src/selectors/debuggerSelectors.test.ts +++ b/app/client/src/selectors/debuggerSelectors.test.ts @@ -1,4 +1,5 @@ -import { Severity, ENTITY_TYPE, LOG_CATEGORY } from "entities/AppsmithConsole"; +import { Severity, LOG_CATEGORY } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { DataTree } from "entities/DataTree/dataTreeTypes"; import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer"; diff --git a/app/client/src/utils/JSPaneUtils.tsx b/app/client/src/utils/JSPaneUtils.tsx index eaa90d320bd..716085c5691 100644 --- a/app/client/src/utils/JSPaneUtils.tsx +++ b/app/client/src/utils/JSPaneUtils.tsx @@ -1,6 +1,6 @@ //check difference for after body change and parsing import type { JSCollection, JSAction, Variable } from "entities/JSCollection"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import AppsmithConsole from "utils/AppsmithConsole"; import { isEmpty, isEqual, xorWith } from "lodash"; diff --git a/app/client/src/widgets/BaseWidget.tsx b/app/client/src/widgets/BaseWidget.tsx index 5117286614f..783504d0391 100644 --- a/app/client/src/widgets/BaseWidget.tsx +++ b/app/client/src/widgets/BaseWidget.tsx @@ -16,7 +16,7 @@ import type { WidgetType, } from "constants/WidgetConstants"; import { RenderModes } from "constants/WidgetConstants"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import type { SetterConfig, Stylesheet } from "entities/AppTheming"; import type { Context, ReactNode, RefObject } from "react"; import { Component } from "react"; diff --git a/app/client/src/widgets/MetaHOC.tsx b/app/client/src/widgets/MetaHOC.tsx index d888e4c01d6..5da949c0819 100644 --- a/app/client/src/widgets/MetaHOC.tsx +++ b/app/client/src/widgets/MetaHOC.tsx @@ -3,7 +3,7 @@ import type { WidgetProps } from "./BaseWidget"; import { debounce, fromPairs, isEmpty } from "lodash"; import { EditorContext } from "components/editorComponents/EditorContextProvider"; import AppsmithConsole from "utils/AppsmithConsole"; -import { ENTITY_TYPE } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import LOG_TYPE from "entities/AppsmithConsole/logtype"; import type { ExecuteTriggerPayload } from "constants/AppsmithActionConstants/ActionConstants"; import { connect } from "react-redux"; diff --git a/app/client/src/workers/Evaluation/fns/overrides/console.ts b/app/client/src/workers/Evaluation/fns/overrides/console.ts index 0c342cffd3b..c2916a584e1 100644 --- a/app/client/src/workers/Evaluation/fns/overrides/console.ts +++ b/app/client/src/workers/Evaluation/fns/overrides/console.ts @@ -4,7 +4,8 @@ import type { Methods, SourceEntity, } from "entities/AppsmithConsole"; -import { ENTITY_TYPE, Severity } from "entities/AppsmithConsole"; +import { Severity } from "entities/AppsmithConsole"; +import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils"; import { klona } from "klona/lite"; import moment from "moment"; import type { TriggerMeta } from "@appsmith/sagas/ActionExecution/ActionExecutionSagas"; From c2679650909b4239cefe5c5f8d90a90def6f69e2 Mon Sep 17 00:00:00 2001 From: Nilesh Sarupriya Date: Wed, 14 Feb 2024 00:48:30 -0600 Subject: [PATCH 02/11] chore: refactor curl import API to support context type (#30934) ## Description Support curl imports for different contexts. ### Server changes Previous API: `/api/v1/import?type=CURL&pageId={pageId}&name=Api2&workspaceId={workspaceId}` New API: With context type, it will create for the specific context. `/api/v1/import?type=CURL&contextId={contextId}&name=Api1&workspaceId={workspaceId}&contextType={contextType}` Without context type, it will create for the page. `/api/v1/import?type=CURL&contextId={contextId}&name=Api1&workspaceId={workspaceId}` ### Client changes - Integrate api changes for curl import. Updated request params type and interfaces for the saga functions - Updated the form value types for the curl import editor #### PR fixes following issue(s) Fixes [[Task]: Curl Import isn't working.](https://github.com/appsmithorg/appsmith/issues/30933) #### Media > N/A #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? - [x] Manual (using postman) - [x] JUnit (existing test cases should work) #### Test Plan > N/A #### Issues raised during DP testing > None ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced API import functionality with a new context-aware mechanism, allowing for more flexible integration within different parts of the application. - Updated various components and services to support the new contextId and contextType parameters for improved data handling and redirection logic. --------- Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ayush Pahwa --- app/client/src/api/ImportApi.ts | 9 +++-- .../Editor/APIEditor/CurlImportEditor.tsx | 4 +- .../src/pages/Editor/APIEditor/helpers.ts | 4 +- app/client/src/sagas/CurlImportSagas.ts | 11 ++++-- .../ce/RestApiImportControllerCE.java | 6 ++- .../server/services/ce/ApiImporterCE.java | 9 ++++- .../server/services/ce/BaseApiImporterCE.java | 8 +++- .../ce/CurlImporterServiceCEImpl.java | 38 ++++++++++++++----- .../services/CurlImporterServiceTest.java | 17 +++++---- 9 files changed, 76 insertions(+), 30 deletions(-) diff --git a/app/client/src/api/ImportApi.ts b/app/client/src/api/ImportApi.ts index 4704daae0c6..20609a2d227 100644 --- a/app/client/src/api/ImportApi.ts +++ b/app/client/src/api/ImportApi.ts @@ -1,13 +1,15 @@ import type { AxiosPromise } from "axios"; import Api from "api/Api"; import type { ApiResponse } from "./ApiResponses"; +import type { ActionParentEntityTypeInterface } from "@appsmith/entities/Engine/actionHelpers"; export interface CurlImportRequest { type: string; - pageId: string; + contextId: string; name: string; curl: string; workspaceId: string; + contextType: ActionParentEntityTypeInterface; } class CurlImportApi extends Api { @@ -16,12 +18,13 @@ class CurlImportApi extends Api { static async curlImport( request: CurlImportRequest, ): Promise> { - const { curl, name, pageId, workspaceId } = request; + const { contextId, contextType, curl, name, workspaceId } = request; return Api.post(CurlImportApi.curlImportURL, curl, { type: "CURL", - pageId, + contextId, name, workspaceId, + contextType, }); } } diff --git a/app/client/src/pages/Editor/APIEditor/CurlImportEditor.tsx b/app/client/src/pages/Editor/APIEditor/CurlImportEditor.tsx index 8f6488a4018..aba46cc8e53 100644 --- a/app/client/src/pages/Editor/APIEditor/CurlImportEditor.tsx +++ b/app/client/src/pages/Editor/APIEditor/CurlImportEditor.tsx @@ -12,6 +12,7 @@ import CloseEditor from "components/editorComponents/CloseEditor"; import { CreateNewActionKey } from "@appsmith/entities/Engine/actionHelpers"; import { DEFAULT_PREFIX } from "sagas/ActionSagas"; import { useIsEditorPaneSegmentsEnabled } from "../IDE/hooks"; +import { ActionParentEntityType } from "@appsmith/entities/Engine/actionHelpers"; type CurlImportEditorProps = RouteComponentProps; @@ -29,7 +30,8 @@ function CurlImportEditor(props: CurlImportEditorProps) { const isImportingCurl = useSelector(getIsImportingCurl); const initialFormValues = { - pageId, + contextId: pageId, + contextType: ActionParentEntityType.PAGE, name: actionName, }; const isEditorPaneEnabled = useIsEditorPaneSegmentsEnabled(); diff --git a/app/client/src/pages/Editor/APIEditor/helpers.ts b/app/client/src/pages/Editor/APIEditor/helpers.ts index b752e18bd74..96b42cb9dda 100644 --- a/app/client/src/pages/Editor/APIEditor/helpers.ts +++ b/app/client/src/pages/Editor/APIEditor/helpers.ts @@ -1,9 +1,11 @@ import { submitCurlImportForm } from "actions/importActions"; +import type { ActionParentEntityTypeInterface } from "@appsmith/entities/Engine/actionHelpers"; export interface curlImportFormValues { curl: string; - pageId: string; + contextId: string; name: string; + contextType: ActionParentEntityTypeInterface; } export const curlImportSubmitHandler = ( diff --git a/app/client/src/sagas/CurlImportSagas.ts b/app/client/src/sagas/CurlImportSagas.ts index cd2d0d87ec2..25cd9d38099 100644 --- a/app/client/src/sagas/CurlImportSagas.ts +++ b/app/client/src/sagas/CurlImportSagas.ts @@ -16,17 +16,18 @@ import { CURL } from "constants/AppsmithActionConstants/ActionConstants"; import { apiEditorIdURL } from "@appsmith/RouteBuilder"; export function* curlImportSaga(action: ReduxAction) { - const { name, pageId, type } = action.payload; + const { contextId, contextType, name, type } = action.payload; let { curl } = action.payload; try { curl = transformCurlImport(curl); const workspaceId: string = yield select(getCurrentWorkspaceId); const request: CurlImportRequest = { type, - pageId, + contextId, name, curl, workspaceId, + contextType, }; const response: ApiResponse = yield CurlImportApi.curlImport(request); @@ -42,8 +43,10 @@ export function* curlImportSaga(action: ReduxAction) { payload: response.data, }); - // @ts-expect-error: response.data is of type unknown - history.push(apiEditorIdURL({ pageId, apiId: response.data.id })); + history.push( + // @ts-expect-error: response.data is of type unknown + apiEditorIdURL({ parentEntityId: contextId, apiId: response.data.id }), + ); } } catch (error) { yield put({ diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/RestApiImportControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/RestApiImportControllerCE.java index 3042d5f5473..f49ac3f1be3 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/RestApiImportControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/RestApiImportControllerCE.java @@ -1,6 +1,7 @@ package com.appsmith.server.controllers.ce; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.views.Views; import com.appsmith.server.constants.FieldName; import com.appsmith.server.constants.Url; @@ -35,9 +36,10 @@ public RestApiImportControllerCE(CurlImporterService curlImporterService) { public Mono> create( @RequestBody(required = false) Object input, @RequestParam RestApiImporterType type, - @RequestParam String pageId, + @RequestParam String contextId, @RequestParam String name, @RequestParam String workspaceId, + @RequestParam(required = false) CreatorContextType contextType, @RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName, @RequestHeader(name = "Origin", required = false) String originHeader) { log.debug("Going to import API"); @@ -51,7 +53,7 @@ public Mono> create( throw new IllegalStateException("Unexpected value: " + type); } - return service.importAction(input, pageId, name, workspaceId, branchName) + return service.importAction(input, contextType, contextId, name, workspaceId, branchName) .map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null)); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApiImporterCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApiImporterCE.java index 546a3e0a960..82a59b22405 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApiImporterCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApiImporterCE.java @@ -1,9 +1,16 @@ package com.appsmith.server.services.ce; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import reactor.core.publisher.Mono; public interface ApiImporterCE { - Mono importAction(Object input, String pageId, String name, String workspaceId, String branchName); + Mono importAction( + Object input, + CreatorContextType contextType, + String contextId, + String name, + String workspaceId, + String branchName); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/BaseApiImporterCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/BaseApiImporterCE.java index 3e618e0c105..a6f3c286847 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/BaseApiImporterCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/BaseApiImporterCE.java @@ -1,10 +1,16 @@ package com.appsmith.server.services.ce; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import reactor.core.publisher.Mono; public abstract class BaseApiImporterCE implements ApiImporterCE { public abstract Mono importAction( - Object input, String pageId, String name, String workspaceId, String branchName); + Object input, + CreatorContextType contextType, + String contextId, + String name, + String workspaceId, + String branchName); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java index e7127297f40..0b5ca1678a4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java @@ -2,6 +2,7 @@ import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.Property; @@ -33,6 +34,7 @@ import java.util.Base64; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.regex.Pattern; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -75,7 +77,12 @@ public CurlImporterServiceCEImpl( @Override public Mono importAction( - Object input, String pageId, String name, String workspaceId, String branchName) { + Object input, + CreatorContextType contextType, + String contextId, + String name, + String workspaceId, + String branchName) { ActionDTO action; try { @@ -91,31 +98,42 @@ public Mono importAction( return Mono.error(new AppsmithException(AppsmithError.INVALID_CURL_COMMAND)); } - Mono pageMono = newPageService.findByBranchNameAndDefaultPageId( - branchName, pageId, pagePermission.getActionCreatePermission()); - // Set the default values for datasource (plugin, name) and then create the action // with embedded datasource - return Mono.zip(Mono.just(action), pluginService.findByPackageName(RESTAPI_PLUGIN), pageMono) + return Mono.zip(Mono.just(action), pluginService.findByPackageName(RESTAPI_PLUGIN)) .flatMap(tuple -> { final ActionDTO action1 = tuple.getT1(); final Plugin plugin = tuple.getT2(); - final NewPage newPage = tuple.getT3(); final Datasource datasource = action1.getDatasource(); final DatasourceConfiguration datasourceConfiguration = datasource.getDatasourceConfiguration(); datasource.setName(datasourceConfiguration.getUrl()); datasource.setPluginId(plugin.getId()); datasource.setWorkspaceId(workspaceId); - // Set git related resource IDs - action1.setDefaultResources(newPage.getDefaultResources()); - action1.setPageId(newPage.getId()); - return Mono.just(action1); + return getBranchedContextId(contextType, contextId, branchName) + .flatMap(branchedContextId -> + associateContextIdToActionDTO(action1, contextType, branchedContextId)); }) .flatMap(action2 -> layoutActionService.createSingleAction(action2, Boolean.FALSE)) .map(responseUtils::updateActionDTOWithDefaultResources); } + protected Mono getBranchedContextId(CreatorContextType contextType, String contextId, String branchName) { + return newPageService + .findByBranchNameAndDefaultPageId(branchName, contextId, pagePermission.getActionCreatePermission()) + .map(NewPage::getId); + } + + protected Mono associateContextIdToActionDTO( + ActionDTO actionDTO, CreatorContextType contextType, String contextId) { + actionDTO.setPageId(contextId); + return newPageService.findById(contextId, Optional.empty()).map(newPage -> { + // Set git related resource IDs + actionDTO.setDefaultResources(newPage.getDefaultResources()); + return actionDTO; + }); + } + public ActionDTO curlToAction(String command, String name) throws AppsmithException { ActionDTO action = curlToAction(command); if (action != null) { diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java index 3103208da50..41ad9260e8e 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java @@ -327,7 +327,8 @@ public void testImportActionOnInvalidInput() { .block(); assert page != null; - Mono action = curlImporterService.importAction("'", page.getId(), "actionName", workspaceId, null); + Mono action = + curlImporterService.importAction("'", null, page.getId(), "actionName", workspaceId, null); StepVerifier.create(action) .expectErrorMatches(throwable -> throwable instanceof AppsmithException @@ -350,7 +351,8 @@ public void testImportActionOnNullInput() { .block(); assert page != null; - Mono action = curlImporterService.importAction(null, page.getId(), "actionName", workspaceId, null); + Mono action = + curlImporterService.importAction(null, null, page.getId(), "actionName", workspaceId, null); StepVerifier.create(action) .expectErrorMatches(throwable -> throwable instanceof AppsmithException @@ -373,7 +375,8 @@ public void testImportActionOnEmptyInput() { .block(); assert page != null; - Mono action = curlImporterService.importAction("", page.getId(), "actionName", workspaceId, null); + Mono action = + curlImporterService.importAction("", null, page.getId(), "actionName", workspaceId, null); StepVerifier.create(action) .expectErrorMatches(throwable -> throwable instanceof AppsmithException @@ -415,8 +418,8 @@ public void importValidCurlCommand() { "curl -X GET http://localhost:8080/api/v1/actions?name=something -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Authorization: Basic YXBpX3VzZXI6OHVBQDsmbUI6Y252Tn57Iw==' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -H 'Cookie: SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5,SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5; SESSION=' -H 'Host: localhost:8080' -H 'Postman-Token: 16e4b6bc-2c7a-4ab1-a127-bca382dfc0f0,a6655daa-db07-4c5e-aca3-3fd505bd230d' -H 'User-Agent: PostmanRuntime/7.20.1' -H 'cache-control: no-cache' -d '{someJson}'"; Mono resultMono = defaultPageMono - .flatMap(page -> - curlImporterService.importAction(command, page.getId(), "actionName", workspaceId, "main")) + .flatMap(page -> curlImporterService.importAction( + command, null, page.getId(), "actionName", workspaceId, "main")) .cache(); Mono savedActionMono = resultMono.flatMap(actionDTO -> newActionService.getById(actionDTO.getId())); @@ -472,7 +475,7 @@ public void importValidCurlCommand() { Mono branchedResultMono = branchedPageMono .flatMap(page -> curlImporterService.importAction( - command, page.getDefaultResources().getPageId(), "actionName", workspaceId, "testBranch")) + command, null, page.getDefaultResources().getPageId(), "actionName", workspaceId, "testBranch")) .cache(); // As importAction updates the ids with the defaultIds before sending the response to client we have to again @@ -1047,7 +1050,7 @@ public void importInvalidCurlCommand() { String command = "invalid curl command here"; Mono actionMono = - curlImporterService.importAction(command, "pageId", "actionName", workspaceId, null); + curlImporterService.importAction(command, null, "pageId", "actionName", workspaceId, null); StepVerifier.create(actionMono).verifyError(); } From d558ce0a2937c2962c811000a5936d03fcbbbefd Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 14 Feb 2024 14:22:04 +0530 Subject: [PATCH 03/11] fix: Datasource null check in QueryDebugger (#31115) Adds null check for datasources as sometimes they may not be available ## Summary by CodeRabbit - **Bug Fixes** - Improved reliability in accessing datasource properties within the Query Debugger, ensuring safer operations and correcting the datasource structure fetching process. --- .../pages/Editor/QueryEditor/QueryDebuggerTabs.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx b/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx index 532c6cf8d0e..ea82cda35a3 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx @@ -98,18 +98,21 @@ function QueryDebuggerTabs({ ); const datasourceStructure = useSelector((state) => - getDatasourceStructureById(state, currentActionConfig?.datasource.id || ""), + getDatasourceStructureById( + state, + currentActionConfig?.datasource?.id ?? "", + ), ); useEffect(() => { if ( - currentActionConfig?.datasource.id && + currentActionConfig?.datasource?.id && datasourceStructure === undefined && pluginDatasourceForm !== DatasourceComponentTypes.RestAPIDatasourceForm ) { dispatch( fetchDatasourceStructure( - currentActionConfig?.datasource.id, + currentActionConfig.datasource.id, true, DatasourceStructureContext.QUERY_EDITOR, ), @@ -180,7 +183,7 @@ function QueryDebuggerTabs({ }); } - if (showSchema && currentActionConfig) { + if (showSchema && currentActionConfig && currentActionConfig.datasource) { responseTabs.unshift({ key: "schema", title: "Schema", From 0d77289e9c1e2f385d6c6bb61c578a795a34bdeb Mon Sep 17 00:00:00 2001 From: Manish Kumar <107841575+sondermanish@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:43:14 +0530 Subject: [PATCH 04/11] chore: added split for permission provider (#31111) --- .../base/ApplicationImportServiceCEImpl.java | 2 +- .../DatasourceImportableServiceCEImpl.java | 2 +- .../server/dtos/ImportingMetaDTO.java | 2 +- .../ImportArtifactPermissionProvider.java | 124 ++++++++++++++++++ ...> ImportArtifactPermissionProviderCE.java} | 102 ++------------ .../internal/ContextBasedImportServiceCE.java | 2 +- .../imports/internal/ImportServiceCEImpl.java | 2 +- .../internal/PartialImportServiceCEImpl.java | 2 +- .../NewActionImportableServiceCEImpl.java | 2 +- .../NewPageImportableServiceCEImpl.java | 2 +- .../server/solutions/ContextPermission.java | 5 + .../solutions/ce/ContextPermissionCE.java | 14 ++ .../server/solutions/ce/PagePermissionCE.java | 8 +- .../ImportArtifactPermissionProviderTest.java | 7 +- 14 files changed, 169 insertions(+), 107 deletions(-) create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ImportArtifactPermissionProvider.java rename app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/{ImportArtifactPermissionProvider.java => ImportArtifactPermissionProviderCE.java} (57%) create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ContextPermission.java create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ContextPermissionCE.java diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationImportServiceCEImpl.java index 799ca66913b..b71ca409670 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationImportServiceCEImpl.java @@ -21,7 +21,7 @@ import com.appsmith.server.dtos.MappedImportableResourcesDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportableService; import com.appsmith.server.layouts.UpdateLayoutService; import com.appsmith.server.migrations.ApplicationVersion; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/imports/DatasourceImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/imports/DatasourceImportableServiceCEImpl.java index 6e141168fb6..e6cad3e9ea4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/imports/DatasourceImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/imports/DatasourceImportableServiceCEImpl.java @@ -21,7 +21,7 @@ import com.appsmith.server.dtos.MappedImportableResourcesDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportableServiceCE; import com.appsmith.server.services.SequenceService; import com.appsmith.server.services.WorkspaceService; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java index 9d08a3de451..1ccb01792e2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java @@ -1,6 +1,6 @@ package com.appsmith.server.dtos; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ImportArtifactPermissionProvider.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ImportArtifactPermissionProvider.java new file mode 100644 index 00000000000..56e8f1e5e13 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ImportArtifactPermissionProvider.java @@ -0,0 +1,124 @@ +package com.appsmith.server.helpers; + +import com.appsmith.server.acl.AclPermission; +import com.appsmith.server.helpers.ce.ImportArtifactPermissionProviderCE; +import com.appsmith.server.solutions.ActionPermission; +import com.appsmith.server.solutions.ArtifactPermission; +import com.appsmith.server.solutions.ContextPermission; +import com.appsmith.server.solutions.DatasourcePermission; +import com.appsmith.server.solutions.WorkspacePermission; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.Set; + +public class ImportArtifactPermissionProvider extends ImportArtifactPermissionProviderCE { + + public ImportArtifactPermissionProvider( + ArtifactPermission artifactPermission, + ContextPermission contextPermission, + ActionPermission actionPermission, + DatasourcePermission datasourcePermission, + WorkspacePermission workspacePermission, + AclPermission requiredPermissionOnTargetWorkspace, + AclPermission requiredPermissionOnTargetApplication, + Set currentUserPermissionGroups, + boolean permissionRequiredToCreateDatasource, + boolean permissionRequiredToCreatePage, + boolean permissionRequiredToEditPage, + boolean permissionRequiredToCreateAction, + boolean permissionRequiredToEditAction, + boolean permissionRequiredToEditDatasource) { + super( + artifactPermission, + contextPermission, + actionPermission, + datasourcePermission, + workspacePermission, + requiredPermissionOnTargetWorkspace, + requiredPermissionOnTargetApplication, + currentUserPermissionGroups, + permissionRequiredToCreateDatasource, + permissionRequiredToCreatePage, + permissionRequiredToEditPage, + permissionRequiredToCreateAction, + permissionRequiredToEditAction, + permissionRequiredToEditDatasource); + } + + public static Builder builder( + ArtifactPermission artifactPermission, + ContextPermission contextPermission, + ActionPermission actionPermission, + DatasourcePermission datasourcePermission, + WorkspacePermission workspacePermission) { + + return new Builder( + artifactPermission, contextPermission, actionPermission, datasourcePermission, workspacePermission); + } + + @Setter + @Accessors(chain = true, fluent = true) + public static class Builder { + private final ArtifactPermission artifactPermission; + private final ContextPermission contextPermission; + private final ActionPermission actionPermission; + private final DatasourcePermission datasourcePermission; + private final WorkspacePermission workspacePermission; + + private AclPermission requiredPermissionOnTargetWorkspace; + private AclPermission requiredPermissionOnTargetApplication; + + private Set currentUserPermissionGroups; + + private boolean permissionRequiredToCreateDatasource; + private boolean permissionRequiredToCreatePage; + private boolean permissionRequiredToEditContext; + private boolean permissionRequiredToCreateAction; + private boolean permissionRequiredToEditAction; + private boolean permissionRequiredToEditDatasource; + + private Builder( + ArtifactPermission artifactPermission, + ContextPermission contextPermission, + ActionPermission actionPermission, + DatasourcePermission datasourcePermission, + WorkspacePermission workspacePermission) { + this.artifactPermission = artifactPermission; + this.contextPermission = contextPermission; + this.actionPermission = actionPermission; + this.datasourcePermission = datasourcePermission; + this.workspacePermission = workspacePermission; + } + + public Builder allPermissionsRequired() { + this.permissionRequiredToCreateDatasource = true; + this.permissionRequiredToCreatePage = true; + this.permissionRequiredToEditContext = true; + this.permissionRequiredToCreateAction = true; + this.permissionRequiredToEditAction = true; + this.permissionRequiredToEditDatasource = true; + return this; + } + + public ImportArtifactPermissionProvider build() { + // IMPORTANT: make sure that we've added unit tests for all the properties. + // Otherwise, we may end up passing value of one attribute of same type to another. + return new ImportArtifactPermissionProvider( + artifactPermission, + contextPermission, + actionPermission, + datasourcePermission, + workspacePermission, + requiredPermissionOnTargetWorkspace, + requiredPermissionOnTargetApplication, + currentUserPermissionGroups, + permissionRequiredToCreateDatasource, + permissionRequiredToCreatePage, + permissionRequiredToEditContext, + permissionRequiredToCreateAction, + permissionRequiredToEditAction, + permissionRequiredToEditDatasource); + } + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProvider.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderCE.java similarity index 57% rename from app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProvider.java rename to app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderCE.java index 2295fdaf34e..19bdf207ca6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProvider.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderCE.java @@ -10,14 +10,12 @@ import com.appsmith.server.solutions.ActionPermission; import com.appsmith.server.solutions.ApplicationPermission; import com.appsmith.server.solutions.ArtifactPermission; +import com.appsmith.server.solutions.ContextPermission; import com.appsmith.server.solutions.DatasourcePermission; -import com.appsmith.server.solutions.PagePermission; import com.appsmith.server.solutions.WorkspacePermission; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; import java.util.Set; @@ -40,12 +38,12 @@ */ @AllArgsConstructor @Getter -public class ImportArtifactPermissionProvider { +public class ImportArtifactPermissionProviderCE { @Getter(AccessLevel.NONE) private final ArtifactPermission artifactPermission; @Getter(AccessLevel.NONE) - private final PagePermission pagePermission; + protected final ContextPermission contextPermission; @Getter(AccessLevel.NONE) private final ActionPermission actionPermission; @@ -62,6 +60,9 @@ public class ImportArtifactPermissionProvider { // minimum required permission on the application being updated in the import flow private final AclPermission requiredPermissionOnTargetApplication; + // all the permission groups of the current user + private final Set currentUserPermissionGroups; + /* Following fields are flags to indicate whether permission check is required on the corresponding operation. */ @@ -71,19 +72,15 @@ public class ImportArtifactPermissionProvider { // flag to indicate whether permission check is required on the create page operation private boolean permissionRequiredToCreatePage; // flag to indicate whether permission check is required on the edit page operation - private boolean permissionRequiredToEditPage; - + protected boolean permissionRequiredToEditContext; // flag to indicate whether permission check is required on the create action operation - private boolean permissionRequiredToCreateAction; + protected boolean permissionRequiredToCreateAction; // flag to indicate whether permission check is required on the edit action operation private boolean permissionRequiredToEditAction; // flag to indicate whether permission check is required during the edit datasource operation private boolean permissionRequiredToEditDatasource; - // all the permission groups of the current user - private final Set currentUserPermissionGroups; - /** * Helper method to check whether the provided permission is present in the provided baseDomain's policies. * If yes, it checks whether the matched policy has a permission group from the currentUserPermissionGroups. @@ -92,7 +89,7 @@ public class ImportArtifactPermissionProvider { * @param baseDomain BaseDomain where the permission is being checked * @return True if there is a match, false otherwise */ - private boolean hasPermission(AclPermission permission, BaseDomain baseDomain) { + protected boolean hasPermission(AclPermission permission, BaseDomain baseDomain) { if (permission == null) { return true; } @@ -101,10 +98,10 @@ private boolean hasPermission(AclPermission permission, BaseDomain baseDomain) { } public boolean hasEditPermission(NewPage page) { - if (!permissionRequiredToEditPage) { + if (!permissionRequiredToEditContext) { return true; } - return hasPermission(pagePermission.getEditPermission(), page); + return hasPermission(contextPermission.getEditPermission(), page); } public boolean hasEditPermission(NewAction action) { @@ -132,7 +129,7 @@ public boolean canCreateAction(NewPage page) { if (!permissionRequiredToCreateAction) { return true; } - return hasPermission(pagePermission.getActionCreatePermission(), page); + return hasPermission(contextPermission.getActionCreatePermission(), page); } public boolean canCreateDatasource(Workspace workspace) { @@ -141,79 +138,4 @@ public boolean canCreateDatasource(Workspace workspace) { } return hasPermission(workspacePermission.getDatasourceCreatePermission(), workspace); } - - public static Builder builder( - ArtifactPermission artifactPermission, - PagePermission pagePermission, - ActionPermission actionPermission, - DatasourcePermission datasourcePermission, - WorkspacePermission workspacePermission) { - return new Builder( - artifactPermission, pagePermission, actionPermission, datasourcePermission, workspacePermission); - } - - @Setter - @Accessors(chain = true, fluent = true) - public static class Builder { - private final ArtifactPermission artifactPermission; - private final PagePermission pagePermission; - private final ActionPermission actionPermission; - private final DatasourcePermission datasourcePermission; - private final WorkspacePermission workspacePermission; - - private AclPermission requiredPermissionOnTargetWorkspace; - private AclPermission requiredPermissionOnTargetApplication; - - private Set currentUserPermissionGroups; - - private boolean permissionRequiredToCreateDatasource; - private boolean permissionRequiredToCreatePage; - private boolean permissionRequiredToEditPage; - private boolean permissionRequiredToCreateAction; - private boolean permissionRequiredToEditAction; - private boolean permissionRequiredToEditDatasource; - - private Builder( - ArtifactPermission artifactPermission, - PagePermission pagePermission, - ActionPermission actionPermission, - DatasourcePermission datasourcePermission, - WorkspacePermission workspacePermission) { - this.artifactPermission = artifactPermission; - this.pagePermission = pagePermission; - this.actionPermission = actionPermission; - this.datasourcePermission = datasourcePermission; - this.workspacePermission = workspacePermission; - } - - public Builder allPermissionsRequired() { - this.permissionRequiredToCreateDatasource = true; - this.permissionRequiredToCreatePage = true; - this.permissionRequiredToEditPage = true; - this.permissionRequiredToCreateAction = true; - this.permissionRequiredToEditAction = true; - this.permissionRequiredToEditDatasource = true; - return this; - } - - public ImportArtifactPermissionProvider build() { - // IMPORTANT: make sure that we've added unit tests for all the properties. - // Otherwise, we may end up passing value of one attribute of same type to another. - return new ImportArtifactPermissionProvider( - artifactPermission, - pagePermission, - actionPermission, - datasourcePermission, - workspacePermission, - requiredPermissionOnTargetWorkspace, - requiredPermissionOnTargetApplication, - permissionRequiredToCreateDatasource, - permissionRequiredToCreatePage, - permissionRequiredToEditPage, - permissionRequiredToCreateAction, - permissionRequiredToEditAction, - permissionRequiredToEditDatasource, - currentUserPermissionGroups); - } - } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ContextBasedImportServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ContextBasedImportServiceCE.java index f46772c9e8e..1baa21a9ab8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ContextBasedImportServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ContextBasedImportServiceCE.java @@ -8,7 +8,7 @@ import com.appsmith.server.dtos.ImportableArtifactDTO; import com.appsmith.server.dtos.ImportingMetaDTO; import com.appsmith.server.dtos.MappedImportableResourcesDTO; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java index b358686222a..839b2931cb0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java @@ -18,8 +18,8 @@ import com.appsmith.server.dtos.MappedImportableResourcesDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.helpers.ImportExportUtils; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportServiceCE; import com.appsmith.server.imports.importable.ImportableService; import com.appsmith.server.migrations.ArtifactSchemaMigration; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/PartialImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/PartialImportServiceCEImpl.java index ad9ac3e92e6..7cd4bb13883 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/PartialImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/PartialImportServiceCEImpl.java @@ -21,7 +21,7 @@ import com.appsmith.server.dtos.MappedImportableResourcesDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportService; import com.appsmith.server.imports.importable.ImportableService; import com.appsmith.server.newpages.base.NewPageService; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/imports/NewActionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/imports/NewActionImportableServiceCEImpl.java index e45a88d3c2f..dea024cc94a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/imports/NewActionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/imports/NewActionImportableServiceCEImpl.java @@ -18,7 +18,7 @@ import com.appsmith.server.dtos.MappedImportableResourcesDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportableServiceCE; import com.appsmith.server.newactions.base.NewActionService; import com.appsmith.server.repositories.NewActionRepository; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/imports/NewPageImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/imports/NewPageImportableServiceCEImpl.java index d9fb5c066f2..8fd70eb0cb1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/imports/NewPageImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/imports/NewPageImportableServiceCEImpl.java @@ -16,8 +16,8 @@ import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.helpers.DefaultResourcesUtils; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.helpers.TextUtils; -import com.appsmith.server.helpers.ce.ImportArtifactPermissionProvider; import com.appsmith.server.imports.importable.ImportableServiceCE; import com.appsmith.server.newactions.base.NewActionService; import com.appsmith.server.newpages.base.NewPageService; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ContextPermission.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ContextPermission.java new file mode 100644 index 00000000000..5052cdabaf3 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ContextPermission.java @@ -0,0 +1,5 @@ +package com.appsmith.server.solutions; + +import com.appsmith.server.solutions.ce.ContextPermissionCE; + +public interface ContextPermission extends ContextPermissionCE {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ContextPermissionCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ContextPermissionCE.java new file mode 100644 index 00000000000..8539e405389 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ContextPermissionCE.java @@ -0,0 +1,14 @@ +package com.appsmith.server.solutions.ce; + +import com.appsmith.server.acl.AclPermission; + +public interface ContextPermissionCE { + + AclPermission getDeletePermission(); + + AclPermission getEditPermission(); + + default AclPermission getActionCreatePermission() { + return null; + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PagePermissionCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PagePermissionCE.java index ddf409abae4..bbc573e589c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PagePermissionCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/PagePermissionCE.java @@ -1,9 +1,5 @@ package com.appsmith.server.solutions.ce; -import com.appsmith.server.acl.AclPermission; +import com.appsmith.server.solutions.ContextPermission; -public interface PagePermissionCE { - AclPermission getDeletePermission(); - - AclPermission getActionCreatePermission(); -} +public interface PagePermissionCE extends ContextPermission {} diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderTest.java index 3bf73e03f7c..7f3a8ab8184 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/ce/ImportArtifactPermissionProviderTest.java @@ -9,6 +9,7 @@ import com.appsmith.server.domains.NewAction; import com.appsmith.server.domains.NewPage; import com.appsmith.server.domains.Workspace; +import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import com.appsmith.server.solutions.ActionPermission; import com.appsmith.server.solutions.ApplicationPermission; import com.appsmith.server.solutions.DatasourcePermission; @@ -140,7 +141,7 @@ public void tesBuilderIsSettingTheCorrectParametersToPermissionProvider() { assertTrue(builder.permissionRequiredToCreateAction(true).build().isPermissionRequiredToCreateAction()); assertTrue(builder.permissionRequiredToEditDatasource(true).build().isPermissionRequiredToEditDatasource()); - assertTrue(builder.permissionRequiredToEditPage(true).build().isPermissionRequiredToEditPage()); + assertTrue(builder.permissionRequiredToEditContext(true).build().isPermissionRequiredToEditContext()); assertTrue(builder.permissionRequiredToEditAction(true).build().isPermissionRequiredToEditAction()); } @@ -159,7 +160,7 @@ public void testAllPermissionsRequiredIsSettingAllPermissionsAsRequired() { assertTrue(provider.isPermissionRequiredToCreatePage()); assertTrue(provider.isPermissionRequiredToCreateAction()); assertTrue(provider.isPermissionRequiredToEditDatasource()); - assertTrue(provider.isPermissionRequiredToEditPage()); + assertTrue(provider.isPermissionRequiredToEditContext()); assertTrue(provider.isPermissionRequiredToEditAction()); } @@ -188,7 +189,7 @@ private ImportArtifactPermissionProvider createPermissionProviderForDomainEditPe .currentUserPermissionGroups(Set.of()); if (baseDomain instanceof NewPage) { - builder.permissionRequiredToEditPage(true); + builder.permissionRequiredToEditContext(true); } else if (baseDomain instanceof NewAction) { builder.permissionRequiredToEditAction(true); } else if (baseDomain instanceof Datasource) { From 5c879230fc8b60f92903d843e9ad998cf65bc1da Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Thu, 15 Feb 2024 10:25:24 +0530 Subject: [PATCH 05/11] chore: Fluent API for update methods (#31104) --- .../ce/BaseAppsmithRepositoryCEImpl.java | 63 +++++++------------ ...ustomActionCollectionRepositoryCEImpl.java | 4 +- .../ce/CustomApplicationRepositoryCEImpl.java | 14 +++-- .../ce/CustomNewActionRepositoryCEImpl.java | 15 ++--- .../ce/CustomThemeRepositoryCEImpl.java | 3 +- .../ce/params/QueryAllParams.java | 21 +++++++ 6 files changed, 63 insertions(+), 57 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java index 5af50599666..b0c3881e19c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java @@ -17,6 +17,7 @@ import com.mongodb.client.result.UpdateResult; import com.querydsl.core.types.Path; import jakarta.validation.constraints.NotNull; +import lombok.NonNull; import org.bson.Document; import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; @@ -39,6 +40,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -236,46 +238,6 @@ public Mono updateFieldByDefaultIdAndBranchName( }); } - public Mono updateById(String id, Update updateObj, AclPermission permission) { - if (id == null) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ID)); - } - if (updateObj == null) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ID)); - } - return updateById(id, updateObj, Optional.ofNullable(permission)); - } - - public Mono updateById(String id, Update updateObj, Optional permission) { - Query query = new Query(Criteria.where("id").is(id)); - - if (permission.isEmpty()) { - return mongoOperations.updateFirst(query, updateObj, this.genericDomain); - } - - return getCurrentUserPermissionGroupsIfRequired(permission, true).flatMap(permissionGroups -> { - query.addCriteria(new Criteria().andOperator(notDeleted(), userAcl(permissionGroups, permission.get()))); - return mongoOperations.updateFirst(query, updateObj, this.genericDomain); - }); - } - - public Mono updateByCriteria( - List criteriaList, UpdateDefinition updateObj, AclPermission permission) { - if (criteriaList == null) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "criteriaList")); - } - if (updateObj == null) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "updateObj")); - } - Mono> permissionGroupsMono = - getCurrentUserPermissionGroupsIfRequired(Optional.ofNullable(permission), true); - - return permissionGroupsMono.flatMap(permissionGroups -> { - Query queryWithPermission = createQueryWithPermission(criteriaList, permissionGroups, permission); - return mongoOperations.updateMulti(queryWithPermission, updateObj, this.genericDomain); - }); - } - protected Mono> getCurrentUserPermissionGroupsIfRequired(Optional permission) { return getCurrentUserPermissionGroupsIfRequired(permission, true); } @@ -382,6 +344,27 @@ public Mono countExecute(QueryAllParams params) { this.genericDomain)); } + public Mono updateAllExecute(@NonNull QueryAllParams params, @NonNull UpdateDefinition update) { + Objects.requireNonNull(params.getCriteria()); + + if (!isEmpty(params.getFields())) { + // Specifying fields to update doesn't make any sense, so explicitly disallow it. + return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "fields")); + } + + return tryGetPermissionGroups(params).flatMap(permissionGroups -> { + final Query query = + createQueryWithPermission(params.getCriteria(), null, permissionGroups, params.getPermission()); + if (QueryAllParams.Scope.ALL.equals(params.getScope())) { + return mongoOperations.updateMulti(query, update, genericDomain); + } else if (QueryAllParams.Scope.FIRST.equals(params.getScope())) { + return mongoOperations.updateFirst(query, update, genericDomain); + } else { + return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "scope")); + } + }); + } + private Mono> tryGetPermissionGroups(QueryAllParams params) { return Mono.justOrEmpty(params.getPermissionGroups()) .switchIfEmpty(Mono.defer(() -> getCurrentUserPermissionGroupsIfRequired( diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java index 249705a3de7..9879191d39a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java @@ -272,7 +272,7 @@ public Flux findAllUnpublishedActionCollectionsByContextIdAndC where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); return queryBuilder() .criteria(contextIdAndContextTypeCriteria) - .permission(Optional.ofNullable(permission).orElse(null)) + .permission(permission) .all(); } @@ -287,7 +287,7 @@ public Flux findAllPublishedActionCollectionsByContextIdAndCon where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); return queryBuilder() .criteria(contextIdAndContextTypeCriteria) - .permission(Optional.ofNullable(permission).orElse(null)) + .permission(permission) .all(); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java index 03e68eb6280..999bf9f3115 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java @@ -179,7 +179,7 @@ public Mono setGitAuth(String applicationId, GitAuth gitAuth, AclP fieldName(QApplication.application.gitApplicationMetadata.gitAuth)); updateObj.set(path, gitAuth); - return this.updateById(applicationId, updateObj, aclPermission); + return queryBuilder().byId(applicationId).permission(aclPermission).updateFirst(updateObj); } @Override @@ -304,7 +304,7 @@ public Mono setAppTheme( updateObj = updateObj.set(fieldName(QApplication.application.publishedModeThemeId), publishedModeThemeId); } - return this.updateById(applicationId, updateObj, aclPermission); + return queryBuilder().byId(applicationId).permission(aclPermission).updateFirst(updateObj); } @Override @@ -379,7 +379,10 @@ public Mono unprotectAllBranches(String applicationId, AclPermissi Update unsetProtected = new Update().set(isProtectedFieldPath, false); - return updateByCriteria(List.of(defaultApplicationIdCriteria), unsetProtected, permission); + return queryBuilder() + .criteria(defaultApplicationIdCriteria) + .permission(permission) + .updateAll(unsetProtected); } /** @@ -404,6 +407,9 @@ public Mono protectBranchedApplications( Criteria branchMatchCriteria = Criteria.where(branchNameFieldPath).in(branchNames); Update setProtected = new Update().set(isProtectedFieldPath, true); - return updateByCriteria(List.of(defaultApplicationIdCriteria, branchMatchCriteria), setProtected, permission); + return queryBuilder() + .criteria(defaultApplicationIdCriteria, branchMatchCriteria) + .permission(permission) + .updateAll(setProtected); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java index 20947d4b65a..3ebbb685cb6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java @@ -624,7 +624,10 @@ public Mono archiveDeletedUnpublishedActions(String applicationId, Update update = new Update(); update.set(FieldName.DELETED, true); update.set(FieldName.DELETED_AT, Instant.now()); - return updateByCriteria(List.of(applicationIdCriteria, deletedFromUnpublishedCriteria), update, permission); + return queryBuilder() + .criteria(applicationIdCriteria, deletedFromUnpublishedCriteria) + .permission(permission) + .updateAll(update); } @Override @@ -672,10 +675,7 @@ public Flux findAllUnpublishedActionsByContextIdAndContextType( criteriaList.add(jsInclusionOrExclusionCriteria); } - return queryBuilder() - .criteria(criteriaList) - .permission(Optional.ofNullable(permission).orElse(null)) - .all(); + return queryBuilder().criteria(criteriaList).permission(permission).all(); } @Override @@ -700,9 +700,6 @@ public Flux findAllPublishedActionsByContextIdAndContextType( criteriaList.add(jsInclusionOrExclusionCriteria); - return queryBuilder() - .criteria(criteriaList) - .permission(Optional.ofNullable(permission).orElse(null)) - .all(); + return queryBuilder().criteria(criteriaList).permission(permission).all(); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomThemeRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomThemeRepositoryCEImpl.java index 3173f012870..4dadb94d2c7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomThemeRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomThemeRepositoryCEImpl.java @@ -17,7 +17,6 @@ import reactor.core.publisher.Mono; import java.time.Instant; -import java.util.List; import java.util.regex.Pattern; import static org.springframework.data.mongodb.core.query.Criteria.where; @@ -75,7 +74,7 @@ private Mono archiveThemeByCriteria(Criteria criteria) { Update update = new Update(); update.set(fieldName(QTheme.theme.deletedAt), Instant.now()); - return updateByCriteria(List.of(criteria, permissionCriteria), update, null); + return queryBuilder().criteria(criteria, permissionCriteria).updateAll(update); }) .map(updateResult -> updateResult.getModifiedCount() > 0); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java index 3706c2abd26..f22c27a8864 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java @@ -4,9 +4,12 @@ import com.appsmith.server.acl.AclPermission; import com.appsmith.server.constants.FieldName; import com.appsmith.server.repositories.ce.BaseAppsmithRepositoryCEImpl; +import com.mongodb.client.result.UpdateResult; import lombok.Getter; +import lombok.NonNull; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.UpdateDefinition; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -36,6 +39,8 @@ public class QueryAllParams { */ private boolean includeAnonymousUserPermissions = true; + private Scope scope; + public QueryAllParams(BaseAppsmithRepositoryCEImpl repo) { this.repo = repo; } @@ -56,6 +61,16 @@ public Mono count() { return repo.countExecute(this); } + public Mono updateAll(@NonNull UpdateDefinition update) { + scope = Scope.ALL; + return repo.updateAllExecute(this, update); + } + + public Mono updateFirst(@NonNull UpdateDefinition update) { + scope = Scope.FIRST; + return repo.updateAllExecute(this, update); + } + public QueryAllParams criteria(Criteria... criteria) { if (criteria == null) { return this; @@ -117,4 +132,10 @@ public QueryAllParams includeAnonymousUserPermissions(boolean value) { includeAnonymousUserPermissions = value; return this; } + + public enum Scope { + ALL, + FIRST, + ONE, + } } From f7d41891b8b14ae2cb5c93468e29abf611e2dbf8 Mon Sep 17 00:00:00 2001 From: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:00:57 +0530 Subject: [PATCH 06/11] fix: Anvil toggleable widgets not working when native callbacks are used for AnvilFlexComponent (#31125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description In last weeks effort of cleaning up Editor and Viewer parts of AnvilFlexComponent I had changed synthetic React callbacks to native ones #30780 . This has resulted in regression of widget toggling of widgets like Checkbox, Switch, etc. so changing them back to synthetic events by passing callbacks and props to the viewer part of AnvilFlexComponent. #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **New Features** - Introduced a new testing suite for validating widget interactions in Anvil Layout Mode, focusing on switch and checkbox widgets. - Added new functionalities for switch and checkbox widgets, including selection toggling and state verification. - Enhanced Anvil editor components to support custom click behaviors, improving widget interaction in edit mode. - **Bug Fixes** - Addressed issues with native click callbacks interfering with widget events. - **Tests** - Added comprehensive test cases for new widget functionalities and interactions. - **Refactor** - Updated internal logic for widget selection and style adjustments based on interaction states. --- .../Anvil/AnvilWidgetClicking_spec.ts | 75 +++++++++++++++++++ app/client/cypress/locators/WidgetLocators.ts | 2 + .../cypress/support/Objects/ObjectsCore.ts | 1 + .../cypress/support/Objects/Registry.ts | 9 +++ .../cypress/support/Pages/WDSWidgets.ts | 22 ++++++ .../anvil/common/AnvilFlexComponent.tsx | 5 ++ .../anvil/editor/AnvilEditorFlexComponent.tsx | 17 ++++- .../anvil/editor/hooks/useAnvilWidgetClick.ts | 55 ++++++-------- .../editor/hooks/useAnvilWidgetStyles.ts | 14 ++-- .../src/layoutSystems/anvil/utils/types.ts | 2 + 10 files changed, 161 insertions(+), 41 deletions(-) create mode 100644 app/client/cypress/e2e/Regression/ClientSide/Anvil/AnvilWidgetClicking_spec.ts create mode 100644 app/client/cypress/support/Pages/WDSWidgets.ts diff --git a/app/client/cypress/e2e/Regression/ClientSide/Anvil/AnvilWidgetClicking_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Anvil/AnvilWidgetClicking_spec.ts new file mode 100644 index 00000000000..0cccd6ea65d --- /dev/null +++ b/app/client/cypress/e2e/Regression/ClientSide/Anvil/AnvilWidgetClicking_spec.ts @@ -0,0 +1,75 @@ +import { ANVIL_EDITOR_TEST } from "../../../../support/Constants"; +import { + agHelper, + homePage, + assertHelper, + anvilLayout, + locators, + wdsWidgets, +} from "../../../../support/Objects/ObjectsCore"; +import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags"; +import { WIDGET } from "../../../../locators/WidgetLocators"; + +describe( + `${ANVIL_EDITOR_TEST}: validating Widget clicks in Anvil Layout Mode`, + { tags: ["@tag.Anvil"] }, + function () { + before(() => { + // intercept features call for Anvil + WDS tests + featureFlagIntercept({ + release_anvil_enabled: true, + ab_wds_enabled: true, + }); + // Cleanup the canvas before each test + agHelper.SelectAllWidgets(); + agHelper.PressDelete(); + }); + it("1. Click on widget to Select Widget", () => { + anvilLayout.DragDropAnvilWidgetNVerify(WIDGET.WDSSWITCH, 5, 20, { + skipWidgetSearch: true, + }); + anvilLayout.DragDropAnvilWidgetNVerify(WIDGET.WDSSWITCH, 5, 20, { + skipWidgetSearch: true, + dropTargetDetails: { + name: "Zone1", + }, + }); + anvilLayout.DragDropAnvilWidgetNVerify(WIDGET.WDSBUTTON, 5, 20, { + skipWidgetSearch: true, + dropTargetDetails: { + name: "Zone1", + }, + }); + // deselect all widgets + agHelper.PressEscape(); + agHelper.AssertElementLength(locators._selectedWidget, 0); + agHelper.GetNClick(locators._widgetByName("Button1")); + agHelper.AssertElementLength(locators._selectedWidget, 1); + agHelper.GetNClick(locators._widgetByName("Switch1")); + agHelper.AssertElementLength(locators._selectedWidget, 1); + }); + it("2. Click on widgets like Switch, Checkbox to toggle selection", () => { + // deselect all widgets + agHelper.PressEscape(); + agHelper + .GetNClick(wdsWidgets._switchWidgetTargetSelector("Switch1")) + .then(() => { + wdsWidgets.verifySwitchWidgetState("Switch1", "checked"); + }); + agHelper + .GetNClick(wdsWidgets._switchWidgetTargetSelector("Switch1")) + .then(() => { + wdsWidgets.verifySwitchWidgetState("Switch1", "unchecked"); + }); + anvilLayout.DragDropAnvilWidgetNVerify(WIDGET.WDSCHECKBOX, 5, 20, { + skipWidgetSearch: true, + }); + wdsWidgets.verifyCheckboxWidgetState("Checkbox1", "checked"); + agHelper + .GetNClick(wdsWidgets._checkboxWidgetTargetSelector("Checkbox1")) + .then(() => { + wdsWidgets.verifyCheckboxWidgetState("Checkbox1", "unchecked"); + }); + }); + }, +); diff --git a/app/client/cypress/locators/WidgetLocators.ts b/app/client/cypress/locators/WidgetLocators.ts index 2636d9dc1a2..adf589aa367 100644 --- a/app/client/cypress/locators/WidgetLocators.ts +++ b/app/client/cypress/locators/WidgetLocators.ts @@ -8,6 +8,8 @@ export const WIDGET = { WDSBUTTON: "wdsbuttonwidget", WDSTABLE: "wdstablewidget", WDSINPUT: "wdsinputwidget", + WDSSWITCH: "wdsswitchwidget", + WDSCHECKBOX: "wdscheckboxwidget", BUTTONNAME: (index: string) => `Button${index}`, CODESCANNER: "codescannerwidget", CONTAINER: "containerwidget", diff --git a/app/client/cypress/support/Objects/ObjectsCore.ts b/app/client/cypress/support/Objects/ObjectsCore.ts index 29dd82bfcd1..ef5f74a097c 100644 --- a/app/client/cypress/support/Objects/ObjectsCore.ts +++ b/app/client/cypress/support/Objects/ObjectsCore.ts @@ -36,4 +36,5 @@ export const gsheetHelper = ObjectsRegistry.GSheetHelper; export const widgetLocators = WIDGETSKIT; export const communityTemplates = ObjectsRegistry.CommunityTemplates; export const anvilLayout = ObjectsRegistry.AnvilLayout; +export const wdsWidgets = ObjectsRegistry.WDSWidgets; export const partialImportExport = ObjectsRegistry.PartialImportExport; diff --git a/app/client/cypress/support/Objects/Registry.ts b/app/client/cypress/support/Objects/Registry.ts index 5c701fea1eb..57bc9892da6 100644 --- a/app/client/cypress/support/Objects/Registry.ts +++ b/app/client/cypress/support/Objects/Registry.ts @@ -30,6 +30,7 @@ import { GsheetHelper } from "../Pages/GSheetHelper"; import { CommunityTemplates } from "../Pages/CommunityTemplates"; import { AnvilLayout } from "../Pages/AnvilLayout"; import PartialImportExport from "../Pages/PartialImportExport"; +import { WDSWidgets } from "../Pages/WDSWidgets"; export class ObjectsRegistry { private static aggregateHelper__: AggregateHelper; @@ -256,6 +257,14 @@ export class ObjectsRegistry { return ObjectsRegistry.anvilLayout__; } + private static wdsWidgets__: WDSWidgets; + static get WDSWidgets(): WDSWidgets { + if (ObjectsRegistry.wdsWidgets__ === undefined) { + ObjectsRegistry.wdsWidgets__ = new WDSWidgets(); + } + return ObjectsRegistry.wdsWidgets__; + } + private static dataManager__: DataManager; static get DataManager(): DataManager { if (ObjectsRegistry.dataManager__ === undefined) { diff --git a/app/client/cypress/support/Pages/WDSWidgets.ts b/app/client/cypress/support/Pages/WDSWidgets.ts new file mode 100644 index 00000000000..845e058065f --- /dev/null +++ b/app/client/cypress/support/Pages/WDSWidgets.ts @@ -0,0 +1,22 @@ +import { ObjectsRegistry } from "../Objects/Registry"; + +export class WDSWidgets { + private locator = ObjectsRegistry.CommonLocators; + + public _switchWidgetTargetSelector = (name: string) => + `${this.locator._widgetByName(name)} label`; + public _checkboxWidgetTargetSelector = this._switchWidgetTargetSelector; + + public verifySwitchWidgetState = ( + name: string, + expectedState: "checked" | "unchecked", + ) => { + const switchLabelSelector = `${this.locator._widgetByName(name)} label`; + cy.get(switchLabelSelector).should( + "have.attr", + "data-state", + expectedState, + ); + }; + public verifyCheckboxWidgetState = this.verifySwitchWidgetState; +} diff --git a/app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx b/app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx index d37ef8fd9f9..e62650358e0 100644 --- a/app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx +++ b/app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx @@ -12,6 +12,7 @@ import type { WidgetProps } from "widgets/BaseWidget"; import type { WidgetConfigProps } from "WidgetProvider/constants"; import { getAnvilWidgetDOMId } from "layoutSystems/common/utils/LayoutElementPositionsObserver/utils"; import { Layers } from "constants/Layers"; +import { noop } from "utils/AppsmithUtils"; const anvilWidgetStyleProps: CSSProperties = { position: "relative", @@ -38,6 +39,8 @@ export const AnvilFlexComponent = forwardRef( children, className, flexGrow, + onClick = noop, + onClickCapture = noop, widgetId, widgetSize, widgetType, @@ -82,6 +85,8 @@ export const AnvilFlexComponent = forwardRef( {...flexProps} className={className} id={getAnvilWidgetDOMId(widgetId)} + onClick={onClick} + onClickCapture={onClickCapture} ref={ref} style={anvilWidgetStyleProps} > diff --git a/app/client/src/layoutSystems/anvil/editor/AnvilEditorFlexComponent.tsx b/app/client/src/layoutSystems/anvil/editor/AnvilEditorFlexComponent.tsx index 076f2b10701..32e4f709808 100644 --- a/app/client/src/layoutSystems/anvil/editor/AnvilEditorFlexComponent.tsx +++ b/app/client/src/layoutSystems/anvil/editor/AnvilEditorFlexComponent.tsx @@ -41,10 +41,23 @@ export const AnvilEditorFlexComponent = (props: AnvilFlexComponentProps) => { // Use custom hooks to manage styles, click, drag, and hover behavior exclusive for Edit mode useAnvilWidgetStyles(props.widgetId, props.widgetName, props.isVisible, ref); - useAnvilWidgetClick(props.widgetId, ref); useAnvilWidgetDrag(props.widgetId, props.layoutId, ref); useAnvilWidgetHover(props.widgetId, ref); + // Note: For some reason native click callback listeners are somehow hindering with events required for toggle-able widgets like checkbox, switch, etc. + // Hence supplying click and click capture callbacks to the AnvilFlexComponent + const { onClickCaptureFn, onClickFn } = useAnvilWidgetClick( + props.widgetId, + ref, + ); // Render the AnvilFlexComponent - return ; + return ( + + ); }; diff --git a/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetClick.ts b/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetClick.ts index 1ce9b134a25..dd65ad11803 100644 --- a/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetClick.ts +++ b/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetClick.ts @@ -1,8 +1,11 @@ import { SELECT_ANVIL_WIDGET_CUSTOM_EVENT } from "layoutSystems/anvil/utils/constants"; -import { useCallback, useEffect } from "react"; +import { useCallback, useEffect, useRef } from "react"; import { useSelector } from "react-redux"; import { snipingModeSelector } from "selectors/editorSelectors"; -import { isCurrentWidgetFocused } from "selectors/widgetSelectors"; +import { + isCurrentWidgetFocused, + isWidgetSelected, +} from "selectors/widgetSelectors"; export const useAnvilWidgetClick = ( widgetId: string, @@ -10,19 +13,26 @@ export const useAnvilWidgetClick = ( ) => { // Retrieve state from the Redux store const isFocused = useSelector(isCurrentWidgetFocused(widgetId)); + const isSelected = useSelector(isWidgetSelected(widgetId)); const isSnipingMode = useSelector(snipingModeSelector); - + const allowSelectionRef = useRef(false); + useEffect(() => { + allowSelectionRef.current = isFocused && !isSelected; + }, [isFocused, isSelected]); // Function to stop event propagation if not in sniping mode // Note: Sniping mode is irrelevant to the Anvil however it becomes relevant if we decide to make Anvil the default editor - const stopEventPropagation = (e: MouseEvent) => { - !isSnipingMode && e.stopPropagation(); - }; + const onClickFn = useCallback( + (e: MouseEvent) => { + !isSnipingMode && e.stopPropagation(); + }, + [isSnipingMode], + ); // Callback function for handling click events on AnvilFlexComponent in Edit mode - const onClickFn = useCallback( + const onClickCaptureFn = useCallback( function () { // Dispatch a custom event when the Anvil widget is clicked and focused - if (ref.current && isFocused) { + if (ref.current && allowSelectionRef.current) { ref.current.dispatchEvent( new CustomEvent(SELECT_ANVIL_WIDGET_CUSTOM_EVENT, { bubbles: true, @@ -32,29 +42,10 @@ export const useAnvilWidgetClick = ( ); } }, - [widgetId, isFocused], + [widgetId], ); - - // Effect hook to add and remove click event listeners - useEffect(() => { - if (ref.current) { - // Add click event listener to select the Anvil widget - ref.current.addEventListener("click", onClickFn, { capture: true }); - - // Add click event listener to stop event propagation in certain modes - ref.current.addEventListener("click", stopEventPropagation, { - capture: false, - }); - } - - // Clean up event listeners when the component unmounts - return () => { - if (ref.current) { - ref.current.removeEventListener("click", onClickFn, { capture: true }); - ref.current.removeEventListener("click", stopEventPropagation, { - capture: false, - }); - } - }; - }, [onClickFn, stopEventPropagation]); + return { + onClickFn, + onClickCaptureFn, + }; }; diff --git a/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetStyles.ts b/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetStyles.ts index aaa860bc8f5..102d33bd6b1 100644 --- a/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetStyles.ts +++ b/app/client/src/layoutSystems/anvil/editor/hooks/useAnvilWidgetStyles.ts @@ -10,6 +10,11 @@ export const useAnvilWidgetStyles = ( isVisible = true, ref: React.RefObject, // Ref object to reference the AnvilFlexComponent ) => { + // Selectors to determine whether the widget is selected or dragging + const isSelected = useSelector(isWidgetSelected(widgetId)); + const isDragging = useSelector( + (state: AppState) => state.ui.widgetDragResize.isDragging, + ); // Get widget border styles using useWidgetBorderStyles const widgetBorderStyles = useWidgetBorderStyles(widgetId); @@ -27,14 +32,9 @@ export const useAnvilWidgetStyles = ( useEffect(() => { if (ref.current) { ref.current.setAttribute("data-widgetname-cy", widgetName); + ref.current.setAttribute("data-testid", isSelected ? "t--selected" : ""); } - }, [widgetName]); - - // Selectors to determine whether the widget is selected or dragging - const isSelected = useSelector(isWidgetSelected(widgetId)); - const isDragging = useSelector( - (state: AppState) => state.ui.widgetDragResize.isDragging, - ); + }, [widgetName, isSelected]); // Calculate whether the widget should fade based on dragging, selection, and visibility const shouldFadeWidget = (isDragging && isSelected) || !isVisible; diff --git a/app/client/src/layoutSystems/anvil/utils/types.ts b/app/client/src/layoutSystems/anvil/utils/types.ts index 18b4604dfa6..913120c9793 100644 --- a/app/client/src/layoutSystems/anvil/utils/types.ts +++ b/app/client/src/layoutSystems/anvil/utils/types.ts @@ -17,6 +17,8 @@ export interface AnvilFlexComponentProps { widgetName: string; widgetSize?: SizeConfig; widgetType: WidgetType; + onClick?: (e: any) => void; + onClickCapture?: () => void; } export type PositionValues = From 96ba97a1b27735d41e1168cfae9dcad6a0f8e0b3 Mon Sep 17 00:00:00 2001 From: Nilansh Bansal Date: Thu, 15 Feb 2024 11:36:34 +0530 Subject: [PATCH 07/11] fix: added escaping logic for html reserved characters (#31133) ## Description > This PR adds escaping logic for HTML reserved characters `"` and `"`. Both of these characters were getting unescaped to double quotes (") leading to a JSON parse error. > I have updated the code to escape these with a backslash before getting converted. [ref](https://theappsmith.slack.com/archives/C0341RERY4R/p1707900321201109?thread_ts=1707510761.277959&cid=C0341RERY4R) #### PR fixes following issue(s) Fixes #31056 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **New Features** - Enhanced data handling to ensure JSON validity by escaping double quotes in certain outputs. - **Tests** - Added test cases to verify the new escaping logic for JSON and HTML characters. --- .../external/helpers/MustacheHelper.java | 9 ++++-- .../external/helpers/MustacheHelperTest.java | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java index 211ad7b6ac6..3564e48ea14 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java @@ -353,8 +353,13 @@ public static String render(String template, Map keyValueMap) { rendered.append(token.getValue()); } } - - return StringEscapeUtils.unescapeHtml4(rendered.toString()); + /** + * ReplaceAll is used to escape the double quotes symbol with \" so that + * JSON remains valid. + * " and " both are HTML reserved characters for double quotes (") + */ + return StringEscapeUtils.unescapeHtml4( + rendered.toString().replaceAll(""", "\\\\"").replaceAll(""", "\\\\"")); } /** diff --git a/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/helpers/MustacheHelperTest.java b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/helpers/MustacheHelperTest.java index 04c62cfb561..1ffb047185e 100644 --- a/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/helpers/MustacheHelperTest.java +++ b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/helpers/MustacheHelperTest.java @@ -591,4 +591,32 @@ public void whenBindingFoundWithoutValue_doNotReplaceWithNull() { Map.of("severity", "CRITICAL VALUE")); assertThat(rendered).isEqualTo("HL7 Result: CODE 5 - CRITICAL VALUE - {{institution}} {{accessionNumber}}"); } + + /** + * This test case checks for the escaping logic for double quotes (") to (\") + * so that the JSON remains valid. + * " and " both are HTML reserved characters for double quotes (") + */ + @Test + public void render_WhenValueContainsHtmlDoubleQuotes_ReturnsEscapedCharacter() { + final String rendered = render( + "Testing html double quotes {{doubleQuotes}} with {{doubleQuotesEntityNumber}}", + Map.of( + "doubleQuotes", """, + "doubleQuotesEntityNumber", """)); + assertThat(rendered).isEqualTo("Testing html double quotes \\\" with \\\""); + } + + /** + * This test case validates the unescaping of HTML characters to string + */ + @Test + public void render_WhenValueContainsHtmlReservedCharacters_ReturnsEscapedCharacters() { + final String rendered = render( + "Testing html lt {{ltSymbol}} and gt {{gtSymbol}} symbols", + Map.of( + "ltSymbol", "<", + "gtSymbol", ">")); + assertThat(rendered).isEqualTo("Testing html lt < and gt > symbols"); + } } From 596f84934c2db03d8037c8c8ed9cbf8fa3c053bd Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Thu, 15 Feb 2024 11:47:56 +0530 Subject: [PATCH 08/11] fix: Debugger shows up with no tab selected (#31126) fixes: #31124 Updates the debugger showing logic for Schema tab ## Summary by CodeRabbit - **Bug Fixes** - Updated the debugger to not render certain tabs (response, header, or schema) when selected in the bottom bar, enhancing the interface's usability. --- .../components/editorComponents/Debugger/DebuggerTabs.tsx | 5 +++-- app/client/src/pages/Editor/DataSourceEditor/Debugger.tsx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/client/src/components/editorComponents/Debugger/DebuggerTabs.tsx b/app/client/src/components/editorComponents/Debugger/DebuggerTabs.tsx index 1d29e5fe34d..6ecf5f9fb0c 100644 --- a/app/client/src/components/editorComponents/Debugger/DebuggerTabs.tsx +++ b/app/client/src/components/editorComponents/Debugger/DebuggerTabs.tsx @@ -99,10 +99,11 @@ function DebuggerTabs() { }, ]; - // Do not render if response tab and header tab is selected in the bottom bar. + // Do not render if response, header or schema tab is selected in the bottom bar. const shouldRender = !( selectedTab === DEBUGGER_TAB_KEYS.RESPONSE_TAB || - selectedTab === DEBUGGER_TAB_KEYS.HEADER_TAB + selectedTab === DEBUGGER_TAB_KEYS.HEADER_TAB || + selectedTab === DEBUGGER_TAB_KEYS.SCHEMA_TAB ); return shouldRender ? ( diff --git a/app/client/src/pages/Editor/DataSourceEditor/Debugger.tsx b/app/client/src/pages/Editor/DataSourceEditor/Debugger.tsx index 14c5df524bf..f19ef75391d 100644 --- a/app/client/src/pages/Editor/DataSourceEditor/Debugger.tsx +++ b/app/client/src/pages/Editor/DataSourceEditor/Debugger.tsx @@ -147,10 +147,11 @@ export default function Debugger() { //TODO: move this to a common place const onClose = () => dispatch(showDebugger(false)); - // Do not render if response tab and header tab is selected in the bottom bar. + // Do not render if response, header or schema tab is selected in the bottom bar. const shouldRender = !( selectedResponseTab === DEBUGGER_TAB_KEYS.RESPONSE_TAB || - selectedResponseTab === DEBUGGER_TAB_KEYS.HEADER_TAB + selectedResponseTab === DEBUGGER_TAB_KEYS.HEADER_TAB || + selectedResponseTab === DEBUGGER_TAB_KEYS.SCHEMA_TAB ); return shouldRender ? ( From 275c7f5394d238dbe41bbbf220f678afea8b10e4 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Thu, 15 Feb 2024 11:51:25 +0530 Subject: [PATCH 09/11] test: Fix Graphql test for Datasource list check (#31120) ## Description Test Fix Removes the reference of right pane Datasource List for Apis and Graphql and uses the input url instead ## Summary by CodeRabbit - **Refactor** - Improved the naming and selection process in the Data Sources management for enhanced usability. - Updated functionality related to intercepting a POST request for improved reliability. --- app/client/cypress/support/Pages/DataSources.ts | 8 +++++--- app/client/cypress/support/commands.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/client/cypress/support/Pages/DataSources.ts b/app/client/cypress/support/Pages/DataSources.ts index 47e909fc3be..4aa9cd58fda 100644 --- a/app/client/cypress/support/Pages/DataSources.ts +++ b/app/client/cypress/support/Pages/DataSources.ts @@ -290,7 +290,7 @@ export class DataSources { _entityExplorerID = (dsName: string) => "[data-testid='t--entity-item-" + dsName + "']"; _stagingTab = "[data-testid='t--ds-data-filter-Staging']"; - _graphQlDsFromRightPane = (dsName: string) => + _graphQlDsHintOption = (dsName: string) => "//div/span[text() ='" + dsName + "']"; _imgFireStoreLogo = "//img[contains(@src, 'firestore.svg')]"; _dsVirtuosoElement = `div .t--schema-virtuoso-container`; @@ -743,8 +743,10 @@ export class DataSources { this.apiPage.EnterURL( this.dataManager.dsValues[environment].GraphqlApiUrl_TED, ); - else if (enterOrSelectUrl == "select") - this.agHelper.GetNClick(this._graphQlDsFromRightPane(dsNameToSelect)); + else if (enterOrSelectUrl == "select") { + this.agHelper.GetNClick(this.apiPage._resourceUrl); + this.agHelper.GetNClick(this._graphQlDsHintOption(dsNameToSelect)); + } this.assertHelper.AssertNetworkStatus("@createNewApi", 201); cy.wrap("GraphQL_API" + "_" + uid).as("dsName"); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index ea4e572f22c..ecb5893331c 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -957,7 +957,7 @@ Cypress.Commands.add("startServerAndRoutes", () => { cy.intercept("PUT", "/api/v1/actions/executeOnLoad/*").as("setExecuteOnLoad"); cy.intercept("POST", "/api/v1/actions").as("createNewApi"); - cy.intercept("POST", "/api/v1/import?type=CURL&pageId=*&name=*").as( + cy.intercept("POST", "/api/v1/import?type=CURL&contextId=*&name=*").as( "curlImport", ); cy.intercept("DELETE", "/api/v1/actions/*").as("deleteAction"); From 1278287609d78b1564899afb0819f7ff83ca8db7 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Thu, 15 Feb 2024 13:37:25 +0530 Subject: [PATCH 10/11] chore: Remove `mongoOperations` in two more methods (#31136) It's doing exactly the same thing, but with a lot of the code duplicated. --- .../ce/BaseAppsmithRepositoryCEImpl.java | 60 +++++-------------- .../ce/CustomApplicationRepositoryCEImpl.java | 15 +---- 2 files changed, 15 insertions(+), 60 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java index b0c3881e19c..436ab80e681 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java @@ -22,7 +22,6 @@ import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.GenericTypeResolver; -import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.ReactiveMongoOperations; import org.springframework.data.mongodb.core.convert.MongoConverter; @@ -216,26 +215,18 @@ public Mono updateFieldByDefaultIdAndBranchName( String branchName, String branchNamePath, AclPermission permission) { - return ReactiveSecurityContextHolder.getContext() - .map(ctx -> ctx.getAuthentication()) - .map(auth -> auth.getPrincipal()) - .flatMap(principal -> getAllPermissionGroupsForUser((User) principal)) - .flatMap(permissionGroups -> { - Query query = - new Query(new Criteria().andOperator(notDeleted(), userAcl(permissionGroups, permission))); - query.addCriteria(Criteria.where(defaultIdPath).is(defaultId)); - - if (!isBlank(branchName)) { - query.addCriteria(Criteria.where(branchNamePath).is(branchName)); - } - - Update update = new Update(); - fieldNameValueMap.forEach((fieldName, fieldValue) -> { - update.set(fieldName, fieldValue); - }); - - return mongoOperations.updateFirst(query, update, this.genericDomain); - }); + final QueryAllParams builder = queryBuilder(); + + builder.criteria(Criteria.where(defaultIdPath).is(defaultId)); + + if (!isBlank(branchName)) { + builder.criteria(Criteria.where(branchNamePath).is(branchName)); + } + + Update update = new Update(); + fieldNameValueMap.forEach(update::set); + + return builder.permission(permission).updateFirst(update); } protected Mono> getCurrentUserPermissionGroupsIfRequired(Optional permission) { @@ -458,31 +449,8 @@ protected Mono> getAnonymousUserPermissionGroups() { Db query methods */ - public Flux queryAllWithoutPermissions( - List criterias, List includeFields, Sort sort, int limit) { - final ArrayList criteriaList = new ArrayList<>(criterias); - Query query = new Query(); - if (!CollectionUtils.isEmpty(includeFields)) { - for (String includeField : includeFields) { - query.fields().include(includeField); - } - } - - if (limit != NO_RECORD_LIMIT) { - query.limit(limit); - } - Criteria andCriteria = new Criteria(); - - criteriaList.add(notDeleted()); - - andCriteria.andOperator(criteriaList.toArray(new Criteria[0])); - - query.addCriteria(andCriteria); - if (sort != null) { - query.with(sort); - } - - return mongoOperations.query(this.genericDomain).matching(query).all().map(obj -> obj); + public Flux queryAllWithoutPermissions(List criterias, List includeFields) { + return queryBuilder().criteria(criterias).fields(includeFields).all(); } /** diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java index 999bf9f3115..94eb7f7aa2f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomApplicationRepositoryCEImpl.java @@ -28,7 +28,6 @@ import java.time.Instant; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; @@ -307,18 +306,6 @@ public Mono setAppTheme( return queryBuilder().byId(applicationId).permission(aclPermission).updateFirst(updateObj); } - @Override - public Mono updateFieldByDefaultIdAndBranchName( - String defaultId, - String defaultIdPath, - Map fieldValueMap, - String branchName, - String branchNamePath, - AclPermission permission) { - return super.updateFieldByDefaultIdAndBranchName( - defaultId, defaultIdPath, fieldValueMap, branchName, branchNamePath, permission); - } - @Override public Mono countByNameAndWorkspaceId(String applicationName, String workspaceId, AclPermission permission) { Criteria workspaceIdCriteria = @@ -347,7 +334,7 @@ public Flux getAllApplicationIdsInWorkspaceAccessibleToARoleWithPermissi ArrayList criteria = new ArrayList<>(List.of(workspaceIdCriteria, permissionGroupCriteria, notDeleted())); - return queryAllWithoutPermissions(criteria, List.of(fieldName(QApplication.application.id)), null, -1) + return queryAllWithoutPermissions(criteria, List.of(fieldName(QApplication.application.id))) .map(application -> application.getId()); } From d35006989ada682deb9bf03fbcbfd02fc88bf82d Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 15 Feb 2024 14:18:27 +0530 Subject: [PATCH 11/11] chore: Removing Paragraph from suggested widget and add Button to suggested widgets (#31143) Fixes #30902 ## Summary by CodeRabbit - **New Features** - Enhanced feature flag checks for "ab_wds_enabled" and "release_anvil_enabled" to prioritize these flags. - Updated the categorization of certain widgets to include them under "Suggested Widgets" for better visibility and organization. - **Refactor** - Improved the handling of feature flags to ensure more reliable feature toggling. - Optimized widget tagging system for `WDSButtonWidget`, `WDSHeadingWidget`, and `WDSParagraphWidget` to enhance widget discoverability and categorization. --------- Co-authored-by: Pawan Kumar --- app/client/src/widgets/wds/WDSButtonWidget/widget/index.tsx | 2 +- app/client/src/widgets/wds/WDSHeadingWidget/widget/index.tsx | 2 ++ .../src/widgets/wds/WDSParagraphWidget/config/metaConfig.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/client/src/widgets/wds/WDSButtonWidget/widget/index.tsx b/app/client/src/widgets/wds/WDSButtonWidget/widget/index.tsx index 7ccb5003fbe..6f4b106d152 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/widget/index.tsx +++ b/app/client/src/widgets/wds/WDSButtonWidget/widget/index.tsx @@ -38,7 +38,7 @@ class WDSButtonWidget extends BaseWidget { iconSVG: IconSVG, needsMeta: false, isCanvas: false, - tags: [WIDGET_TAGS.BUTTONS], + tags: [WIDGET_TAGS.SUGGESTED_WIDGETS, WIDGET_TAGS.BUTTONS], searchTags: ["click", "submit"], }; } diff --git a/app/client/src/widgets/wds/WDSHeadingWidget/widget/index.tsx b/app/client/src/widgets/wds/WDSHeadingWidget/widget/index.tsx index 08135b6269b..3ff841d9fbb 100644 --- a/app/client/src/widgets/wds/WDSHeadingWidget/widget/index.tsx +++ b/app/client/src/widgets/wds/WDSHeadingWidget/widget/index.tsx @@ -1,3 +1,4 @@ +import { WIDGET_TAGS } from "constants/WidgetConstants"; import { WDSParagraphWidget } from "widgets/wds/WDSParagraphWidget"; class WDSHeadingWidget extends WDSParagraphWidget { @@ -6,6 +7,7 @@ class WDSHeadingWidget extends WDSParagraphWidget { static getConfig() { return { ...super.getConfig(), + tags: [WIDGET_TAGS.SUGGESTED_WIDGETS, WIDGET_TAGS.CONTENT], name: "Heading", }; } diff --git a/app/client/src/widgets/wds/WDSParagraphWidget/config/metaConfig.ts b/app/client/src/widgets/wds/WDSParagraphWidget/config/metaConfig.ts index a87580e0393..ae98ebaa64a 100644 --- a/app/client/src/widgets/wds/WDSParagraphWidget/config/metaConfig.ts +++ b/app/client/src/widgets/wds/WDSParagraphWidget/config/metaConfig.ts @@ -1,9 +1,10 @@ import IconSVG from "../icon.svg"; +import type { WidgetTags } from "constants/WidgetConstants"; import { WIDGET_TAGS } from "constants/WidgetConstants"; export const metaConfig = { name: "Paragraph", iconSVG: IconSVG, - tags: [WIDGET_TAGS.SUGGESTED_WIDGETS, WIDGET_TAGS.CONTENT], + tags: [WIDGET_TAGS.CONTENT] as WidgetTags[], searchTags: ["typography", "paragraph", "label"], };