mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 12:26:19 +00:00
chore: tweak feature matrix
This commit is contained in:
@ -2,6 +2,14 @@ import { create } from "zustand";
|
||||
import { workspaceServiceClient } from "@/grpcweb";
|
||||
import { WorkspaceProfile, WorkspaceSetting } from "@/types/proto/api/v1/workspace_service";
|
||||
|
||||
export enum FeatureType {
|
||||
SSO = "ysh.slash.sso",
|
||||
AdvancedAnalytics = "ysh.slash.advanced-analytics",
|
||||
UnlimitedAccounts = "ysh.slash.unlimited-accounts",
|
||||
UnlimitedCollections = "ysh.slash.unlimited-collections",
|
||||
CustomeBranding = "ysh.slash.custom-branding",
|
||||
}
|
||||
|
||||
interface WorkspaceState {
|
||||
profile: WorkspaceProfile;
|
||||
setting: WorkspaceSetting;
|
||||
@ -9,6 +17,7 @@ interface WorkspaceState {
|
||||
// Workspace related actions.
|
||||
fetchWorkspaceProfile: () => Promise<WorkspaceProfile>;
|
||||
fetchWorkspaceSetting: () => Promise<WorkspaceSetting>;
|
||||
checkFeatureAvailable: (feature: FeatureType) => boolean;
|
||||
}
|
||||
|
||||
const useWorkspaceStore = create<WorkspaceState>()((set, get) => ({
|
||||
@ -17,6 +26,7 @@ const useWorkspaceStore = create<WorkspaceState>()((set, get) => ({
|
||||
fetchWorkspaceProfile: async () => {
|
||||
const workspaceProfile = (await workspaceServiceClient.getWorkspaceProfile({})).profile as WorkspaceProfile;
|
||||
set({ ...get(), profile: workspaceProfile });
|
||||
console.log("workspaceProfile", workspaceProfile);
|
||||
return workspaceProfile;
|
||||
},
|
||||
fetchWorkspaceSetting: async () => {
|
||||
@ -24,6 +34,9 @@ const useWorkspaceStore = create<WorkspaceState>()((set, get) => ({
|
||||
set({ ...get(), setting: workspaceSetting });
|
||||
return workspaceSetting;
|
||||
},
|
||||
checkFeatureAvailable: (feature: FeatureType): boolean => {
|
||||
return get().profile.features.includes(feature);
|
||||
},
|
||||
}));
|
||||
|
||||
export default useWorkspaceStore;
|
||||
|
Reference in New Issue
Block a user