mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Redirect to org on studio
This commit is contained in:
+9
-1
@@ -6,11 +6,17 @@ export const enum Mode {
|
||||
SELF_HOSTED = 'self-hosted'
|
||||
}
|
||||
|
||||
export const enum Profile {
|
||||
CONSOLE = 'console',
|
||||
STUDIO = 'studio'
|
||||
}
|
||||
|
||||
export const VARS = {
|
||||
CONSOLE_MODE: (env.PUBLIC_CONSOLE_MODE as Mode) ?? undefined,
|
||||
APPWRITE_ENDPOINT: env.PUBLIC_APPWRITE_ENDPOINT ?? undefined,
|
||||
GROWTH_ENDPOINT: env.PUBLIC_GROWTH_ENDPOINT ?? undefined,
|
||||
PUBLIC_STRIPE_KEY: env.PUBLIC_STRIPE_KEY ?? undefined
|
||||
PUBLIC_STRIPE_KEY: env.PUBLIC_STRIPE_KEY ?? undefined,
|
||||
PROJECT_PROFILE: (env.PUBLIC_PROJECT_PROFILE as Profile) ?? undefined
|
||||
};
|
||||
|
||||
export const ENV = {
|
||||
@@ -21,7 +27,9 @@ export const ENV = {
|
||||
};
|
||||
|
||||
export const MODE = VARS.CONSOLE_MODE === Mode.CLOUD ? Mode.CLOUD : Mode.SELF_HOSTED;
|
||||
export const PROFILE = VARS.PROJECT_PROFILE === Profile.CONSOLE ? Profile.CONSOLE : Profile.STUDIO;
|
||||
export const isCloud = MODE === Mode.CLOUD;
|
||||
export const isStudio = PROFILE === Profile.STUDIO;
|
||||
export const isSelfHosted = MODE !== Mode.CLOUD;
|
||||
export const isDev = ENV.DEV;
|
||||
export const isProd = ENV.PROD;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
export const load: PageLoad = async ({ params, url, route, depends, parent }) => {
|
||||
const { scopes } = await parent();
|
||||
@@ -12,7 +13,7 @@ export const load: PageLoad = async ({ params, url, route, depends, parent }) =>
|
||||
const limit = getLimit(url, route, CARD_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
if (!scopes.includes('projects.read') && scopes.includes('billing.read')) {
|
||||
return redirect(301, `/console/organization-${params.organization}/billing`);
|
||||
return redirect(301, `${base}/organization-${params.organization}/billing`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,12 +5,13 @@ import { sdk } from '$lib/stores/sdk';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
export const load: PageLoad = async ({ parent, depends }) => {
|
||||
const { organization, scopes } = await parent();
|
||||
|
||||
if (!scopes.includes('billing.read')) {
|
||||
return redirect(301, `/console/organization-${organization.$id}`);
|
||||
return redirect(301, `${base}/organization-${organization.$id}`);
|
||||
}
|
||||
depends(Dependencies.PAYMENT_METHODS);
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { OrganizationList } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
export let domain: Domain;
|
||||
export let organizations: OrganizationList;
|
||||
@@ -20,7 +21,7 @@
|
||||
type: 'success',
|
||||
message: 'Domain moved successfully'
|
||||
});
|
||||
await goto(`/console/organization-${selectedOrg}/domains/`);
|
||||
await goto(`${base}/organization-${selectedOrg}/domains/`);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
await invalidate(Dependencies.DOMAINS);
|
||||
} catch (e) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Hey studio!
|
||||
+7
-2
@@ -2,7 +2,7 @@ import { redirect } from '@sveltejs/kit';
|
||||
import { base } from '$app/paths';
|
||||
import type { PageLoad } from './$types';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { VARS } from '$lib/system';
|
||||
import { isStudio, VARS } from '$lib/system';
|
||||
|
||||
const handleGithubEducationMembership = async (name: string, email: string) => {
|
||||
const result = await sdk.forConsole.billing.setMembership('github-student-developer');
|
||||
@@ -39,7 +39,12 @@ export const load: PageLoad = async ({ parent, url }) => {
|
||||
if (!teamId) {
|
||||
redirect(303, `${base}/account/organizations${url.search}`);
|
||||
} else {
|
||||
redirect(303, `${base}/organization-${teamId}${url.search}`);
|
||||
redirect(
|
||||
303,
|
||||
isStudio
|
||||
? `${base}/org-${teamId}${url.search}`
|
||||
: `${base}/organization-${teamId}${url.search}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
redirect(303, `${base}/onboarding/create-project${url.search}`);
|
||||
|
||||
Reference in New Issue
Block a user