chore: Optimizing code-split for mapStateToProps and mapDispatchToProps (#27726)

## Description

Optimizing code-split for mapStateToProps and mapDispatchToProps

#### PR fixes following issue(s)
Fixes [#27727](https://github.com/appsmithorg/appsmith/issues/27727)

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)

## Testing

#### How Has This Been Tested?
- [x] Manual
- [ ] JUnit
- [ ] Jest
- [x] Cypress

## 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
- [ ] 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
This commit is contained in:
Ankita Kinger 2023-09-30 11:58:05 +05:30 committed by GitHub
parent e1e2af4c73
commit 266c41fde3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 21 deletions

View File

@ -204,12 +204,12 @@ function AppRouter(props: {
);
}
const mapStateToProps = (state: AppState) => ({
export const mapStateToProps = (state: AppState) => ({
safeCrash: getSafeCrash(state),
safeCrashCode: getSafeCrashCode(state),
});
const mapDispatchToProps = (dispatch: any) => ({
export const mapDispatchToProps = (dispatch: any) => ({
getCurrentUser: () => dispatch(getCurrentUser()),
getFeatureFlags: () => dispatch(fetchFeatureFlagsInit()),
getCurrentTenant: () => dispatch(getCurrentTenant(false)),

View File

@ -849,7 +849,7 @@ export class Applications<
}
}
const mapStateToProps = (state: AppState) => ({
export const mapStateToProps = (state: AppState) => ({
applicationList: getApplicationList(state),
isFetchingApplications: getIsFetchingApplications(state),
isCreatingApplication: getIsCreatingApplication(state),
@ -860,7 +860,7 @@ const mapStateToProps = (state: AppState) => ({
searchKeyword: getApplicationSearchKeyword(state),
});
const mapDispatchToProps = (dispatch: any) => ({
export const mapDispatchToProps = (dispatch: any) => ({
getAllApplication: () => {
dispatch({ type: ReduxActionTypes.GET_ALL_APPLICATION_INIT });
},

View File

@ -718,23 +718,28 @@ function WorkspaceInviteUsersForm(props: any) {
);
}
export const mapStateToProps = (
state: AppState,
{ formName }: { formName?: string },
) => ({
roles: getRolesForField(state),
allUsers: getAllUsers(state),
isLoading: state.ui.workspaces.loadingStates.isFetchAllUsers,
form: formName || INVITE_USERS_TO_WORKSPACE_FORM,
});
export const mapDispatchToProps = (dispatch: any) => ({
fetchAllRoles: (workspaceId: string) =>
dispatch(fetchRolesForWorkspace(workspaceId)),
fetchCurrentWorkspace: (workspaceId: string) =>
dispatch(fetchWorkspace(workspaceId)),
fetchUser: (workspaceId: string) =>
dispatch(fetchUsersForWorkspace(workspaceId)),
});
export default connect(
(state: AppState, { formName }: { formName?: string }) => {
return {
roles: getRolesForField(state),
allUsers: getAllUsers(state),
isLoading: state.ui.workspaces.loadingStates.isFetchAllUsers,
form: formName || INVITE_USERS_TO_WORKSPACE_FORM,
};
},
(dispatch: any) => ({
fetchAllRoles: (workspaceId: string) =>
dispatch(fetchRolesForWorkspace(workspaceId)),
fetchCurrentWorkspace: (workspaceId: string) =>
dispatch(fetchWorkspace(workspaceId)),
fetchUser: (workspaceId: string) =>
dispatch(fetchUsersForWorkspace(workspaceId)),
}),
mapStateToProps,
mapDispatchToProps,
)(
reduxForm<
InviteUsersToWorkspaceFormValues,

View File

@ -102,7 +102,12 @@ const CircleAppIcon = styled(AppIcon)`
const NameWrapper = styled((props: HTMLDivProps & NameWrapperProps) => (
<div
{...omit(props, ["hasReadPermission", "showOverlay", "isContextMenuOpen"])}
{...omit(props, [
"hasReadPermission",
"showOverlay",
"isContextMenuOpen",
"testId",
])}
/>
))`
.bp3-card {