Remove three old env variables (#2297)

* remove three old env variables IS_DATA_MODEL_SETTINGS_ENABLED IS_DEVELOPERS_SETTINGS_ENABLED FLEXIBLE_BACKEND_ENABLED

* Fix database:reset script

* Removing unused variable

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
bosiraphael
2023-10-31 13:15:24 +01:00
committed by GitHub
parent 71dd6eb0a8
commit dda911fea7
17 changed files with 32 additions and 148 deletions

View File

@ -19,7 +19,6 @@ import MainNavbar from '@/ui/navigation/navbar/components/MainNavbar';
import NavItem from '@/ui/navigation/navbar/components/NavItem'; import NavItem from '@/ui/navigation/navbar/components/NavItem';
import NavTitle from '@/ui/navigation/navbar/components/NavTitle'; import NavTitle from '@/ui/navigation/navbar/components/NavTitle';
import { useGetClientConfigQuery } from './generated/graphql';
import { measureTotalFrameLoad } from './utils/measureTotalFrameLoad'; import { measureTotalFrameLoad } from './utils/measureTotalFrameLoad';
export const AppNavbar = () => { export const AppNavbar = () => {
@ -31,10 +30,6 @@ export const AppNavbar = () => {
const isInSubMenu = useIsSubMenuNavbarDisplayed(); const isInSubMenu = useIsSubMenuNavbarDisplayed();
const { currentUserDueTaskCount } = useCurrentUserTaskCount(); const { currentUserDueTaskCount } = useCurrentUserTaskCount();
const { data } = useGetClientConfigQuery();
const isFlexibleBackendEnabled = data?.clientConfig?.flexibleBackendEnabled;
return ( return (
<> <>
{!isInSubMenu ? ( {!isInSubMenu ? (
@ -95,7 +90,7 @@ export const AppNavbar = () => {
Icon={IconTargetArrow} Icon={IconTargetArrow}
active={currentPath === '/opportunities'} active={currentPath === '/opportunities'}
/> />
{isFlexibleBackendEnabled && <ObjectMetadataNavItems />} <ObjectMetadataNavItems />
</MainNavbar> </MainNavbar>
) : ( ) : (
<SettingsNavbar /> <SettingsNavbar />

View File

@ -658,10 +658,7 @@ export type BoolFilter = {
export type ClientConfig = { export type ClientConfig = {
__typename?: 'ClientConfig'; __typename?: 'ClientConfig';
authProviders: AuthProviders; authProviders: AuthProviders;
dataModelSettingsEnabled: Scalars['Boolean'];
debugMode: Scalars['Boolean']; debugMode: Scalars['Boolean'];
developersSettingsEnabled: Scalars['Boolean'];
flexibleBackendEnabled: Scalars['Boolean'];
signInPrefilled: Scalars['Boolean']; signInPrefilled: Scalars['Boolean'];
support: Support; support: Support;
telemetry: Telemetry; telemetry: Telemetry;
@ -3288,7 +3285,7 @@ export type CheckUserExistsQuery = { __typename?: 'Query', checkUserExists: { __
export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>; export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;
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 GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, debugMode: 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 }; 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 };
@ -4643,8 +4640,6 @@ export const GetClientConfigDocument = gql`
password password
} }
signInPrefilled signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode debugMode
telemetry { telemetry {
enabled enabled
@ -4654,7 +4649,6 @@ export const GetClientConfigDocument = gql`
supportDriver supportDriver
supportFrontChatId supportFrontChatId
} }
flexibleBackendEnabled
} }
} }
`; `;

View File

@ -8,26 +8,14 @@ import { supportChatState } from '@/client-config/states/supportChatState';
import { telemetryState } from '@/client-config/states/telemetryState'; import { telemetryState } from '@/client-config/states/telemetryState';
import { useGetClientConfigQuery } from '~/generated/graphql'; 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> = ({ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
children, children,
}) => { }) => {
const [, setAuthProviders] = useRecoilState(authProvidersState); const [, setAuthProviders] = useRecoilState(authProvidersState);
const [, setIsDebugMode] = useRecoilState(isDebugModeState); const [, setIsDebugMode] = useRecoilState(isDebugModeState);
const [, setIsFlexibleBackendEnabled] = useRecoilState(
isFlexibleBackendEnabledState,
);
const [, setIsSignInPrefilled] = useRecoilState(isSignInPrefilledState); const [, setIsSignInPrefilled] = useRecoilState(isSignInPrefilledState);
const [, setIsDataModelSettingsEnabled] = useRecoilState(
isDataModelSettingsEnabledState,
);
const [, setIsDevelopersSettingsEnabled] = useRecoilState(
isDevelopersSettingsEnabledState,
);
const [, setTelemetry] = useRecoilState(telemetryState); const [, setTelemetry] = useRecoilState(telemetryState);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const setSupportChat = useSetRecoilState(supportChatState); const setSupportChat = useSetRecoilState(supportChatState);
@ -44,15 +32,9 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
password: data?.clientConfig.authProviders.password, password: data?.clientConfig.authProviders.password,
magicLink: false, magicLink: false,
}); });
setIsFlexibleBackendEnabled(data?.clientConfig.flexibleBackendEnabled);
setIsDebugMode(data?.clientConfig.debugMode); setIsDebugMode(data?.clientConfig.debugMode);
setIsSignInPrefilled(data?.clientConfig.signInPrefilled); setIsSignInPrefilled(data?.clientConfig.signInPrefilled);
setIsDataModelSettingsEnabled(
data?.clientConfig.dataModelSettingsEnabled,
);
setIsDevelopersSettingsEnabled(
data?.clientConfig.developersSettingsEnabled,
);
setTelemetry(data?.clientConfig.telemetry); setTelemetry(data?.clientConfig.telemetry);
setSupportChat(data?.clientConfig.support); setSupportChat(data?.clientConfig.support);
} }
@ -60,10 +42,7 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
data, data,
setAuthProviders, setAuthProviders,
setIsDebugMode, setIsDebugMode,
setIsFlexibleBackendEnabled,
setIsSignInPrefilled, setIsSignInPrefilled,
setIsDataModelSettingsEnabled,
setIsDevelopersSettingsEnabled,
setTelemetry, setTelemetry,
setIsLoading, setIsLoading,
loading, loading,

View File

@ -8,8 +8,6 @@ export const GET_CLIENT_CONFIG = gql`
password password
} }
signInPrefilled signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode debugMode
telemetry { telemetry {
enabled enabled
@ -19,7 +17,6 @@ export const GET_CLIENT_CONFIG = gql`
supportDriver supportDriver
supportFrontChatId supportFrontChatId
} }
flexibleBackendEnabled
} }
} }
`; `;

