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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 NavTitle from '@/ui/navigation/navbar/components/NavTitle';
import { useGetClientConfigQuery } from './generated/graphql';
import { measureTotalFrameLoad } from './utils/measureTotalFrameLoad';
export const AppNavbar = () => {
@ -31,10 +30,6 @@ export const AppNavbar = () => {
const isInSubMenu = useIsSubMenuNavbarDisplayed();
const { currentUserDueTaskCount } = useCurrentUserTaskCount();
const { data } = useGetClientConfigQuery();
const isFlexibleBackendEnabled = data?.clientConfig?.flexibleBackendEnabled;
return (
<>
{!isInSubMenu ? (
@ -95,7 +90,7 @@ export const AppNavbar = () => {
Icon={IconTargetArrow}
active={currentPath === '/opportunities'}
/>
{isFlexibleBackendEnabled && <ObjectMetadataNavItems />}
<ObjectMetadataNavItems />
</MainNavbar>
) : (
<SettingsNavbar />

View File

@ -658,10 +658,7 @@ 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;
telemetry: Telemetry;
@ -3288,7 +3285,7 @@ export type CheckUserExistsQuery = { __typename?: 'Query', checkUserExists: { __
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 };
@ -4643,8 +4640,6 @@ export const GetClientConfigDocument = gql`
password
}
signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode
telemetry {
enabled
@ -4654,7 +4649,6 @@ export const GetClientConfigDocument = gql`
supportDriver
supportFrontChatId
}
flexibleBackendEnabled
}
}
`;

View File

@ -8,26 +8,14 @@ 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> = ({
children,
}) => {
const [, setAuthProviders] = useRecoilState(authProvidersState);
const [, setIsDebugMode] = useRecoilState(isDebugModeState);
const [, setIsFlexibleBackendEnabled] = useRecoilState(
isFlexibleBackendEnabledState,
);
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);
@ -44,15 +32,9 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
password: data?.clientConfig.authProviders.password,
magicLink: false,
});
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);
}
@ -60,10 +42,7 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
data,
setAuthProviders,
setIsDebugMode,
setIsFlexibleBackendEnabled,
setIsSignInPrefilled,
setIsDataModelSettingsEnabled,
setIsDevelopersSettingsEnabled,
setTelemetry,
setIsLoading,
loading,

View File

@ -8,8 +8,6 @@ export const GET_CLIENT_CONFIG = gql`
password
}
signInPrefilled
dataModelSettingsEnabled
developersSettingsEnabled
debugMode
telemetry {
enabled
@ -19,7 +17,6 @@ export const GET_CLIENT_CONFIG = gql`
supportDriver
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 { 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,
@ -29,22 +26,6 @@ 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/developers/api-keys').pathname,
end: true,
});
return (
<SubMenuNavbar backButtonTitle="Settings" displayVersion={true}>
<NavTitle label="User" />
@ -93,22 +74,30 @@ export const SettingsNavbar = () => {
})
}
/>
{isDataModelSettingsEnabled && (
<NavItem
label="Data model"
to="/settings/objects"
Icon={IconHierarchy2}
active={isDataModelSettingsActive}
active={
!!useMatch({
path: useResolvedPath('/settings/objects').pathname,
end: false,
})
}
/>
)}
{isDevelopersSettingsEnabled && (
<NavItem
label="Developers"
to="/settings/developers/api-keys"
Icon={IconRobot}
active={isDevelopersSettingsActive}
active={
!!useMatch({
path: useResolvedPath('/settings/developers/api-keys').pathname,
end: true,
})
}
/>
)}
<NavTitle label="Other" />
<NavItem label="Logout" onClick={handleLogout} Icon={IconLogout} />
</SubMenuNavbar>

View File

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

View File

@ -26,6 +26,3 @@ SIGN_IN_PREFILLED=true
# LOGGER_DRIVER=console
# 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,8 +14,6 @@ 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

@ -33,7 +33,7 @@
"database:truncate": "npx ts-node ./scripts/truncate-db.ts",
"database:migrate": "yarn typeorm:migrate && yarn prisma:migrate",
"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",
"command": "node dist/src/command"
},

View File

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

View File

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

View File

@ -22,13 +22,7 @@ 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(),
support: {
supportDriver: this.environmentService.getSupportDriver(),
supportFrontChatId: this.environmentService.getSupportFrontChatId(),

View File

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

View File

@ -36,16 +36,6 @@ 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()
@ -56,11 +46,6 @@ export class EnvironmentVariables {
@IsBoolean()
TELEMETRY_ANONYMIZATION_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
FLEXIBLE_BACKEND_ENABLED?: boolean;
@CastToPositiveNumber()
@IsNumber()
@IsOptional()