PromucFlow_constructor/app/client/src/ce/reducers/tenantReducer.ts

109 lines
3.4 KiB
TypeScript
Raw Normal View History

import type { ReduxAction } from "ee/constants/ReduxActionConstants";
import {
ReduxActionErrorTypes,
ReduxActionTypes,
} from "ee/constants/ReduxActionConstants";
import {
APPSMITH_BRAND_FAVICON_URL,
APPSMITH_BRAND_LOGO_URL,
APPSMITH_BRAND_PRIMARY_COLOR,
createBrandColorsFromPrimaryColor,
} from "utils/BrandingUtils";
import { createReducer } from "utils/ReducerUtils";
export interface TenantReduxState<T> {
userPermissions: string[];
tenantConfiguration: Record<string, T>;
new: boolean;
isLoading: boolean;
instanceId: string;
}
export const defaultBrandingConfig = {
brandFaviconUrl: APPSMITH_BRAND_FAVICON_URL,
brandColors: {
...createBrandColorsFromPrimaryColor(APPSMITH_BRAND_PRIMARY_COLOR),
},
brandLogoUrl: APPSMITH_BRAND_LOGO_URL,
};
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const initialState: TenantReduxState<any> = {
userPermissions: [],
tenantConfiguration: {
...defaultBrandingConfig,
},
new: false,
isLoading: true,
instanceId: "",
};
export const handlers = {
[ReduxActionTypes.FETCH_CURRENT_TENANT_CONFIG]: (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state: TenantReduxState<any>,
action: ReduxAction<{ isBackgroundRequest: boolean }>,
) => ({
...state,
isLoading: !action.payload.isBackgroundRequest,
}),
[ReduxActionTypes.FETCH_CURRENT_TENANT_CONFIG_SUCCESS]: (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state: TenantReduxState<any>,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
action: ReduxAction<TenantReduxState<any>>,
) => ({
...state,
userPermissions: action.payload.userPermissions || [],
tenantConfiguration: {
chore: Updating strings to sentence case and moving brand colors logic update to tenant reducer (#28219) ## Description Updating strings to sentence case and moving brand colors logic update to tenant reducer #### PR fixes following issue(s) Fixes [#28235](https://github.com/appsmithorg/appsmith/issues/28235) #### 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
2023-10-19 18:12:01 +00:00
...defaultBrandingConfig,
...state.tenantConfiguration,
...action.payload.tenantConfiguration,
chore: Updating strings to sentence case and moving brand colors logic update to tenant reducer (#28219) ## Description Updating strings to sentence case and moving brand colors logic update to tenant reducer #### PR fixes following issue(s) Fixes [#28235](https://github.com/appsmithorg/appsmith/issues/28235) #### 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
2023-10-19 18:12:01 +00:00
brandColors: {
...defaultBrandingConfig.brandColors,
...action.payload.tenantConfiguration.brandColors,
},
},
isLoading: false,
instanceId: action.payload.instanceId,
}),
[ReduxActionErrorTypes.FETCH_CURRENT_TENANT_CONFIG_ERROR]: (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state: TenantReduxState<any>,
) => ({
...state,
isLoading: false,
}),
chore: add utility for widget level acl (#23526) ## Description > This is a utility code change for supporting Widget Level ACL in Appsmith-EE. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/23260 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > A test case has been added to assert the user management role. #### 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2023-06-02 11:06:41 +00:00
[ReduxActionTypes.UPDATE_TENANT_CONFIG_SUCCESS]: (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
chore: add utility for widget level acl (#23526) ## Description > This is a utility code change for supporting Widget Level ACL in Appsmith-EE. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/23260 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > A test case has been added to assert the user management role. #### 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2023-06-02 11:06:41 +00:00
state: TenantReduxState<any>,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
chore: add utility for widget level acl (#23526) ## Description > This is a utility code change for supporting Widget Level ACL in Appsmith-EE. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/23260 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > A test case has been added to assert the user management role. #### 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2023-06-02 11:06:41 +00:00
action: ReduxAction<TenantReduxState<any>>,
) => ({
...state,
...action.payload,
tenantConfiguration: {
...state.tenantConfiguration,
...action.payload.tenantConfiguration,
},
isLoading: false,
}),
[ReduxActionErrorTypes.UPDATE_TENANT_CONFIG_ERROR]: (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
chore: add utility for widget level acl (#23526) ## Description > This is a utility code change for supporting Widget Level ACL in Appsmith-EE. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/23260 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > A test case has been added to assert the user management role. #### 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2023-06-02 11:06:41 +00:00
state: TenantReduxState<any>,
) => ({
...state,
isLoading: false,
}),
};
export default createReducer(initialState, handlers);