View File

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

View File

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

View File

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

View File

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

View File

@ -212,7 +212,6 @@ export const graphqlMocks = [
return res( return res(
ctx.data({ ctx.data({
clientConfig: { clientConfig: {
flexibleBackendEnabled: true,
signInPrefilled: true, signInPrefilled: true,
dataModelSettingsEnabled: true, dataModelSettingsEnabled: true,
developersSettingsEnabled: true, developersSettingsEnabled: true,

View File

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

View File

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

View File

@ -33,7 +33,7 @@
"database:truncate": "npx ts-node ./scripts/truncate-db.ts", "database:truncate": "npx ts-node ./scripts/truncate-db.ts",
"database:migrate": "yarn typeorm:migrate && yarn prisma:migrate", "database:migrate": "yarn typeorm:migrate && yarn prisma:migrate",
"database:generate": "yarn prisma:generate", "database:generate": "yarn prisma:generate",
"database:seed": "yarn prisma:seed && yarn command tenant:sync-metadata -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419 && yarn command tenant:migrate -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419 && yarn command tenant:data-seed -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419", "database:seed": "yarn prisma:seed && yarn build && yarn command tenant:sync-metadata -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419 && yarn command tenant:migrate -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419 && yarn command tenant:data-seed -w twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419",
"database:reset": "yarn database:truncate && yarn database:init", "database:reset": "yarn database:truncate && yarn database:init",
"command": "node dist/src/command" "command": "node dist/src/command"
}, },

View File

@ -58,8 +58,8 @@ import { ExceptionFilter } from './filters/exception.filter';
// Extract JWT from the request // Extract JWT from the request
const token = ExtractJwt.fromAuthHeaderAsBearerToken()(request.req); const token = ExtractJwt.fromAuthHeaderAsBearerToken()(request.req);
// If there is no token or flexible backend is disabled, return an empty schema // If there is no token return an empty schema
if (!token || !environmentService.isFlexibleBackendEnabled()) { if (!token) {
return new GraphQLSchema({}); return new GraphQLSchema({});
} }

View File

@ -41,18 +41,9 @@ export class ClientConfig {
@Field(() => Boolean) @Field(() => Boolean)
signInPrefilled: boolean; signInPrefilled: boolean;
@Field(() => Boolean)
dataModelSettingsEnabled: boolean;
@Field(() => Boolean)
developersSettingsEnabled: boolean;
@Field(() => Boolean) @Field(() => Boolean)
debugMode: boolean; debugMode: boolean;
@Field(() => Boolean)
flexibleBackendEnabled: boolean;
@Field(() => Support) @Field(() => Support)
support: Support; support: Support;
} }

View File

@ -22,13 +22,7 @@ export class ClientConfigResolver {
this.environmentService.isTelemetryAnonymizationEnabled(), this.environmentService.isTelemetryAnonymizationEnabled(),
}, },
signInPrefilled: this.environmentService.isSignInPrefilled(), signInPrefilled: this.environmentService.isSignInPrefilled(),
dataModelSettingsEnabled:
this.environmentService.isDataModelSettingsEnabled(),
developersSettingsEnabled:
this.environmentService.isDevelopersSettingsEnabled(),
debugMode: this.environmentService.isDebugMode(), debugMode: this.environmentService.isDebugMode(),
flexibleBackendEnabled:
this.environmentService.isFlexibleBackendEnabled(),
support: { support: {
supportDriver: this.environmentService.getSupportDriver(), supportDriver: this.environmentService.getSupportDriver(),
supportFrontChatId: this.environmentService.getSupportFrontChatId(), supportFrontChatId: this.environmentService.getSupportFrontChatId(),

View File

@ -19,18 +19,6 @@ export class EnvironmentService {
return this.configService.get<boolean>('SIGN_IN_PREFILLED') ?? false; 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 { isTelemetryEnabled(): boolean {
return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true; return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true;
} }
@ -41,10 +29,6 @@ export class EnvironmentService {
); );
} }
isFlexibleBackendEnabled(): boolean {
return this.configService.get<boolean>('FLEXIBLE_BACKEND_ENABLED') ?? false;
}
getPort(): number { getPort(): number {
return this.configService.get<number>('PORT') ?? 3000; return this.configService.get<number>('PORT') ?? 3000;
} }

View File

@ -36,16 +36,6 @@ export class EnvironmentVariables {
@IsBoolean() @IsBoolean()
SIGN_IN_PREFILLED?: boolean; SIGN_IN_PREFILLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
IS_DATA_MODEL_SETTINGS_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
IS_DEVELOPERS_SETTINGS_ENABLED?: boolean;
@CastToBoolean() @CastToBoolean()
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ -56,11 +46,6 @@ export class EnvironmentVariables {
@IsBoolean() @IsBoolean()
TELEMETRY_ANONYMIZATION_ENABLED?: boolean; TELEMETRY_ANONYMIZATION_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
FLEXIBLE_BACKEND_ENABLED?: boolean;
@CastToPositiveNumber() @CastToPositiveNumber()
@IsNumber() @IsNumber()
@IsOptional() @IsOptional()