From 99639d446e3ab73dd5d0432157a2f7d3440f4e33 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Tue, 12 Mar 2024 18:14:05 +0530 Subject: [PATCH] fix: Homepage error message with no workspaces & Github changes message (#31691) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - Fixing error message on homepage when there are no workspaces - Fixing leave workspace leading to no workspaces message - Fixing github changes list message on the git modal with modules & module instances - Adding doc link for packages Fixes [#30748](https://github.com/appsmithorg/appsmith/issues/30748) [#31472](https://github.com/appsmithorg/appsmith/issues/31472) [#30214](https://github.com/appsmithorg/appsmith/issues/30214) ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!IMPORTANT] > Workflow run: > Commit: `6cd2ef6f4cfb2f12f251d6a4ad26e48fe88e78f8` > Cypress dashboard url: Click here! > All cypress tests have passed 🎉🎉🎉 ## Summary by CodeRabbit - **New Features** - Added new categories (`PACKAGES`, `MODULES`, `MODULE_INSTANCES`) to track changes in Git Sync more effectively. - Introduced a new constant for accessing the packages overview documentation. - **Enhancements** - Improved icon determination logic for queries based on their configuration. - Enhanced user experience by redirecting to "/applications" after leaving a workspace. - **Refactor** - Optimized the `leaveWS` function for better performance. - Updated selectors and reducers to handle new Git Sync tracking categories. - **Tests** - Expanded test coverage to include tracking of modified packages, modules, and module instances. --- .../src/ce/pages/Applications/index.tsx | 17 ++++++++-------- app/client/src/ce/sagas/userSagas.tsx | 1 + .../useSource/useConnectToOptions.tsx | 14 ++++++------- .../src/constants/ThirdPartyConstants.tsx | 2 ++ .../gitSync/components/GitChangesList.tsx | 20 +++++++++++++++++++ .../src/reducers/uiReducers/gitSyncReducer.ts | 3 +++ app/client/src/selectors/gitSyncSelectors.tsx | 8 ++++++-- 7 files changed, 47 insertions(+), 18 deletions(-) diff --git a/app/client/src/ce/pages/Applications/index.tsx b/app/client/src/ce/pages/Applications/index.tsx index 14b6733899..140b7c20bb 100644 --- a/app/client/src/ce/pages/Applications/index.tsx +++ b/app/client/src/ce/pages/Applications/index.tsx @@ -12,7 +12,6 @@ import { createMessage, INVITE_USERS_PLACEHOLDER, NO_APPS_FOUND, - NO_WORKSPACE_DESCRIPTION, NO_WORKSPACE_HEADING, WORKSPACES_HEADING, } from "@appsmith/constants/messages"; @@ -565,11 +564,14 @@ export function ApplicationsSection(props: any) { setSelectedWorkspaceIdForImportApplication, ]); - const leaveWS = (workspaceId: string) => { - setWarnLeavingWorkspace(false); - setWorkspaceToOpenMenu(null); - dispatch(leaveWorkspace(workspaceId)); - }; + const leaveWS = useCallback( + (workspaceId: string) => { + setWarnLeavingWorkspace(false); + setWorkspaceToOpenMenu(null); + dispatch(leaveWorkspace(workspaceId)); + }, + [dispatch], + ); const handleDeleteWorkspace = useCallback( (workspaceId: string) => { @@ -657,9 +659,6 @@ export function ApplicationsSection(props: any) { {createMessage(NO_WORKSPACE_HEADING)} - - {createMessage(NO_WORKSPACE_DESCRIPTION)} - ); } diff --git a/app/client/src/ce/sagas/userSagas.tsx b/app/client/src/ce/sagas/userSagas.tsx index dc84d0f5b2..4439ea2df9 100644 --- a/app/client/src/ce/sagas/userSagas.tsx +++ b/app/client/src/ce/sagas/userSagas.tsx @@ -602,6 +602,7 @@ export function* leaveWorkspaceSaga( toast.show(`You have successfully left the workspace`, { kind: "success", }); + history.push("/applications"); } } catch (error) { // do nothing as it's already handled globally diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx index 17d202093a..2a781f7329 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx @@ -98,7 +98,13 @@ export const getQueryIcon = ( query: ActionData | ModuleInstanceData, pluginImages: Record, ) => { - if (!query.config.hasOwnProperty("sourceModuleId")) { + if (query.config.hasOwnProperty("type")) { + return ( + + + + ); + } else { const action = query as ActionData; return ( @@ -109,12 +115,6 @@ export const getQueryIcon = ( /> ); - } else { - return ( - - - - ); } }; diff --git a/app/client/src/constants/ThirdPartyConstants.tsx b/app/client/src/constants/ThirdPartyConstants.tsx index f03e68f827..f98268edb0 100644 --- a/app/client/src/constants/ThirdPartyConstants.tsx +++ b/app/client/src/constants/ThirdPartyConstants.tsx @@ -31,6 +31,8 @@ export const DOCS_BRANCH_PROTECTION_URL = "https://docs.appsmith.com/advanced-concepts/version-control-with-git/working-with-branches#branch-protection"; export const DOCS_DEFAULT_BRANCH_URL = "https://docs.appsmith.com/advanced-concepts/version-control-with-git/working-with-branches#default-branch"; +export const PACKAGES_OVERVIEW_DOC = + "https://docs.appsmith.com/packages/overview"; export const PRICING_PAGE_URL = ( URL: string, diff --git a/app/client/src/pages/Editor/gitSync/components/GitChangesList.tsx b/app/client/src/pages/Editor/gitSync/components/GitChangesList.tsx index 011417885c..1d4002cef7 100644 --- a/app/client/src/pages/Editor/gitSync/components/GitChangesList.tsx +++ b/app/client/src/pages/Editor/gitSync/components/GitChangesList.tsx @@ -57,6 +57,8 @@ export enum Kind { JS_LIB = "JS_LIB", THEME = "THEME", SETTINGS = "SETTINGS", + PACKAGES = "PACKAGES", + MODULES = "MODULES", } interface GitStatusProps { @@ -125,6 +127,22 @@ const STATUS_MAP: GitStatusMap = { iconName: "package", hasValue: (status?.modifiedJSLibs || 0) > 0, }), + [Kind.PACKAGES]: (status) => ({ + message: `${status?.modifiedPackages || 0} ${ + (status?.modifiedPackages || 0) <= 1 ? "package" : "packages" + } modified`, + iconName: "package", + hasValue: (status?.modifiedPackages || 0) > 0, + }), + [Kind.MODULES]: (status) => ({ + message: `${status?.modifiedModules || 0} ${ + (status?.modifiedModules || 0) <= 1 + ? "module configuration" + : "module configurations" + } modified`, + iconName: "package", + hasValue: (status?.modifiedModules || 0) > 0, + }), }; function behindCommitMessage(status: Partial) { @@ -193,6 +211,8 @@ export function gitChangeListData( Kind.JS_OBJECT, Kind.DATA_SOURCE, Kind.JS_LIB, + Kind.MODULES, + Kind.PACKAGES, ]; return changeKind .map((type: Kind) => STATUS_MAP[type](status)) diff --git a/app/client/src/reducers/uiReducers/gitSyncReducer.ts b/app/client/src/reducers/uiReducers/gitSyncReducer.ts index 5c28324c38..b69a7b9f06 100644 --- a/app/client/src/reducers/uiReducers/gitSyncReducer.ts +++ b/app/client/src/reducers/uiReducers/gitSyncReducer.ts @@ -670,6 +670,9 @@ export interface GitStatusData { modifiedJSLibs: number; discardDocUrl?: string; migrationMessage?: string; + modifiedPackages?: number; + modifiedModules?: number; + modifiedModuleInstances?: number; } interface GitErrorPayloadType { diff --git a/app/client/src/selectors/gitSyncSelectors.tsx b/app/client/src/selectors/gitSyncSelectors.tsx index d3b6efc307..68c3388953 100644 --- a/app/client/src/selectors/gitSyncSelectors.tsx +++ b/app/client/src/selectors/gitSyncSelectors.tsx @@ -135,8 +135,12 @@ export const getMergeError = (state: AppState) => state.ui.gitSync.mergeError; export const getCountOfChangesToCommit = (state: AppState) => { const gitStatus = getGitStatus(state); - const { modifiedPages = 0, modifiedQueries = 0 } = gitStatus || {}; - return modifiedPages + modifiedQueries; + const { + modifiedModules = 0, + modifiedPages = 0, + modifiedQueries = 0, + } = gitStatus || {}; + return modifiedPages + modifiedQueries + modifiedModules; }; export const getShowRepoLimitErrorModal = (state: AppState) =>