chore: Remove client feature flag system (#14791)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-28 10:45:16 -05:00
1 parent 2cbd8726fd
commit 38eb10db51
2 files changed
-101

No files matched your search

-26
View File
@@ -17,7 +17,6 @@ import {
import { DeveloperSection } from "~/actions/sections";
import env from "~/env";
import { client } from "~/utils/ApiClient";
import { Feature, FeatureFlags } from "~/utils/FeatureFlags";
import Logger from "~/utils/Logger";
import { deleteAllDatabases } from "~/utils/developer";
import history from "~/utils/history";
@@ -216,30 +215,6 @@ export const toggleDebugSafeArea = createAction({
},
});
export const toggleFeatureFlag = createActionWithChildren({
name: "Toggle feature flag",
icon: <BeakerIcon />,
section: DeveloperSection,
visible: () => env.ENVIRONMENT === "development",
children: Object.values(Feature).map((flag) =>
createAction({
id: `flag-${flag}`,
name: flag,
selected: () => FeatureFlags.isEnabled(flag),
section: DeveloperSection,
perform: () => {
if (FeatureFlags.isEnabled(flag)) {
FeatureFlags.disable(flag);
toast.success(`Disabled feature flag: ${flag}`);
} else {
FeatureFlags.enable(flag);
toast.success(`Enabled feature flag: ${flag}`);
}
},
})
),
});
export const developer = createActionWithChildren({
name: ({ t }) => t("Development"),
keywords: "debug",
@@ -251,7 +226,6 @@ export const developer = createActionWithChildren({
copyId,
toggleDebugLogging,
toggleDebugSafeArea,
toggleFeatureFlag,
createToast,
createTestUsers,
createTestNotifications,
-75
View File
@@ -1,75 +0,0 @@
import { makeObservable, observable, runInAction } from "mobx";
import Storage from "@shared/utils/Storage";
/**
* Available feature flags that can be toggled per-client.
*/
export enum Feature {
/** New collection permissions UI */
newCollectionSharing = "newCollectionSharing",
}
/** Default values for feature flags */
const FeatureDefaults: Record<Feature, boolean> = {
[Feature.newCollectionSharing]: true,
};
/**
* A simple feature flagging system that stores flags in browser storage.
*/
export class FeatureFlags {
/**
* Checks whether a feature flag is currently enabled.
*
* @param flag the feature flag to check.
* @returns true if the flag is enabled.
*/
public static isEnabled(flag: Feature) {
// init on first read
if (this.initialized === false) {
runInAction(() => {
this.cache = new Set();
for (const key of Object.values(Feature)) {
const value = Storage.get(key);
if (value === true) {
this.cache.add(key);
}
}
this.initialized = true;
});
}
return this.cache.has(flag) ? true : (FeatureDefaults[flag] ?? false);
}
/**
* Enables a feature flag and persists the value to browser storage.
*
* @param flag the feature flag to enable.
*/
public static enable(flag: Feature) {
runInAction(() => {
this.cache.add(flag);
});
Storage.set(flag, true);
}
/**
* Disables a feature flag and persists the value to browser storage.
*
* @param flag the feature flag to disable.
*/
public static disable(flag: Feature) {
runInAction(() => {
this.cache.delete(flag);
});
Storage.set(flag, false);
}
@observable
private static cache: Set<Feature> = new Set();
private static initialized = false;
}
makeObservable(FeatureFlags);