mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: add too many free org header alert, fix redirection url when org is deleted
This commit is contained in:
1 parent
05b417a9d5
commit
ecb024dc21
5 files changed
+48
-29
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
// import { base } from '$app/paths';
|
||||
// import { Button } from '$lib/elements/forms';
|
||||
import { HeaderAlert } from '$lib/layout';
|
||||
import { failedInvoice } from '$lib/stores/billing';
|
||||
</script>
|
||||
|
||||
{#if $failedInvoice}
|
||||
<HeaderAlert title="You are limited to one free organization per account">
|
||||
<svelte:fragment>
|
||||
All but one organization will be automatically upgraded to a Pro plan on <b
|
||||
>01 Feb 2024</b
|
||||
>. You can add a payment method or transfer projects from your settings.
|
||||
</svelte:fragment>
|
||||
<!-- <svelte:fragment slot="buttons">
|
||||
<Button
|
||||
href={`${base}/console/organization-${$failedInvoice?.teamId}/billing#paymentMethods`}
|
||||
secondary
|
||||
fullWidthMobile>
|
||||
<span class="text">Update billing details</span>
|
||||
</Button>
|
||||
</svelte:fragment> -->
|
||||
</HeaderAlert>
|
||||
{/if}
|
||||
@@ -22,7 +22,7 @@ function createHeaderAlertStore() {
|
||||
set,
|
||||
add: (component: HeaderAlert) => {
|
||||
update((n) => {
|
||||
if (n.components.find((c) => c.id === component.id)) return n;
|
||||
if (n.components.some((c) => c.id === component.id)) return n;
|
||||
else {
|
||||
n.components.push(component);
|
||||
n.components = n.components;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { INTERVAL } from '$lib/constants';
|
||||
import { HeaderAlert, Logs } from '$lib/layout';
|
||||
import { Logs } from '$lib/layout';
|
||||
import Footer from '$lib/layout/footer.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import SideNavigation from '$lib/layout/navigation.svelte';
|
||||
@@ -46,6 +46,7 @@
|
||||
import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte';
|
||||
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
|
||||
import PostReleaseModal from './(billing-modal)/postReleaseModal.svelte';
|
||||
import TooManyFreOrgs from '$lib/components/billing/alerts/tooManyFreOrgs.svelte';
|
||||
|
||||
function kebabToSentenceCase(str: string) {
|
||||
return str
|
||||
@@ -245,8 +246,11 @@
|
||||
let selectedHeaderAlert = headerAlert.get();
|
||||
onMount(async () => {
|
||||
loading.set(false);
|
||||
if (isCloud && !$page.url.pathname.includes('/console/onboarding')) {
|
||||
checkForPreReleaseProModal();
|
||||
if (isCloud) {
|
||||
checkForFreeOrgOverflow();
|
||||
if (!$page.url.pathname.includes('/console/onboarding')) {
|
||||
checkForPreReleaseProModal();
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
@@ -283,7 +287,7 @@
|
||||
if (orgs.total > 1) {
|
||||
headerAlert.add({
|
||||
id: 'freeOrgOverflow',
|
||||
component: ExcesLimitModal,
|
||||
component: TooManyFreOrgs,
|
||||
show: true,
|
||||
importance: 10
|
||||
});
|
||||
@@ -314,7 +318,6 @@
|
||||
});
|
||||
}
|
||||
checkPaymentAuthorizationRequired();
|
||||
selectedHeaderAlert = headerAlert.get();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -449,7 +452,6 @@
|
||||
$actionRequiredInvoices = await sdk.forConsole.billing.listInvoices($organization.$id, [
|
||||
Query.equal('status', 'requires_authentication')
|
||||
]);
|
||||
console.log($actionRequiredInvoices);
|
||||
if ($actionRequiredInvoices && $actionRequiredInvoices.total) {
|
||||
headerAlert.add({
|
||||
id: 'paymentAuthRequired',
|
||||
@@ -457,7 +459,6 @@
|
||||
show: true,
|
||||
importance: 8
|
||||
});
|
||||
console.log($headerAlert);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,15 +493,6 @@
|
||||
{#if selectedHeaderAlert?.show}
|
||||
<svelte:component this={selectedHeaderAlert.component} />
|
||||
{/if}
|
||||
|
||||
{#if $organization?.markedForDeletion && !$page.url.pathname.includes('/console/account')}
|
||||
<HeaderAlert title="Organization flagged for deletion">
|
||||
<svelte:fragment>
|
||||
All existing projects in the {$organization.name} organization have been paused.
|
||||
This organization will be deleted once your upcoming invoice is processed successfully.
|
||||
</svelte:fragment>
|
||||
</HeaderAlert>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<Header slot="header" />
|
||||
<SideNavigation slot="side" bind:isOpen />
|
||||
|
||||
@@ -24,19 +24,27 @@
|
||||
} else {
|
||||
await sdk.forConsole.teams.delete($organization.$id);
|
||||
}
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$organization.name} has been flagged for deletion`
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
trackEvent(Submit.OrganizationDelete);
|
||||
if ($organizationList?.total > 1) {
|
||||
goto(`${base}/console/`);
|
||||
const account = await sdk.forConsole.account.get();
|
||||
const teamId =
|
||||
account.prefs.organization ??
|
||||
$organizationList.teams[0].$id === $organization.$id
|
||||
? $organizationList.teams[1].$id
|
||||
: $organizationList.teams[0].$id;
|
||||
|
||||
await goto(`${base}/console/organization-${teamId}`);
|
||||
} else {
|
||||
goto(`${base}/console/onboarding`);
|
||||
await goto(`${base}/console/onboarding`);
|
||||
}
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$organization.name} has been flagged for deletion`
|
||||
});
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.OrganizationDelete);
|
||||
|
||||
+1
-6
@@ -1,10 +1,5 @@
|
||||
import { page } from '$app/stores';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const loading = writable(true);
|
||||
|
||||
export const organizations = derived(page, ($page) => {
|
||||
return $page.data.organizations as Models.TeamList<Models.Preferences>;
|
||||
});
|
||||
export const requestedMigration = writable<Record<string, string> | null>(null);
|
||||
Reference in new issue
Block a user