-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated at 2024-06-17T14:31:43-04:00
- Loading branch information
Showing
7 changed files
with
97 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GristDeploymentType } from "app/common/gristUrls"; | ||
import { getGristConfig } from "app/common/urlUtils"; | ||
|
||
const enterpriseDeploymentTypes: GristDeploymentType[] = ['saas', 'enterprise']; | ||
export function isEnterpriseDeployment(): boolean { | ||
return enterpriseDeploymentTypes.includes(getGristConfig().deploymentType ?? 'core'); | ||
} | ||
|
||
/** | ||
* Calls one of the provided callbacks at call time, based on the edition of grist that's running. | ||
* @param enterpriseCallback - Called when an enterprise deployment type is used. | ||
* @param nonEnterpriseCallback - Called for non-enterprise deployment types (e.g. core, desktop). | ||
*/ | ||
export function createEnterpriseSpecificFunc<P extends any[], R>( | ||
enterpriseCallback: (...args: P) => R, | ||
nonEnterpriseCallback: (...args: P) => R | ||
) | ||
{ | ||
return function callCorrectCallback(...args: P): R { | ||
return isEnterpriseDeployment() ? enterpriseCallback(...args) : nonEnterpriseCallback(...args); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
import type {AppModel} from 'app/client/models/AppModel'; | ||
import {PlanSelection} from 'app/common/BillingAPI'; | ||
import {commonUrls} from 'app/common/gristUrls'; | ||
import {Disposable, DomArg, DomContents, IDisposableOwner} from 'grainjs'; | ||
import { commonUrls } from 'app/common/gristUrls'; | ||
import {Disposable} from 'grainjs'; | ||
import * as CoreTeamModals from "app/client/ui/CreateTeamModal"; | ||
import {createEnterpriseSpecificFunc} from "app/client/lib/enterpriseDeploymentCheck"; | ||
|
||
export async function buildNewSiteModal(context: Disposable, options: { | ||
appModel: AppModel, | ||
plan?: PlanSelection, | ||
onCreate?: () => void | ||
}) { | ||
window.location.href = commonUrls.plans; | ||
} | ||
export const buildNewSiteModal = CoreTeamModals.buildNewSiteModal; | ||
|
||
export async function buildUpgradeModal(owner: Disposable, options: { | ||
async function buildEnterpriseUpgradeModal(owner: Disposable, options: { | ||
appModel: AppModel, | ||
pickPlan?: PlanSelection, | ||
reason?: 'upgrade' | 'renew', | ||
}) { | ||
window.location.href = commonUrls.plans; | ||
} | ||
|
||
export function showTeamUpgradeConfirmation(owner: Disposable) { | ||
} | ||
export const buildUpgradeModal = createEnterpriseSpecificFunc( | ||
buildEnterpriseUpgradeModal, | ||
CoreTeamModals.buildUpgradeModal, | ||
); | ||
|
||
export interface UpgradeButton { | ||
showUpgradeCard(...args: DomArg<HTMLElement>[]): DomContents; | ||
showUpgradeButton(...args: DomArg<HTMLElement>[]): DomContents; | ||
} | ||
|
||
export function buildUpgradeButton(owner: IDisposableOwner, app: AppModel): UpgradeButton { | ||
return { | ||
showUpgradeCard : () => null, | ||
showUpgradeButton : () => null, | ||
}; | ||
} | ||
export const buildUpgradeButton = CoreTeamModals.buildUpgradeButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters