2022-10-15 14:51:25 +00:00
|
|
|
import {
|
|
|
|
|
ReduxAction,
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2022-12-09 14:43:47 +00:00
|
|
|
import { createBrandColorsFromPrimaryColor } from "utils/BrandingUtils";
|
2022-10-15 14:51:25 +00:00
|
|
|
import { createReducer } from "utils/ReducerUtils";
|
|
|
|
|
|
|
|
|
|
export interface TenantReduxState {
|
|
|
|
|
userPermissions: string[];
|
2022-12-09 14:43:47 +00:00
|
|
|
tenantConfiguration: Record<string, any>;
|
2022-10-15 14:51:25 +00:00
|
|
|
new: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 14:43:47 +00:00
|
|
|
export const defaultBrandingConfig = {
|
|
|
|
|
brandFaviconUrl: "/static/img/favicon-orange.ico",
|
|
|
|
|
brandColors: {
|
|
|
|
|
...createBrandColorsFromPrimaryColor("#F86A2B"),
|
|
|
|
|
},
|
|
|
|
|
brandLogoUrl: "/static/img/appsmith-logo.svg",
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-15 14:51:25 +00:00
|
|
|
export const initialState: TenantReduxState = {
|
|
|
|
|
userPermissions: [],
|
2022-12-09 14:43:47 +00:00
|
|
|
tenantConfiguration: {
|
|
|
|
|
brandColors: {
|
|
|
|
|
...createBrandColorsFromPrimaryColor("#000"),
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-10-15 14:51:25 +00:00
|
|
|
new: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const handlers = {
|
|
|
|
|
[ReduxActionTypes.FETCH_CURRENT_TENANT_CONFIG_SUCCESS]: (
|
|
|
|
|
state: TenantReduxState,
|
|
|
|
|
action: ReduxAction<TenantReduxState>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
2022-12-09 14:43:47 +00:00
|
|
|
userPermissions: action.payload.userPermissions,
|
|
|
|
|
tenantConfiguration: {
|
|
|
|
|
...defaultBrandingConfig,
|
|
|
|
|
...action.payload.tenantConfiguration,
|
|
|
|
|
},
|
2022-10-15 14:51:25 +00:00
|
|
|
}),
|
|
|
|
|
[ReduxActionErrorTypes.FETCH_CURRENT_TENANT_CONFIG_ERROR]: (
|
|
|
|
|
state: TenantReduxState,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default createReducer(initialState, handlers);
|