From 15fda5608436768d925c6245a691ed5086b3d68e Mon Sep 17 00:00:00 2001 From: Druthi Polisetty Date: Tue, 28 Nov 2023 09:07:48 +0530 Subject: [PATCH] feat: workflows editor code split (#28779) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Code split for workflows code editor setup #### PR fixes following issue(s) Fixes [#2873](https://github.com/appsmithorg/appsmith-ee/issues/2873) #### 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 - New feature (non-breaking change which adds functionality) ## 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 --------- Co-authored-by: Ayush Pahwa --- app/client/src/actions/queryPaneActions.ts | 1 + .../src/ce/constants/WorkflowConstants.ts | 17 ++++++++++++++++ .../pages/Applications/WorkflowCardList.tsx | 14 +++++++++++++ .../src/ce/pages/Applications/index.tsx | 11 +++++++++- .../src/ce/selectors/applicationSelectors.tsx | 20 ++++++++++++++++--- .../src/ce/selectors/workflowSelectors.ts | 20 +++++++++++++++++++ .../src/ee/constants/WorkflowConstants.ts | 1 + .../pages/Applications/WorkflowCardList.tsx | 3 +++ .../src/ee/selectors/workflowSelectors.ts | 1 + app/client/src/sagas/EvaluationsSaga.ts | 12 ++++++++++- 10 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 app/client/src/ce/constants/WorkflowConstants.ts create mode 100644 app/client/src/ce/pages/Applications/WorkflowCardList.tsx create mode 100644 app/client/src/ce/selectors/workflowSelectors.ts create mode 100644 app/client/src/ee/constants/WorkflowConstants.ts create mode 100644 app/client/src/ee/pages/Applications/WorkflowCardList.tsx create mode 100644 app/client/src/ee/selectors/workflowSelectors.ts diff --git a/app/client/src/actions/queryPaneActions.ts b/app/client/src/actions/queryPaneActions.ts index 7074964120..55f87e7724 100644 --- a/app/client/src/actions/queryPaneActions.ts +++ b/app/client/src/actions/queryPaneActions.ts @@ -8,6 +8,7 @@ export interface ChangeQueryPayload { applicationId?: string; pageId?: string; moduleId?: string; + workflowId?: string; newQuery?: boolean; action?: Action; } diff --git a/app/client/src/ce/constants/WorkflowConstants.ts b/app/client/src/ce/constants/WorkflowConstants.ts new file mode 100644 index 0000000000..8bce81de0d --- /dev/null +++ b/app/client/src/ce/constants/WorkflowConstants.ts @@ -0,0 +1,17 @@ +type ID = string; + +// Type for the workflow object. +export interface Workflow { + id: ID; + name: string; // Name of the workflow. + icon: string; + color: string; + workspaceId: ID; // ID of the workspace where the workflow is created. + modifiedBy: string; + modifiedAt: string; + userPermissions: string[]; + new: boolean; + slug: string; // Slug of the workflow (Not in use currently). +} + +export type WorkflowMetadata = Workflow; diff --git a/app/client/src/ce/pages/Applications/WorkflowCardList.tsx b/app/client/src/ce/pages/Applications/WorkflowCardList.tsx new file mode 100644 index 0000000000..c4fa3e370e --- /dev/null +++ b/app/client/src/ce/pages/Applications/WorkflowCardList.tsx @@ -0,0 +1,14 @@ +import type { Workflow } from "@appsmith/constants/WorkflowConstants"; + +export interface WorkflowCardListProps { + isMobile: boolean; + workspaceId: string; + workflows?: Workflow[]; +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function WorkflowCardList(props: WorkflowCardListProps) { + return null; +} + +export default WorkflowCardList; diff --git a/app/client/src/ce/pages/Applications/index.tsx b/app/client/src/ce/pages/Applications/index.tsx index d42e3b9f2f..e4f701efff 100644 --- a/app/client/src/ce/pages/Applications/index.tsx +++ b/app/client/src/ce/pages/Applications/index.tsx @@ -104,6 +104,7 @@ import ResourceListLoader from "@appsmith/pages/Applications/ResourceListLoader" import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; import { getHasCreateWorkspacePermission } from "@appsmith/utils/BusinessFeatures/permissionPageHelpers"; +import WorkflowCardList from "@appsmith/pages/Applications/WorkflowCardList"; import { allowManageEnvironmentAccessForUser } from "@appsmith/selectors/environmentSelectors"; import CreateNewAppsOption from "@appsmith/pages/Applications/CreateNewAppsOption"; import { resetCurrentApplicationIdForCreateNewApp } from "actions/onboardingActions"; @@ -598,7 +599,8 @@ export function ApplicationsSection(props: any) { workspacesListComponent = updatedWorkspaces.map( (workspaceObject: any, index: number) => { const isLastWorkspace = updatedWorkspaces.length === index + 1; - const { applications, packages, workspace } = workspaceObject; + const { applications, packages, workflows, workspace } = + workspaceObject; const hasManageWorkspacePermissions = isPermitted( workspace.userPermissions, PERMISSION_TYPE.MANAGE_WORKSPACE, @@ -761,6 +763,13 @@ export function ApplicationsSection(props: any) { workspaceId={workspace.id} /> )} + {!isLoadingResources && ( + + )} {!isLastWorkspace && } diff --git a/app/client/src/ce/selectors/applicationSelectors.tsx b/app/client/src/ce/selectors/applicationSelectors.tsx index 1b77d90c3f..e8ea4a1c8a 100644 --- a/app/client/src/ce/selectors/applicationSelectors.tsx +++ b/app/client/src/ce/selectors/applicationSelectors.tsx @@ -1,6 +1,7 @@ import { createSelector } from "reselect"; import { groupBy } from "lodash"; import type { AppState } from "@appsmith/reducers"; +import type { WorkflowMetadata } from "@appsmith/constants/WorkflowConstants"; import type { ApplicationsReduxState, creatingApplicationMap, @@ -13,6 +14,7 @@ import { hasCreateNewAppPermission } from "@appsmith/utils/permissionHelpers"; import { NAVIGATION_SETTINGS, SIDEBAR_WIDTH } from "constants/AppConstants"; import { getPackagesList } from "@appsmith/selectors/packageSelectors"; import type { PackageMetadata } from "@appsmith/constants/PackageConstants"; +import { getWorkflowsList } from "@appsmith/selectors/workflowSelectors"; const fuzzySearchOptions = { keys: ["applications.name", "workspace.name", "packages.name"], @@ -36,14 +38,17 @@ const fuzzySearchOptions = { * workspace: {}, * applications: [], * users:[], - * packages: [] + * packages: [], + * workflows: [], * } */ -const injectPackagesToWorkspacesList = ( +const injectPackagesAndWorkflowsToWorkspacesList = ( workspacesList: Workspaces[] = [], packages: PackageMetadata[] = [], + workflows: WorkflowMetadata[] = [], ) => { const packagesGroupByWorkspaceId = groupBy(packages, (p) => p.workspaceId); + const workflowsGroupByWorkspaceId = groupBy(workflows, (w) => w?.workspaceId); return workspacesList.map((workspacesObj) => { const { workspace } = workspacesObj; @@ -51,6 +56,7 @@ const injectPackagesToWorkspacesList = ( return { ...workspacesObj, packages: packagesGroupByWorkspaceId[workspace.id] || [], + workflows: workflowsGroupByWorkspaceId[workspace.id] || [], }; }); }; @@ -116,14 +122,17 @@ export const getUserApplicationsWorkspacesList = createSelector( getUserApplicationsWorkspaces, getApplicationSearchKeyword, getPackagesList, + getWorkflowsList, ( applicationsWorkspaces?: Workspaces[], keyword?: string, packages?: PackageMetadata[], + workflows?: WorkflowMetadata[], ) => { - const workspacesList = injectPackagesToWorkspacesList( + const workspacesList = injectPackagesAndWorkflowsToWorkspacesList( applicationsWorkspaces, packages, + workflows, ); if ( @@ -144,11 +153,16 @@ export const getUserApplicationsWorkspacesList = createSelector( ...fuzzySearchOptions, keys: ["name"], }); + const workflowFuzzy = new Fuse(workspace.workflows, { + ...fuzzySearchOptions, + keys: ["name"], + }); return { ...workspace, applications: appFuzzy.search(keyword), packages: packageFuzzy.search(keyword), + workflows: workflowFuzzy.search(keyword), }; }); } else if ( diff --git a/app/client/src/ce/selectors/workflowSelectors.ts b/app/client/src/ce/selectors/workflowSelectors.ts new file mode 100644 index 0000000000..a45f971888 --- /dev/null +++ b/app/client/src/ce/selectors/workflowSelectors.ts @@ -0,0 +1,20 @@ +import type { AppState } from "@appsmith/reducers"; +import type { WorkflowMetadata } from "@appsmith/constants/WorkflowConstants"; + +const DEFAULT_WORKFLOW_LIST: WorkflowMetadata[] = []; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const getIsFetchingWorkflows = (state: AppState) => false; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const getIsCreatingWorkflow = (state: AppState, workspaceId: string) => + false; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const getWorkflowsList = (state: AppState): WorkflowMetadata[] => + DEFAULT_WORKFLOW_LIST; + +export const getIsCurrentEditorWorkflowType = ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + state: AppState, +) => false; diff --git a/app/client/src/ee/constants/WorkflowConstants.ts b/app/client/src/ee/constants/WorkflowConstants.ts new file mode 100644 index 0000000000..56b284a580 --- /dev/null +++ b/app/client/src/ee/constants/WorkflowConstants.ts @@ -0,0 +1 @@ +export * from "ce/constants/WorkflowConstants"; diff --git a/app/client/src/ee/pages/Applications/WorkflowCardList.tsx b/app/client/src/ee/pages/Applications/WorkflowCardList.tsx new file mode 100644 index 0000000000..9c2db63245 --- /dev/null +++ b/app/client/src/ee/pages/Applications/WorkflowCardList.tsx @@ -0,0 +1,3 @@ +export * from "ce/pages/Applications/WorkflowCardList"; +import { default as CE_WorkflowCardList } from "ce/pages/Applications/WorkflowCardList"; +export default CE_WorkflowCardList; diff --git a/app/client/src/ee/selectors/workflowSelectors.ts b/app/client/src/ee/selectors/workflowSelectors.ts new file mode 100644 index 0000000000..22166f4f1f --- /dev/null +++ b/app/client/src/ee/selectors/workflowSelectors.ts @@ -0,0 +1 @@ +export * from "ce/selectors/workflowSelectors"; diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index 0191b1bda8..a1e2cdf3ab 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -101,6 +101,7 @@ import { selectFeatureFlags } from "@appsmith/selectors/featureFlagsSelectors"; import { fetchFeatureFlagsInit } from "actions/userActions"; import { parseUpdatesAndDeleteUndefinedUpdates } from "./EvaluationSaga.utils"; import { getFeatureFlagsFetched } from "selectors/usersSelectors"; +import { getIsCurrentEditorWorkflowType } from "@appsmith/selectors/workflowSelectors"; import { evalErrorHandler } from "./EvalErrorHandler"; import AnalyticsUtil from "utils/AnalyticsUtil"; @@ -607,7 +608,16 @@ function* evaluationChangeListenerSaga(): any { const initAction: EvaluationReduxAction = yield take( FIRST_EVAL_REDUX_ACTIONS, ); - yield call(waitForWidgetConfigBuild); + + // Wait for widget config build to complete before starting evaluation only if the current editor is not a workflow + const isCurrentEditorWorkflowType = yield select( + getIsCurrentEditorWorkflowType, + ); + + if (!isCurrentEditorWorkflowType) { + yield call(waitForWidgetConfigBuild); + } + widgetTypeConfigMap = WidgetFactory.getWidgetTypeConfigMap(); yield fork(evalAndLintingHandler, false, initAction, { shouldReplay: false,