fix: Homepage error message with no workspaces & Github changes message (#31691)

## 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"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]  
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8247923955>
> Commit: `6cd2ef6f4cfb2f12f251d6a4ad26e48fe88e78f8`
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8247923955&attempt=2"
target="_blank">Click here!</a>
> All cypress tests have passed 🎉🎉🎉

<!-- end of auto-generated comment: Cypress test results  -->





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Ankita Kinger 2024-03-12 18:14:05 +05:30 committed by GitHub
parent 3a8064ad5f
commit 99639d446e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 47 additions and 18 deletions

View File

@ -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) {
<NewText className="!mb-3 !font-semibold" kind="heading-s">
{createMessage(NO_WORKSPACE_HEADING)}
</NewText>
<NewText className="w-[328px]" kind="heading-xs">
{createMessage(NO_WORKSPACE_DESCRIPTION)}
</NewText>
</div>
);
}

View File

@ -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

View File

@ -98,7 +98,13 @@ export const getQueryIcon = (
query: ActionData | ModuleInstanceData,
pluginImages: Record<string, string>,
) => {
if (!query.config.hasOwnProperty("sourceModuleId")) {
if (query.config.hasOwnProperty("type")) {
return (
<EntityIcon>
<Icon name="module" />
</EntityIcon>
);
} else {
const action = query as ActionData;
return (
<ImageWrapper>
@ -109,12 +115,6 @@ export const getQueryIcon = (
/>
</ImageWrapper>
);
} else {
return (
<EntityIcon>
<Icon name="module" />
</EntityIcon>
);
}
};

View File

@ -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,

View File

@ -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<GitStatusData>) {
@ -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))

View File

@ -670,6 +670,9 @@ export interface GitStatusData {
modifiedJSLibs: number;
discardDocUrl?: string;
migrationMessage?: string;
modifiedPackages?: number;
modifiedModules?: number;
modifiedModuleInstances?: number;
}
interface GitErrorPayloadType {

View File

@ -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) =>