Skip to content

Commit

Permalink
refactor(core): move editor settings flag from runtime config to Feat…
Browse files Browse the repository at this point in the history
…ureFlagService
  • Loading branch information
JimmFly committed Aug 21, 2024
1 parent cb41884 commit 5af885b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/common/env/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const runtimeFlagsSchema = z.object({
enableInfoModal: z.boolean(),
enableOrganize: z.boolean(),
enableThemeEditor: z.boolean(),
enableEditorSettings: z.boolean(),
});

export type RuntimeConfig = z.infer<typeof runtimeFlagsSchema>;
Expand Down
7 changes: 7 additions & 0 deletions packages/common/infra/src/modules/feature-flag/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export const AFFINE_FLAGS = {
configurable: true,
defaultState: false,
},
enable_editor_settings: {
category: 'affine',
displayName: 'Editor Settings',
description: 'Enables editor settings.',
configurable: isCanaryBuild,
defaultState: false,
},
} satisfies { [key in string]: FlagInfo };

export type AFFINE_FLAGS = typeof AFFINE_FLAGS;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
InformationIcon,
KeyboardIcon,
} from '@blocksuite/icons/rc';
import { useLiveData, useServices } from '@toeverything/infra';
import {
FeatureFlagService,
useLiveData,
useServices,
} from '@toeverything/infra';
import type { ReactElement, SVGProps } from 'react';
import { useEffect } from 'react';

Expand All @@ -33,15 +37,24 @@ export type GeneralSettingList = GeneralSettingListItem[];

export const useGeneralSettingList = (): GeneralSettingList => {
const t = useI18n();
const { authService, serverConfigService, userFeatureService } = useServices({
const {
authService,
serverConfigService,
userFeatureService,
featureFlagService,
} = useServices({
AuthService,
ServerConfigService,
UserFeatureService,
FeatureFlagService,
});
const status = useLiveData(authService.session.status$);
const hasPaymentFeature = useLiveData(
serverConfigService.serverConfig.features$.map(f => f?.payment)
);
const enableEditorSettings = useLiveData(
featureFlagService.flags.enable_editor_settings.$
);

useEffect(() => {
userFeatureService.userFeature.revalidate();
Expand All @@ -67,7 +80,7 @@ export const useGeneralSettingList = (): GeneralSettingList => {
testId: 'about-panel-trigger',
},
];
if (runtimeConfig.enableEditorSettings) {
if (enableEditorSettings) {
// add editor settings to second position
settings.splice(1, 0, {
key: 'editor',
Expand Down
2 changes: 0 additions & 2 deletions tools/cli/src/webpack/runtime-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
enableNewSettingUnstableApi: false,
enableEnhanceShareMode: false,
enableThemeEditor: false,
enableEditorSettings: false,
};
},
get beta() {
Expand Down Expand Up @@ -57,7 +56,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
enableInfoModal: true,
enableOrganize: true,
enableThemeEditor: true,
enableEditorSettings: true,
};
},
};
Expand Down

0 comments on commit 5af885b

Please sign in to comment.