mirror of
https://github.com/makeplane/plane.git
synced 2025-12-29 00:24:56 +01:00
* dev: initialize feature flagging * dev: feature flagging workspace active cycles * dev: update feature flag implementation * dev: add `FEATURE_FLAG_SERVER_AUTH_TOKEN` env * dev: add feature flagging for backend apis * dev: setup feature flags store and hooks. (#558) * dev: setup feature flags store and hooks. * minor improvements for swr key and flags enum. * dev: workspace active cycles feature flag. (#562) * dev: add task for cancelling the workspace subscription when the workspace is deleted * dev: rename feaure flagging component * dev: update feature flagging function for spaces * dev: add feature flags for bulk ops, issue embeds and page publish. (#589) * dev: add logging for member sync task * dev: restrict workspace from deleting if the subscription is active * dev: workspace delete check endpoint * dev: subscription endpoint check * dev: update subscriptions * chore: plane pro billing and plans page updates. * dev: update pro pill display logic. * dev: fix feature flagging * chore: minor improvement in cloud-badge to avoid API calls to `products` endpoint if user has PRO subscription. --------- Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { set } from "lodash";
|
|
import { action, makeObservable, observable, runInAction } from "mobx";
|
|
// services
|
|
import { FeatureFlagService, TFeatureFlagsResponse } from "@/plane-web/services/feature-flag.service";
|
|
// plane web store
|
|
|
|
const featureFlagService = new FeatureFlagService();
|
|
|
|
type TFeatureFlagsMaps = {
|
|
[featureFlag: string]: boolean;
|
|
};
|
|
|
|
export interface IFeatureFlagsStore {
|
|
loader: boolean;
|
|
flags: TFeatureFlagsMaps;
|
|
fetchFeatureFlags: (workspaceSlug: string, userId: string) => Promise<TFeatureFlagsResponse>;
|
|
}
|
|
|
|
export class FeatureFlagsStore implements IFeatureFlagsStore {
|
|
loader = false;
|
|
flags: TFeatureFlagsMaps = {};
|
|
|
|
constructor() {
|
|
makeObservable(this, {
|
|
loader: observable.ref,
|
|
flags: observable,
|
|
fetchFeatureFlags: action,
|
|
});
|
|
}
|
|
|
|
fetchFeatureFlags = async (workspaceSlug: string, userId: string) => {
|
|
try {
|
|
set(this, "loader", true);
|
|
const response = await featureFlagService.getFeatureFlags({ workspace_slug: workspaceSlug, user_id: userId });
|
|
runInAction(() => {
|
|
if (response.values) {
|
|
Object.keys(response.values).forEach((key) => {
|
|
set(this.flags, key, response.values[key]);
|
|
});
|
|
}
|
|
set(this, "loader", false);
|
|
});
|
|
return response;
|
|
} catch (error) {
|
|
set(this, "loader", false);
|
|
console.error("Error fetching feature flags", error);
|
|
throw error;
|
|
}
|
|
};
|
|
}
|