(core) Allowing installation admins to manage billing.

Summary:
Permissions for admin billing endpoints were changed

- Support user can't use admin subscription endpoints
- Installation admin (as support user) can see billing details on any site
- Installation admin (unlike support user) can replace subscription (or attach payment) on any site, regardless permissions

Installation admin is any user that belongs to a special `admin` org. If `admin` org is not defined, it defaults to
support user. In that case, with this diff, the support user receives admin's permissions, and now can replace subscription on
any site (without being billing manager).

Test Plan: Added new test

Reviewers: dsagal, paulfitz

Reviewed By: dsagal, paulfitz

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D4338
This commit is contained in:
Jarosław Sadziński
2024-09-11 22:25:32 +02:00
parent 1d2cf3de49
commit 14718120bd
5 changed files with 31 additions and 18 deletions

View File

@@ -196,13 +196,17 @@ export class AccountWidget extends Disposable {
if (deploymentType !== 'saas') { return null; }
const {currentValidUser, currentOrg, isTeamSite} = this._appModel;
const isBillingManager = Boolean(currentOrg && currentOrg.billingAccount &&
(currentOrg.billingAccount.isManager || currentValidUser?.isSupport));
const canViewBillingPage = Boolean(
currentOrg && // have accecc to org
currentOrg.billingAccount && // have access to billing account
(currentOrg.billingAccount.isManager // is billing manager
|| currentValidUser?.isSupport // or support
|| this._appModel.isInstallAdmin())); // or install admin
return isTeamSite ?
// For links, disabling with just a class is hard; easier to just not make it a link.
// TODO weasel menus should support disabling menuItemLink.
(isBillingManager ?
(canViewBillingPage ?
menuItemLink(urlState().setLinkUrl({billing: 'billing'}), t('Billing Account')) :
menuItem(() => null, t('Billing Account'), dom.cls('disabled', true))
) :