Created two new env variables (#2120)

* created the two env variables

* modify according to comments
This commit is contained in:
bosiraphael
2023-10-19 14:57:16 +02:00
committed by GitHub
parent c04f6bf371
commit 2b8a81a05c
13 changed files with 118 additions and 23 deletions

View File

@ -648,7 +648,9 @@ export type BoolFilter = {
export type ClientConfig = {
__typename?: 'ClientConfig';
authProviders: AuthProviders;
dataModelSettingsEnabled: Scalars['Boolean'];
debugMode: Scalars['Boolean'];
developersSettingsEnabled: Scalars['Boolean'];
flexibleBackendEnabled: Scalars['Boolean'];
signInPrefilled: Scalars['Boolean'];
support: Support;
@ -1383,6 +1385,8 @@ export type Mutation = {
createOneApiKey: AuthToken;
createOneComment: Comment;
createOneCompany: Company;
createOneField: Field;
createOneObject: Object;
createOnePerson: Person;
createOnePipelineProgress: PipelineProgress;
createOnePipelineStage: PipelineStage;
@ -1397,6 +1401,8 @@ export type Mutation = {
deleteManyView: AffectedRows;
deleteManyViewFilter: AffectedRows;
deleteManyViewSort: AffectedRows;
deleteOneField: FieldDeleteResponse;
deleteOneObject: ObjectDeleteResponse;
deleteOnePipelineStage: PipelineStage;
deleteOneView: View;
deleteUserAccount: User;
@ -1407,6 +1413,8 @@ export type Mutation = {
signUp: LoginToken;
updateOneActivity: Activity;
updateOneCompany?: Maybe<Company>;
updateOneField: Field;
updateOneObject: Object;
updateOnePerson?: Maybe<Person>;
updateOnePipelineProgress?: Maybe<PipelineProgress>;
updateOnePipelineStage?: Maybe<PipelineStage>;
@ -2483,6 +2491,8 @@ export type Query = {
clientConfig: ClientConfig;
currentUser: User;
currentWorkspace: Workspace;
field: Field;
fields: FieldConnection;
findFavorites: Array<Favorite>;
findManyActivities: Array<Activity>;
findManyApiKey: Array<ApiKey>;
@ -2500,6 +2510,8 @@ export type Query = {
findUniqueCompany: Company;
findUniquePerson: Person;
findWorkspaceFromInviteHash: Workspace;
object: Object;
objects: ObjectConnection;
};
@ -3769,7 +3781,7 @@ export type CheckUserExistsQuery = { __typename?: 'Query', checkUserExists: { __
export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, debugMode: boolean, flexibleBackendEnabled: boolean, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean }, telemetry: { __typename?: 'Telemetry', enabled: boolean, anonymizationEnabled: boolean }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null } } };
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, dataModelSettingsEnabled: boolean, developersSettingsEnabled: boolean, debugMode: boolean, flexibleBackendEnabled: boolean, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean }, telemetry: { __typename?: 'Telemetry', enabled: boolean, anonymizationEnabled: boolean }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null } } };
export type BaseCompanyFieldsFragmentFragment = { __typename?: 'Company', address: string, annualRecurringRevenue?: number | null, createdAt: string, domainName: string, employees?: number | null, id: string, idealCustomerProfile: boolean, linkedinUrl?: string | null, name: string, xUrl?: string | null, _activityCount: number };
@ -5212,6 +5224,8 @@ export const GetClientConfigDocument = gql`
password
}
signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode
telemetry {
enabled

View File

@ -8,6 +8,8 @@ import { supportChatState } from '@/client-config/states/supportChatState';
import { telemetryState } from '@/client-config/states/telemetryState';
import { useGetClientConfigQuery } from '~/generated/graphql';
import { isDataModelSettingsEnabledState } from '../states/isDataModelSettingsEnabled';
import { isDevelopersSettingsEnabledState } from '../states/isDevelopersSettingsEnabled';
import { isFlexibleBackendEnabledState } from '../states/isFlexibleBackendEnabledState';
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
@ -20,6 +22,12 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
);
const [, setIsSignInPrefilled] = useRecoilState(isSignInPrefilledState);
const [, setIsDataModelSettingsEnabled] = useRecoilState(
isDataModelSettingsEnabledState,
);
const [, setIsDevelopersSettingsEnabled] = useRecoilState(
isDevelopersSettingsEnabledState,
);
const [, setTelemetry] = useRecoilState(telemetryState);
const [isLoading, setIsLoading] = useState(true);
const setSupportChat = useSetRecoilState(supportChatState);
@ -39,6 +47,12 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
setIsFlexibleBackendEnabled(data?.clientConfig.flexibleBackendEnabled);
setIsDebugMode(data?.clientConfig.debugMode);
setIsSignInPrefilled(data?.clientConfig.signInPrefilled);
setIsDataModelSettingsEnabled(
data?.clientConfig.dataModelSettingsEnabled,
);
setIsDevelopersSettingsEnabled(
data?.clientConfig.developersSettingsEnabled,
);
setTelemetry(data?.clientConfig.telemetry);
setSupportChat(data?.clientConfig.support);
}
@ -48,6 +62,8 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
setIsDebugMode,
setIsFlexibleBackendEnabled,
setIsSignInPrefilled,
setIsDataModelSettingsEnabled,
setIsDevelopersSettingsEnabled,
setTelemetry,
setIsLoading,
loading,

View File

@ -8,6 +8,8 @@ export const GET_CLIENT_CONFIG = gql`
password
}
signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode
telemetry {
enabled

View File

@ -0,0 +1,6 @@
import { atom } from 'recoil';
export const isDataModelSettingsEnabledState = atom<boolean>({
key: 'isDataModelSettingsEnabledState',
default: false,
});

View File

@ -0,0 +1,6 @@
import { atom } from 'recoil';
export const isDevelopersSettingsEnabledState = atom<boolean>({
key: 'isDevelopersSettingsEnabledState',
default: false,
});

View File

@ -1,7 +1,10 @@
import { useCallback } from 'react';
import { useMatch, useNavigate, useResolvedPath } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { useAuth } from '@/auth/hooks/useAuth';
import { isDataModelSettingsEnabledState } from '@/client-config/states/isDataModelSettingsEnabled';
import { isDevelopersSettingsEnabledState } from '@/client-config/states/isDevelopersSettingsEnabled';
import { AppPath } from '@/types/AppPath';
import {
IconColorSwatch,
@ -26,6 +29,22 @@ export const SettingsNavbar = () => {
navigate(AppPath.SignIn);
}, [signOut, navigate]);
const isDataModelSettingsEnabled = useRecoilValue(
isDataModelSettingsEnabledState,
);
const isDevelopersSettingsEnabled = useRecoilValue(
isDevelopersSettingsEnabledState,
);
const isDataModelSettingsActive = !!useMatch({
path: useResolvedPath('/settings/objects').pathname,
end: false,
});
const isDevelopersSettingsActive = !!useMatch({
path: useResolvedPath('/settings/api').pathname,
end: true,
});
return (
<SubMenuNavbar backButtonTitle="Settings" displayVersion={true}>
<NavTitle label="User" />
@ -74,28 +93,22 @@ export const SettingsNavbar = () => {
})
}
/>
<NavItem
label="Data model"
to="/settings/objects"
Icon={IconHierarchy2}
active={
!!useMatch({
path: useResolvedPath('/settings/objects').pathname,
end: false,
})
}
/>
<NavItem
label="Developers"
to="/settings/apis"
Icon={IconRobot}
active={
!!useMatch({
path: useResolvedPath('/settings/api').pathname,
end: true,
})
}
/>
{isDataModelSettingsEnabled && (
<NavItem
label="Data model"
to="/settings/objects"
Icon={IconHierarchy2}
active={isDataModelSettingsActive}
/>
)}
{isDevelopersSettingsEnabled && (
<NavItem
label="Developers"
to="/settings/apis"
Icon={IconRobot}
active={isDevelopersSettingsActive}
/>
)}
<NavTitle label="Other" />
<NavItem label="Logout" onClick={handleLogout} Icon={IconLogout} />
</SubMenuNavbar>

