Rename plan->tier, topics->reservations, more tests, more todos
This commit is contained in:
parent
df512d0ba2
commit
1f54adad71
14 changed files with 298 additions and 134 deletions
|
@ -178,13 +178,13 @@
|
|||
"account_usage_of_limit": "of {{limit}}",
|
||||
"account_usage_unlimited": "Unlimited",
|
||||
"account_usage_limits_reset_daily": "Usage limits are reset daily at midnight (UTC)",
|
||||
"account_usage_plan_title": "Account type",
|
||||
"account_usage_plan_code_default": "Default",
|
||||
"account_usage_plan_code_unlimited": "Unlimited",
|
||||
"account_usage_plan_code_none": "None",
|
||||
"account_usage_plan_code_pro": "Pro",
|
||||
"account_usage_plan_code_business": "Business",
|
||||
"account_usage_plan_code_business_plus": "Business Plus",
|
||||
"account_usage_tier_title": "Account type",
|
||||
"account_usage_tier_code_default": "Default",
|
||||
"account_usage_tier_code_unlimited": "Unlimited",
|
||||
"account_usage_tier_code_none": "None",
|
||||
"account_usage_tier_code_pro": "Pro",
|
||||
"account_usage_tier_code_business": "Business",
|
||||
"account_usage_tier_code_business_plus": "Business Plus",
|
||||
"account_usage_messages_title": "Published messages",
|
||||
"account_usage_emails_title": "Emails sent",
|
||||
"account_usage_topics_title": "Reserved topics",
|
||||
|
|
|
@ -169,7 +169,7 @@ const Stats = () => {
|
|||
if (!account) {
|
||||
return <></>;
|
||||
}
|
||||
const planCode = account.plan.code ?? "none";
|
||||
const tierCode = account.tier.code ?? "none";
|
||||
const normalize = (value, max) => Math.min(value / max * 100, 100);
|
||||
const barColor = (remaining, limit) => {
|
||||
if (account.role === "admin") {
|
||||
|
@ -186,12 +186,12 @@ const Stats = () => {
|
|||
{t("account_usage_title")}
|
||||
</Typography>
|
||||
<PrefGroup>
|
||||
<Pref title={t("account_usage_plan_title")}>
|
||||
<Pref title={t("account_usage_tier_title")}>
|
||||
<div>
|
||||
{account.role === "admin"
|
||||
? <>{t("account_usage_unlimited")} <Tooltip title={t("account_basics_username_admin_tooltip")}><span style={{cursor: "default"}}>👑</span></Tooltip></>
|
||||
: t(`account_usage_plan_code_${planCode}`)}
|
||||
{config.enable_payments && account.plan.upgradeable &&
|
||||
: t(`account_usage_tier_code_${tierCode}`)}
|
||||
{config.enable_payments && account.tier.upgradeable &&
|
||||
<em>{" "}
|
||||
<Link onClick={() => {}}>Upgrade</Link>
|
||||
</em>
|
||||
|
@ -199,20 +199,20 @@ const Stats = () => {
|
|||
</div>
|
||||
</Pref>
|
||||
<Pref title={t("account_usage_topics_title")}>
|
||||
{account.limits.topics > 0 &&
|
||||
{account.limits.reservations > 0 &&
|
||||
<>
|
||||
<div>
|
||||
<Typography variant="body2" sx={{float: "left"}}>{account.stats.topics}</Typography>
|
||||
<Typography variant="body2" sx={{float: "right"}}>{account.role === "user" ? t("account_usage_of_limit", { limit: account.limits.topics }) : t("account_usage_unlimited")}</Typography>
|
||||
<Typography variant="body2" sx={{float: "left"}}>{account.stats.reservations}</Typography>
|
||||
<Typography variant="body2" sx={{float: "right"}}>{account.role === "user" ? t("account_usage_of_limit", { limit: account.limits.reservations }) : t("account_usage_unlimited")}</Typography>
|
||||
</div>
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={account.limits.topics > 0 ? normalize(account.stats.topics, account.limits.topics) : 100}
|
||||
color={barColor(account.stats.topics_remaining, account.limits.topics)}
|
||||
value={account.limits.reservations > 0 ? normalize(account.stats.reservations, account.limits.reservations) : 100}
|
||||
color={barColor(account.stats.reservations_remaining, account.limits.reservations)}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
{account.limits.topics === 0 &&
|
||||
{account.limits.reservations === 0 &&
|
||||
<em>No reserved topics for this account</em>
|
||||
}
|
||||
</Pref>
|
||||
|
|
|
@ -99,7 +99,7 @@ const NavList = (props) => {
|
|||
navigate(routes.account);
|
||||
};
|
||||
|
||||
const showUpgradeBanner = config.enable_payments && (!props.account || props.account.plan.upgradeable);
|
||||
const showUpgradeBanner = config.enable_payments && (!props.account || props.account.tier.upgradeable);
|
||||
const showSubscriptionsList = props.subscriptions?.length > 0;
|
||||
const showNotificationBrowserNotSupportedBox = !notifier.browserSupported();
|
||||
const showNotificationContextNotSupportedBox = notifier.browserSupported() && !notifier.contextSupported(); // Only show if notifications are generally supported in the browser
|
||||
|
|
|
@ -489,7 +489,7 @@ const Reservations = () => {
|
|||
return <></>;
|
||||
}
|
||||
const reservations = account.reservations || [];
|
||||
const limitReached = account.role === "user" && account.stats.topics_remaining === 0;
|
||||
const limitReached = account.role === "user" && account.stats.reservations_remaining === 0;
|
||||
|
||||
const handleAddClick = () => {
|
||||
setDialogKey(prev => prev+1);
|
||||
|
|
|
@ -87,7 +87,7 @@ const SubscribePage = (props) => {
|
|||
const existingBaseUrls = Array
|
||||
.from(new Set([publicBaseUrl, ...props.subscriptions.map(s => s.baseUrl)]))
|
||||
.filter(s => s !== config.base_url);
|
||||
//const reserveTopicEnabled = session.exists() && (account?.stats.topics_remaining || 0) > 0;
|
||||
//const reserveTopicEnabled = session.exists() && (account?.stats.reservations_remaining || 0) > 0;
|
||||
|
||||
const handleSubscribe = async () => {
|
||||
const user = await userManager.get(baseUrl); // May be undefined
|
||||
|
@ -184,7 +184,7 @@ const SubscribePage = (props) => {
|
|||
control={
|
||||
<Checkbox
|
||||
fullWidth
|
||||
// disabled={account.stats.topics_remaining}
|
||||
// disabled={account.stats.reservations_remaining}
|
||||
checked={reserveTopicVisible}
|
||||
onChange={(ev) => setReserveTopicVisible(ev.target.checked)}
|
||||
inputProps={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue