feat: add status

This commit is contained in:
Arman committed 2023-12-10 11:56:10 +01:00
1 parent 5f3241f431
commit 6a3396709a
12 files changed
+93 -39

No files matched your search

+2 -1
View File
@@ -68,7 +68,8 @@
width="250"
height="30"
frameborder="0"
scrolling="no"></iframe>
scrolling="no">
</iframe>
</div>
</div>
+39
View File
@@ -0,0 +1,39 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
import { Button } from '$lib/elements/forms';
import { tierToPlan } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
export let title: string;
export let tooltipContent =
$organization.billingPlan === 'tier-0'
? `Upgrade to add more ${title.toLocaleLowerCase()}`
: `You've reached the ${title.toLocaleLowerCase()} limit for the ${
tierToPlan($organization.billingPlan).name
} plan`;
export let disabled: boolean;
export let buttonText: string;
export let buttonMethod: () => void | Promise<void>;
export let buttonEvent: string = buttonText?.toLocaleLowerCase();
export let icon = 'plus';
export let showIcon = true;
export let buttonType: 'primary' | 'secondary' | 'text' = 'primary';
</script>
<div
use:tooltip={{
content: tooltipContent,
disabled: !disabled
}}>
<Button
text={buttonType === 'text'}
secondary={buttonType === 'secondary'}
on:click={buttonMethod}
event={buttonEvent}
{disabled}>
{#if showIcon}
<span class={`icon-${icon}`} aria-hidden="true" />
{/if}
<span class="text">{buttonText}</span>
</Button>
</div>
+8 -16
View File
@@ -6,7 +6,6 @@
showUsageRatesModal,
checkForUsageFees
} from '$lib/stores/billing';
import { tooltip } from '$lib/actions/tooltip';
import { Alert, DropList, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import { organization } from '$lib/stores/organization';
@@ -14,7 +13,7 @@
import { createEventDispatcher, onMount } from 'svelte';
import { wizard } from '$lib/stores/wizard';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { Button } from '$lib/elements/forms';
import { ContainerButton } from '.';
export let isFlex = true;
export let title: string;
@@ -26,7 +25,7 @@
export let showAlert = true;
export let buttonText: string = null;
export let buttonMethod: () => void = null;
export let buttonMethod: () => void | Promise<void> = null;
export let buttonEvent: string = buttonText?.toLocaleLowerCase();
export let buttonDisabled = false;
@@ -120,19 +119,12 @@
<slot {isButtonDisabled}>
{#if buttonText}
<div
use:tooltip={{
content:
$organization.billingPlan === 'tier-0'
? `Upgrade to add more ${title.toLocaleLowerCase()}`
: `You've reached the ${title.toLocaleLowerCase()} limit for the ${tier} plan`,
disabled: !isButtonDisabled
}}>
<Button on:click={buttonMethod} event={buttonEvent} disabled={isButtonDisabled}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">{buttonText}</span>
</Button>
</div>
<ContainerButton
{title}
disabled={isButtonDisabled}
{buttonText}
{buttonEvent}
{buttonMethod} />
{/if}
</slot>
</header>
+1
View File
@@ -18,3 +18,4 @@ export { default as Progress } from './progress.svelte';
export { default as GridHeader } from './gridHeader.svelte';
export { default as ContainerHeader } from './containerHeader.svelte';
export { default as HeaderAlert } from './headerAlert.svelte';
export { default as ContainerButton } from './containerButton.svelte';
+2
View File
@@ -127,8 +127,10 @@ export function checkForUsageFees(plan: Tier, id: PlanServices) {
}
export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: number) {
if (!total) return false;
const limit = getServiceLimit(serviceId) || Infinity;
const isLimited = limit !== 0 && limit < Infinity;
const hasUsageFees = checkForUsageFees(plan, serviceId);
console.log(serviceId, plan, total, limit, isLimited, hasUsageFees);
return isLimited && total >= limit && !hasUsageFees;
}
-2
View File
@@ -476,8 +476,6 @@
afterUpdate(() => {
selectedHeaderAlert = headerAlert.get();
});
$: console.log(selectedHeaderAlert);
</script>
<CommandCenter />
@@ -16,6 +16,9 @@
template as templateStore
} from '$lib/wizards/functions/store.js';
import { marketplace } from '$lib/stores/marketplace.js';
import { functionsList } from './store';
import { organization } from '$lib/stores/organization';
import { isServiceLimited } from '$lib/stores/billing';
export let data;
@@ -54,13 +57,17 @@
label: 'Create function',
callback: openWizard,
keys: ['c'],
disabled: $wizard.show,
disabled:
$wizard.show ||
isServiceLimited('functions', $organization?.billingPlan, $functionsList?.total),
icon: 'plus',
group: 'functions'
}
]);
$updateCommandGroupRanks({ functions: 1000 });
$: console.log($functionsList);
</script>
<Container>
@@ -16,4 +16,4 @@ export const baseRuntimesList = derived(runtimesList, async ($runtimesList) => {
return { runtimes: [...baseRuntimes.values()] };
});
export const functionsList = derived(page, ($page) => $page.data?.projects as Models.FunctionList);
export const functionsList = derived(page, ($page) => $page.data.functions as Models.FunctionList);
@@ -12,13 +12,13 @@
SvgIcon
} from '$lib/components';
import { Button, InputSearch } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { Container, ContainerButton } 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';
import { functionsList } from '../store';
export let data;
@@ -227,12 +227,14 @@
<span class="text">View details</span>
</Button>
<Button
<ContainerButton
title="functions"
disabled={buttonDisabled}
secondary
on:click={() => connectTemplate(template)}>
<span class="text">Create function</span>
</Button>
buttonType="secondary"
buttonMethod={() => connectTemplate(template)}
showIcon={false}
buttonText="Create function"
buttonEvent="create_function" />
</div>
</article>
</li>
@@ -1,9 +1,12 @@
import { CARD_LIMIT } from '$lib/constants';
import { CARD_LIMIT, Dependencies } from '$lib/constants';
import { getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
import { marketplace } from '$lib/stores/marketplace';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, route }) => {
export const load: PageLoad = async ({ url, route, depends }) => {
depends(Dependencies.FUNCTIONS);
const limit = CARD_LIMIT;
const page = getPage(url);
const search = getSearch(url);
@@ -52,6 +55,7 @@ export const load: PageLoad = async ({ url, route }) => {
runtimes,
useCases,
sum: templates.length,
templates: templates.splice(((page === 0 ? 1 : page) - 1) * limit, limit)
templates: templates.splice(((page === 0 ? 1 : page) - 1) * limit, limit),
functions: await sdk.forProject.functions.list()
};
};
@@ -2,7 +2,7 @@
import { Alert, Card, Collapsible, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { Container, ContainerButton } from '$lib/layout';
import { isSelfHosted } from '$lib/system';
import AppwriteLogoDark from '$lib/images/appwrite-logo-dark.svg';
import AppwriteLogoLight from '$lib/images/appwrite-logo-light.svg';
@@ -19,7 +19,7 @@
$: buttonDisabled = isServiceLimited(
'functions',
$organization?.billingPlan,
$functionsList?.total ?? 0
$functionsList?.total
);
</script>
@@ -99,11 +99,14 @@
View source
<span class="icon-external-link" />
</Button>
<Button
<ContainerButton
title="functions"
disabled={buttonDisabled || (isSelfHosted && !isVcsEnabled)}
on:click={() => connectTemplate($template)}>
Create function
</Button>
buttonMethod={() => connectTemplate($template)}
showIcon={false}
buttonText="Create function"
buttonEvent="create_function" />
</div>
</Card>
</section>
@@ -1,8 +1,13 @@
import { Dependencies } from '$lib/constants';
import { marketplace } from '$lib/stores/marketplace';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
export const load: PageLoad = async ({ params, depends }) => {
depends(Dependencies.FUNCTIONS);
return {
template: marketplace.find((template) => template.id === params.template)
template: marketplace.find((template) => template.id === params.template),
functions: await sdk.forProject.functions.list()
};
};