View File

@ -217,6 +217,8 @@ export const graphqlMocks = [
ctx.data({
clientConfig: {
signInPrefilled: true,
dataModelSettingsEnabled: true,
developersSettingsEnabled: true,
debugMode: false,
authProviders: { google: true, password: true, magicLink: false },
telemetry: { enabled: false, anonymizationEnabled: true },

View File

@ -27,3 +27,5 @@ SIGN_IN_PREFILLED=true
# SENTRY_DSN=https://xxx@xxx.ingest.sentry.io/xxx
# LOG_LEVEL=error,warn
# FLEXIBLE_BACKEND_ENABLED=false
# IS_DATA_MODEL_SETTINGS_ENABLED=false
# IS_DEVELOPERS_SETTINGS_ENABLED=false

View File

@ -14,6 +14,8 @@ REFRESH_TOKEN_SECRET=secret_refresh_token
# ———————— Optional ————————
# DEBUG_MODE=false
# SIGN_IN_PREFILLED=false
# IS_DATA_MODEL_SETTINGS_ENABLED=false
# IS_DEVELOPERS_SETTINGS_ENABLED=false
# ACCESS_TOKEN_EXPIRES_IN=30m
# LOGIN_TOKEN_EXPIRES_IN=15m
# REFRESH_TOKEN_EXPIRES_IN=90d

View File

@ -41,6 +41,12 @@ export class ClientConfig {
@Field(() => Boolean)
signInPrefilled: boolean;
@Field(() => Boolean)
dataModelSettingsEnabled: boolean;
@Field(() => Boolean)
developersSettingsEnabled: boolean;
@Field(() => Boolean)
debugMode: boolean;

View File

@ -22,6 +22,10 @@ export class ClientConfigResolver {
this.environmentService.isTelemetryAnonymizationEnabled(),
},
signInPrefilled: this.environmentService.isSignInPrefilled(),
dataModelSettingsEnabled:
this.environmentService.isDataModelSettingsEnabled(),
developersSettingsEnabled:
this.environmentService.isDevelopersSettingsEnabled(),
debugMode: this.environmentService.isDebugMode(),
flexibleBackendEnabled:
this.environmentService.isFlexibleBackendEnabled(),

View File

@ -19,6 +19,18 @@ export class EnvironmentService {
return this.configService.get<boolean>('SIGN_IN_PREFILLED') ?? false;
}
isDataModelSettingsEnabled(): boolean {
return (
this.configService.get<boolean>('IS_DATA_MODEL_SETTINGS_ENABLED') ?? false
);
}
isDevelopersSettingsEnabled(): boolean {
return (
this.configService.get<boolean>('IS_DEVELOPERS_SETTINGS_ENABLED') ?? false
);
}
isTelemetryEnabled(): boolean {
return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true;
}

View File

@ -36,6 +36,16 @@ export class EnvironmentVariables {
@IsBoolean()
SIGN_IN_PREFILLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
IS_DATA_MODEL_SETTINGS_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
IS_DEVELOPERS_SETTINGS_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()