mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add product for new personal plan
Summary: Adds the new personal plan as a product that will be available in the future. Can be enabled along with other plan-related via an environment variable. Test Plan: Browser tests and existing tests. Reviewers: jarek Reviewed By: jarek Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3533
This commit is contained in:
@@ -68,16 +68,55 @@ export function canAddOrgMembers(features: Features): boolean {
|
||||
return features.maxWorkspacesPerOrg !== 1;
|
||||
}
|
||||
|
||||
export const FREE_PERSONAL_PLAN = 'starter';
|
||||
|
||||
export const PERSONAL_LEGACY_PLAN = 'starter';
|
||||
export const PERSONAL_FREE_PLAN = 'personalFree';
|
||||
export const TEAM_FREE_PLAN = 'teamFree';
|
||||
export const TEAM_PLAN = 'team';
|
||||
|
||||
export const displayPlanName: { [key: string]: string } = {
|
||||
[PERSONAL_LEGACY_PLAN]: 'Free Personal (Legacy)',
|
||||
[PERSONAL_FREE_PLAN]: 'Free Personal',
|
||||
[TEAM_FREE_PLAN]: 'Team Free',
|
||||
[TEAM_PLAN]: 'Team'
|
||||
} as const;
|
||||
|
||||
// Returns true if `product` is free.
|
||||
export function isFreeProduct(product: Product): boolean {
|
||||
return [FREE_PERSONAL_PLAN, TEAM_FREE_PLAN, 'Free'].includes(product?.name);
|
||||
// Returns true if `planName` is for a personal product.
|
||||
export function isPersonalPlan(planName: string): boolean {
|
||||
return isFreePersonalPlan(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a free personal product.
|
||||
export function isFreePersonalPlan(planName: string): boolean {
|
||||
return [PERSONAL_LEGACY_PLAN, PERSONAL_FREE_PLAN].includes(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a legacy product.
|
||||
export function isLegacyPlan(planName: string): boolean {
|
||||
return isFreeLegacyPlan(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a free legacy product.
|
||||
export function isFreeLegacyPlan(planName: string): boolean {
|
||||
return [PERSONAL_LEGACY_PLAN].includes(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a team product.
|
||||
export function isTeamPlan(planName: string): boolean {
|
||||
return !isPersonalPlan(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a free team product.
|
||||
export function isFreeTeamPlan(planName: string): boolean {
|
||||
return [TEAM_FREE_PLAN].includes(planName);
|
||||
}
|
||||
|
||||
// Returns true if `planName` is for a free product.
|
||||
export function isFreePlan(planName: string): boolean {
|
||||
return (
|
||||
isFreePersonalPlan(planName) ||
|
||||
isFreeTeamPlan(planName) ||
|
||||
isFreeLegacyPlan(planName) ||
|
||||
planName === 'Free'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isTeamPlan, Product } from 'app/common/Features';
|
||||
import { normalizeEmail } from 'app/common/emails';
|
||||
import { Features } from 'app/common/Features';
|
||||
import { PermissionData, PermissionDelta } from 'app/common/UserAPI';
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,9 @@ export interface ShareAnnotations {
|
||||
* current shares in place.
|
||||
*/
|
||||
export class ShareAnnotator {
|
||||
constructor(private _features: Features, private _state: PermissionData) {
|
||||
private _features = this._product?.features ?? {};
|
||||
|
||||
constructor(private _product: Product|null, private _state: PermissionData) {
|
||||
}
|
||||
|
||||
public updateState(state: PermissionData) {
|
||||
@@ -43,7 +45,7 @@ export class ShareAnnotator {
|
||||
public annotateChanges(change: PermissionDelta): ShareAnnotations {
|
||||
const features = this._features;
|
||||
const annotations: ShareAnnotations = {
|
||||
hasTeam: features.maxWorkspacesPerOrg !== 1,
|
||||
hasTeam: !this._product || isTeamPlan(this._product.name),
|
||||
users: new Map(),
|
||||
};
|
||||
if (features.maxSharesPerDocPerRole || features.maxSharesPerWorkspace) {
|
||||
|
||||
@@ -539,6 +539,9 @@ export interface GristLoadConfig {
|
||||
|
||||
// String to append to the end of the HTML document.title
|
||||
pageTitleSuffix?: string;
|
||||
|
||||
// TODO: can be removed once new deal is released.
|
||||
newDeal?: boolean;
|
||||
}
|
||||
|
||||
export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts");
|
||||
|
||||
Reference in New Issue
Block a user