Add isSandboxMode to AppContext (#6704)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- Added `isSandboxMode` to `AppContext`
|
||||
@@ -56,6 +56,7 @@ type InitialStateType = {
|
||||
currentTeam: ITeamSummary | undefined;
|
||||
enrollSecret: IEnrollSecret[] | null;
|
||||
isPreviewMode: boolean | undefined;
|
||||
isSandboxMode: boolean | undefined;
|
||||
isFreeTier: boolean | undefined;
|
||||
isPremiumTier: boolean | undefined;
|
||||
isGlobalAdmin: boolean | undefined;
|
||||
@@ -87,6 +88,7 @@ const initialState = {
|
||||
currentTeam: undefined,
|
||||
enrollSecret: null,
|
||||
isPreviewMode: false,
|
||||
isSandboxMode: false,
|
||||
isFreeTier: undefined,
|
||||
isPremiumTier: undefined,
|
||||
isGlobalAdmin: undefined,
|
||||
@@ -125,6 +127,7 @@ const setPermissions = (
|
||||
}
|
||||
|
||||
return {
|
||||
isSandboxMode: permissions.isSandboxMode(config),
|
||||
isFreeTier: permissions.isFreeTier(config),
|
||||
isPremiumTier: permissions.isPremiumTier(config),
|
||||
isGlobalAdmin: permissions.isGlobalAdmin(user),
|
||||
@@ -180,7 +183,7 @@ const reducer = (state: InitialStateType, action: IAction) => {
|
||||
}
|
||||
case ACTIONS.SET_CONFIG: {
|
||||
const { config } = action;
|
||||
// config.sandbox_enabled = true;
|
||||
// config.sandbox_enabled = true; // TODO: uncomment for sandbox dev
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -212,6 +215,7 @@ const AppProvider = ({ children }: Props): JSX.Element => {
|
||||
currentTeam: state.currentTeam,
|
||||
enrollSecret: state.enrollSecret,
|
||||
isPreviewMode: detectPreview(),
|
||||
isSandboxMode: state.isSandboxMode,
|
||||
isFreeTier: state.isFreeTier,
|
||||
isPremiumTier: state.isPremiumTier,
|
||||
isGlobalAdmin: state.isGlobalAdmin,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { IUser } from "interfaces/user";
|
||||
import { IConfig } from "interfaces/config";
|
||||
|
||||
export const isSandboxMode = (config: IConfig): boolean => {
|
||||
return !!config.sandbox_enabled; // TODO: confirm null/undefined config should treated as false based on final API spec
|
||||
};
|
||||
|
||||
export const isFreeTier = (config: IConfig): boolean => {
|
||||
return config.license.tier === "free";
|
||||
};
|
||||
@@ -99,6 +103,7 @@ const isNoAccess = (user: IUser): boolean => {
|
||||
};
|
||||
|
||||
export default {
|
||||
isSandboxMode,
|
||||
isFreeTier,
|
||||
isPremiumTier,
|
||||
isGlobalAdmin,
|
||||
|
||||
Reference in New Issue
Block a user