mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #862 from appwrite/update-migration-consts
Update 'envVar' to 'environment variable' for migrations and remove Firebase OAuth stuff
This commit is contained in:
+19
-17
@@ -35,21 +35,23 @@ export const createMigrationFormStore = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const resources = [
|
||||
'user',
|
||||
'team',
|
||||
'membership',
|
||||
'file',
|
||||
'bucket',
|
||||
'function',
|
||||
'envVar',
|
||||
'deployment',
|
||||
'database',
|
||||
'collection',
|
||||
'index',
|
||||
'attribute',
|
||||
'document'
|
||||
] as const;
|
||||
export const ResourcesFriendly = {
|
||||
user: { singular: 'User', plural: 'Users' },
|
||||
team: { singular: 'Team', plural: 'Teams' },
|
||||
membership: { singular: 'Membership', plural: 'Memberships' },
|
||||
file: { singular: 'File', plural: 'Files' },
|
||||
bucket: { singular: 'Bucket', plural: 'Buckets' },
|
||||
function: { singular: 'Function', plural: 'Functions' },
|
||||
'environment variable': { singular: 'Environment Variable', plural: 'Environment Variables' },
|
||||
deployment: { singular: 'Deployment', plural: 'Deployments' },
|
||||
database: { singular: 'Database', plural: 'Databases' },
|
||||
collection: { singular: 'Collection', plural: 'Collections' },
|
||||
index: { singular: 'Index', plural: 'Indexes' },
|
||||
attribute: { singular: 'Attribute', plural: 'Attributes' },
|
||||
document: { singular: 'Document', plural: 'Documents' }
|
||||
};
|
||||
|
||||
const resources = Object.keys(ResourcesFriendly);
|
||||
|
||||
type Resource = (typeof resources)[number];
|
||||
|
||||
@@ -101,7 +103,7 @@ export const migrationFormToResources = (
|
||||
addResource('function');
|
||||
}
|
||||
if (formData.functions.env) {
|
||||
addResource('envVar');
|
||||
addResource('environment variable');
|
||||
}
|
||||
if (formData.functions.inactive) {
|
||||
addResource('deployment');
|
||||
@@ -155,7 +157,7 @@ export const resourcesToMigrationForm = (
|
||||
if (resources.includes('function') && isVersionAtLeast(version, '1.4.0')) {
|
||||
formData.functions.root = true;
|
||||
}
|
||||
if (resources.includes('envVar') && isVersionAtLeast(version, '1.4.0')) {
|
||||
if (resources.includes('environment variable') && isVersionAtLeast(version, '1.4.0')) {
|
||||
formData.functions.env = true;
|
||||
}
|
||||
if (resources.includes('deployment') && isVersionAtLeast(version, '1.4.0')) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { deepMap } from '$lib/helpers/object';
|
||||
import type { WritableValue } from '$lib/helpers/types';
|
||||
import { sdk, type getSdkForProject } from '$lib/stores/sdk';
|
||||
import { type getSdkForProject } from '$lib/stores/sdk';
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
@@ -107,19 +107,10 @@
|
||||
);
|
||||
break;
|
||||
case 'firebase':
|
||||
if ($provider.projectId) {
|
||||
// OAuth
|
||||
report = await sdk.forProject.migrations.getFirebaseReportOAuth(
|
||||
providerResources.firebase,
|
||||
$provider.projectId
|
||||
);
|
||||
} else if ($provider.serviceAccount) {
|
||||
// Manual auth
|
||||
report = await projectSdk.migrations.getFirebaseReport(
|
||||
providerResources.firebase,
|
||||
$provider.serviceAccount
|
||||
);
|
||||
}
|
||||
report = await projectSdk.migrations.getFirebaseReport(
|
||||
providerResources.firebase,
|
||||
$provider.serviceAccount
|
||||
);
|
||||
|
||||
break;
|
||||
case 'nhost':
|
||||
@@ -353,7 +344,7 @@
|
||||
<div />
|
||||
<span>Import all functions and their active deployment</span>
|
||||
<ul>
|
||||
{#if resources?.includes('envVar')}
|
||||
{#if resources?.includes('environment variable')}
|
||||
<li class="checkbox-field">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import {
|
||||
FormList,
|
||||
InputNumber,
|
||||
InputPassword,
|
||||
InputSelect,
|
||||
InputText,
|
||||
InputTextarea
|
||||
} from '$lib/elements/forms';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import type { Provider } from '$lib/stores/migration';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { provider } from '.';
|
||||
|
||||
const providers: Record<Provider, string> = {
|
||||
@@ -22,34 +16,6 @@
|
||||
supabase: 'Supabase',
|
||||
nhost: 'NHost'
|
||||
};
|
||||
|
||||
// function connectGoogle() {
|
||||
// const redirect = new URL($page.url);
|
||||
// const target = new URL(
|
||||
// `${sdk.forProject.client.config.endpoint}/migrations/firebase/connect`
|
||||
// );
|
||||
// target.searchParams.set('redirect', redirect.toString());
|
||||
// target.searchParams.set('project', $page.params.project);
|
||||
// target.searchParams.set('mode', 'admin');
|
||||
// return target;
|
||||
// }
|
||||
|
||||
function deauthorizeGoogle() {
|
||||
sdk.forProject.migrations.deleteFirebaseAuth().then(() => {
|
||||
firebaseProjects = [];
|
||||
});
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Signed out of Google successfully'
|
||||
});
|
||||
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
}
|
||||
|
||||
$: firebaseProjects = $page.data.firebaseProjects;
|
||||
|
||||
// let showAuth = false;
|
||||
</script>
|
||||
|
||||
<WizardStep>
|
||||
@@ -102,24 +68,7 @@
|
||||
bind:value={$provider.apiKey} />
|
||||
</FormList>
|
||||
{:else if $provider.provider === 'firebase'}
|
||||
{#if !firebaseProjects?.length}
|
||||
<!-- <div class="box u-flex u-flex-vertical u-gap-16 u-cross-center u-margin-block-start-24">
|
||||
<p class="u-text-center u-bold">Sign in with Google to get started</p>
|
||||
<Button secondary href={connectGoogle().toString()}>
|
||||
<SvgIcon name="google" />Sign in
|
||||
</Button>
|
||||
</div> -->
|
||||
|
||||
<!-- <button
|
||||
class="tag u-margin-block-start-16"
|
||||
type="button"
|
||||
on:click={() => (showAuth = !showAuth)}
|
||||
class:is-selected={showAuth}>
|
||||
<span class="icon-lock-closed" aria-hidden="true" />
|
||||
<span class="text">Manual authentication</span>
|
||||
</button> -->
|
||||
|
||||
<!-- {#if showAuth} -->
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<div class="u-margin-block-start-16">
|
||||
<InputTextarea
|
||||
id="credentials"
|
||||
@@ -128,23 +77,7 @@
|
||||
bind:value={$provider.serviceAccount}
|
||||
placeholder="Enter account credentials" />
|
||||
</div>
|
||||
<!-- {/if} -->
|
||||
{:else}
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<InputSelect
|
||||
id="firebase-project"
|
||||
label="Firebase project"
|
||||
required
|
||||
bind:value={$provider.projectId}
|
||||
options={firebaseProjects.map((project) => ({
|
||||
label: project.displayName,
|
||||
value: project.projectId
|
||||
}))} />
|
||||
</FormList>
|
||||
<p class="u-text-center u-margin-block-start-24">
|
||||
<button class="u-bold" on:click|preventDefault={deauthorizeGoogle}>Sign out</button>
|
||||
</p>
|
||||
{/if}
|
||||
</FormList>
|
||||
{:else if $provider.provider === 'supabase'}
|
||||
<FormList class="u-margin-block-start-24">
|
||||
<p class="body-text-1 u-bold">Postgres credentials</p>
|
||||
|
||||
@@ -49,19 +49,10 @@
|
||||
break;
|
||||
}
|
||||
case 'firebase': {
|
||||
if ($provider.projectId) {
|
||||
// OAuth
|
||||
await sdk.forProject.migrations.createFirebaseOAuthMigration(
|
||||
resources,
|
||||
$provider.projectId
|
||||
);
|
||||
} else if ($provider.serviceAccount) {
|
||||
// Manual auth
|
||||
await sdk.forProject.migrations.createFirebaseMigration(
|
||||
resources,
|
||||
$provider.serviceAccount
|
||||
);
|
||||
}
|
||||
await sdk.forProject.migrations.createFirebaseMigration(
|
||||
resources,
|
||||
$provider.serviceAccount
|
||||
);
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import { Dependencies } from '$lib/constants.js';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
async function getFirebaseProjects() {
|
||||
try {
|
||||
const res = await sdk.forProject.migrations.listFirebaseProjects();
|
||||
return res.projects;
|
||||
} catch (e) {
|
||||
if (e.type === 'user_identity_not_found') {
|
||||
return [];
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function load({ depends }) {
|
||||
depends(Dependencies.MIGRATIONS);
|
||||
|
||||
@@ -21,8 +8,7 @@ export async function load({ depends }) {
|
||||
const { migrations } = await sdk.forProject.migrations.list();
|
||||
|
||||
return {
|
||||
migrations,
|
||||
firebaseProjects: getFirebaseProjects()
|
||||
migrations
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { parseIfString } from '$lib/helpers/object';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { ResourcesFriendly } from '$lib/stores/migration';
|
||||
|
||||
export let migrations: Models.Migration[] = [];
|
||||
export let migrationId: string = null;
|
||||
@@ -106,7 +107,10 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="u-capitalize">{entity + 's'}</span>
|
||||
<span class="u-capitalize"
|
||||
>{total(Object.values(entityCounter)) > 1
|
||||
? ResourcesFriendly[entity].plural
|
||||
: ResourcesFriendly[entity].singular}</span>
|
||||
<span class="inline-tag">{totalItems(entityCounter)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user