feat: add upgrade banners for teams and organizations (#27650)
This commit is contained in:
1 parent
c197de147a
commit
b7340f7151
74 files changed
+1834
-500
No files matched your search
@@ -2,7 +2,6 @@ import { Memoize, Unmemoize } from "@calcom/features/cache";
|
||||
import type { FeatureId } from "@calcom/features/flags/config";
|
||||
import type { FeatureDto } from "@calcom/lib/dto/FeatureDto";
|
||||
import { FeatureDtoArraySchema, FeatureDtoSchema } from "@calcom/lib/dto/FeatureDto";
|
||||
|
||||
import type { IFeatureRepository } from "./PrismaFeatureRepository";
|
||||
|
||||
const CACHE_PREFIX = "features:global";
|
||||
@@ -47,4 +46,20 @@ export class CachedFeatureRepository implements IFeatureRepository {
|
||||
const feature = await this.findBySlug(slug);
|
||||
return Boolean(feature && feature.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a map of all feature flags and their enabled status.
|
||||
* Uses caching to avoid hitting the database on every request.
|
||||
* @returns Promise<AppFlags> - A map of feature flags to their enabled status
|
||||
*/
|
||||
public async getFeatureFlagMap() {
|
||||
const flags = await this.findAll();
|
||||
return flags.reduce(
|
||||
(acc, flag) => {
|
||||
acc[flag.slug as FeatureId] = flag.enabled;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, boolean>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ export interface IFeatureRepository {
|
||||
findBySlug(slug: string): Promise<FeatureDto | null>;
|
||||
update(input: { featureId: FeatureId; enabled: boolean; updatedBy?: number }): Promise<FeatureDto>;
|
||||
checkIfFeatureIsEnabledGlobally(slug: string): Promise<boolean>;
|
||||
getFeatureFlagMap(): Promise<Record<string, boolean>>;
|
||||
}
|
||||
|
||||
export class PrismaFeatureRepository implements IFeatureRepository {
|
||||
@@ -76,4 +77,15 @@ export class PrismaFeatureRepository implements IFeatureRepository {
|
||||
});
|
||||
return Boolean(feature?.enabled);
|
||||
}
|
||||
|
||||
async getFeatureFlagMap(): Promise<Record<string, boolean>> {
|
||||
const flags = await this.findAll();
|
||||
return flags.reduce(
|
||||
(acc, flag) => {
|
||||
acc[flag.slug as FeatureId] = flag.enabled;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, boolean>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user