mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: function creation button is created
This commit is contained in:
1 parent
b15aec84de
commit
f3f9345fd3
5 files changed
+49
-19
No files matched your search
@@ -4,7 +4,7 @@
|
||||
getServiceLimit,
|
||||
type PlanServices,
|
||||
showUsageRatesModal,
|
||||
type Tier
|
||||
checkForUsageFees
|
||||
} from '$lib/stores/billing';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { Alert, DropList, Heading } from '$lib/components';
|
||||
@@ -47,22 +47,6 @@
|
||||
onMount(() => {
|
||||
dispatch('data', { isButtonDisabled, limit, tier });
|
||||
});
|
||||
|
||||
function checkForUsageFees(plan: Tier, id: PlanServices) {
|
||||
if (plan === 'tier-1' || plan === 'tier-2') {
|
||||
switch (id) {
|
||||
case 'bandwidth':
|
||||
case 'storage':
|
||||
case 'users':
|
||||
case 'executions':
|
||||
case 'realtime':
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if isCloud && showAlert && total && limit !== 0 && total >= limit}
|
||||
|
||||
@@ -109,3 +109,26 @@ export const tierScale: TierData = {
|
||||
};
|
||||
|
||||
export const showUsageRatesModal = writable<boolean>(false);
|
||||
|
||||
export function checkForUsageFees(plan: Tier, id: PlanServices) {
|
||||
if (plan === 'tier-1' || plan === 'tier-2') {
|
||||
switch (id) {
|
||||
case 'bandwidth':
|
||||
case 'storage':
|
||||
case 'users':
|
||||
case 'executions':
|
||||
case 'realtime':
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
|
||||
export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: number) {
|
||||
const limit = getServiceLimit(serviceId) || Infinity;
|
||||
const isLimited = limit !== 0 && limit < Infinity;
|
||||
const hasUsageFees = checkForUsageFees(plan, serviceId);
|
||||
return isLimited && total >= limit && !hasUsageFees;
|
||||
}
|
||||
@@ -15,3 +15,5 @@ export const baseRuntimesList = derived(runtimesList, async ($runtimesList) => {
|
||||
}
|
||||
return { runtimes: [...baseRuntimes.values()] };
|
||||
});
|
||||
|
||||
export const functionsList = derived(page, ($page) => $page.data?.projects as Models.FunctionList);
|
||||
@@ -14,8 +14,11 @@
|
||||
import { Button, InputSearch } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { isServiceLimited } from '$lib/stores/billing';
|
||||
import type { Runtime } from '$lib/stores/marketplace.js';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { connectTemplate } from '$lib/wizards/functions/cover.svelte';
|
||||
import { functionsList } from '../store.js';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -83,6 +86,12 @@
|
||||
target.searchParams.delete('page');
|
||||
goto(target.toString(), { keepFocus: true });
|
||||
}
|
||||
|
||||
$: buttonDisabled = isServiceLimited(
|
||||
'functions',
|
||||
$organization?.billingPlan,
|
||||
$functionsList?.total ?? 0
|
||||
);
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -218,7 +227,10 @@
|
||||
<span class="text">View details</span>
|
||||
</Button>
|
||||
|
||||
<Button secondary on:click={() => connectTemplate(template)}>
|
||||
<Button
|
||||
disabled={buttonDisabled}
|
||||
secondary
|
||||
on:click={() => connectTemplate(template)}>
|
||||
<span class="text">Create function</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
+10
-1
@@ -10,8 +10,17 @@
|
||||
import { consoleVariables } from '$routes/console/store';
|
||||
import { template } from './store';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { isServiceLimited } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { functionsList } from '../../store';
|
||||
|
||||
const isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
|
||||
|
||||
$: buttonDisabled = isServiceLimited(
|
||||
'functions',
|
||||
$organization?.billingPlan,
|
||||
$functionsList?.total ?? 0
|
||||
);
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -91,7 +100,7 @@
|
||||
<span class="icon-external-link" />
|
||||
</Button>
|
||||
<Button
|
||||
disabled={isSelfHosted && !isVcsEnabled}
|
||||
disabled={buttonDisabled || (isSelfHosted && !isVcsEnabled)}
|
||||
on:click={() => connectTemplate($template)}>
|
||||
Create function
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user