mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
improve fix: disable project creation
This commit is contained in:
@@ -138,6 +138,7 @@ export type PlanServices =
|
||||
| 'logs'
|
||||
| 'memberAddon'
|
||||
| 'members'
|
||||
| 'projects'
|
||||
| 'platforms'
|
||||
| 'realtime'
|
||||
| 'realtimeAddon'
|
||||
@@ -156,7 +157,7 @@ export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan
|
||||
if (!serviceId) return 0;
|
||||
|
||||
plan ??= get(currentPlan);
|
||||
|
||||
|
||||
if (tier) {
|
||||
const info = get(plansInfo);
|
||||
if (!info) return 0;
|
||||
@@ -164,10 +165,15 @@ export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan
|
||||
}
|
||||
|
||||
if (serviceId === 'members') {
|
||||
if (!(plan.addons.seats?.supported ?? false)) return Infinity;
|
||||
if (!plan.addons.seats) return Infinity;
|
||||
return plan.addons.seats?.limit ?? 1;
|
||||
}
|
||||
|
||||
if (serviceId === 'projects') {
|
||||
if (!plan.addons.seats) return Infinity;
|
||||
return plan.addons.projects?.limit ?? 1;
|
||||
}
|
||||
|
||||
return plan?.[serviceId] ?? 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
} from '$lib/components';
|
||||
import { trackEvent, Click } from '$lib/actions/analytics';
|
||||
import { type Models } from '@appwrite.io/console';
|
||||
import { readOnly, upgradeURL } from '$lib/stores/billing';
|
||||
import { getServiceLimit, readOnly, upgradeURL } from '$lib/stores/billing';
|
||||
import { onMount, type ComponentType } from 'svelte';
|
||||
import { canWriteProjects } from '$lib/stores/roles';
|
||||
import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect';
|
||||
@@ -79,6 +79,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: projectCreationDisabled =
|
||||
(isCloud && getServiceLimit('projects') <= data.allProjectsCount) ||
|
||||
($readOnly && !GRACE_PERIOD_OVERRIDE) ||
|
||||
!$canWriteProjects;
|
||||
|
||||
$: $registerCommands([
|
||||
{
|
||||
label: 'Create project',
|
||||
@@ -86,7 +91,7 @@
|
||||
showCreate = true;
|
||||
},
|
||||
keys: ['c'],
|
||||
disabled: ($readOnly && !GRACE_PERIOD_OVERRIDE) || !$canWriteProjects,
|
||||
disabled: projectCreationDisabled,
|
||||
group: 'projects',
|
||||
icon: IconPlus
|
||||
}
|
||||
@@ -125,7 +130,7 @@
|
||||
<Button
|
||||
on:click={handleCreateProject}
|
||||
event="create_project"
|
||||
disabled={$readOnly && !GRACE_PERIOD_OVERRIDE}>
|
||||
disabled={projectCreationDisabled}>
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create project
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user