Add Permissions and other fixes

This commit is contained in:
Bradley Schofield committed 2023-04-04 20:17:57 +09:00
1 parent 3b9d6430fe
commit 8165a63f58
26 files changed
+445 -191

No files matched your search

+10
View File
@@ -159,6 +159,16 @@ export const scopes: {
description: "Access to execute your project's functions",
category: 'Functions'
},
{
scope: 'transfers.read',
description: "Access to read your project's transfers",
category: 'Transfers'
},
{
scope: 'transfers.write',
description: "Access to create, update, and delete your project's transfers",
category: 'Transfers'
},
{
scope: 'locale.read',
description: "Access to access your project's Locale service",
+10
View File
@@ -59,6 +59,11 @@ function createServices() {
label: 'GraphQL',
method: 'graphql',
value: null
},
{
label: 'Transfers',
method: 'Transfers',
value: null
}
]
});
@@ -117,6 +122,11 @@ function createServices() {
label: 'GraphQL',
method: 'graphql',
value: project.serviceStatusForGraphql
},
{
label: 'Transfers',
method: 'Transfers',
value: project.serviceStatusForTransfers
}
];
set({ list });
@@ -12,6 +12,7 @@
Database = 'Database',
Functions = 'Functions',
Storage = 'Storage',
Transfers = 'Transfers',
Other = 'Other'
}
@@ -87,7 +88,7 @@
</ul>
<Collapsible>
{#each [Category.Auth, Category.Database, Category.Functions, Category.Storage, Category.Other] as category}
{#each [Category.Auth, Category.Database, Category.Functions, Category.Storage, Category.Transfers, Category.Other] as category}
{@const checked = categoryState(category, scopes)}
<CollapsibleItem withIndentation>
<svelte:fragment slot="beforetitle">
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/stores';
import { Button } from '$lib/elements/forms';
import { Empty, CardContainer, Copy, GridItem1, Heading, Pagination } from '$lib/components';
import { Empty, Heading, Pagination } from '$lib/components';
import { Pill } from '$lib/elements';
import { Container } from '$lib/layout';
import { base } from '$app/paths';
@@ -11,11 +11,17 @@
import Create from '../createTransfer.svelte';
import type { PageData } from './$types';
import { CARD_LIMIT } from '$lib/constants';
import {
Table,
TableBody,
TableRowLink,
TableCellHead,
TableCell,
TableHeader
} from '$lib/elements/table';
export let data: PageData;
let offset = 0;
const project = $page.params.project;
function openWizard() {
@@ -36,34 +42,44 @@
</div>
{#if data.transfers.total}
<CardContainer
{offset}
event="transfers"
total={data.transfers.total}
on:click={openWizard}>
{#each data.transfers.transfers as transfer}
<GridItem1
href={`${base}/console/project-${project}/settings/transfers/transfer-${transfer.$id}`}>
<svelte:fragment slot="title">
<div class="u-flex u-gap-16 u-cross-center">
<div class="avatar is-medium">
<img
src={`${base}/icons/${$app.themeInUse}/color/appwrite.svg`}
alt="technology" />
<Table>
<TableHeader>
<TableCellHead>Name</TableCellHead>
<TableCellHead>Providers</TableCellHead>
<TableCellHead>Status</TableCellHead>
</TableHeader>
<TableBody>
{#each data.transfers.transfers as transfer}
<TableRowLink
href={`${base}/console/project-${project}/settings/transfers/transfer-${transfer.$id}`}>
<TableCell title="Name">
<div class="u-flex u-main-space-between">
{transfer.$id}
</div>
<span class="text">{transfer.$id}</span>
</div>
</svelte:fragment>
</TableCell>
<TableCell title="Providers">
<div class="grid-box u-flex">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/supabase.svg`}
alt="technology" />
</div>
<span class="icon-arrow-right" style="align-self: center;" />
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/appwrite.svg`}
alt="technology" />
</div>
</div>
</TableCell>
<TableCell title="Status">
<Pill><span class="u-capitalize">{transfer.status}</span></Pill>
</TableCell>
</TableRowLink>
{/each}
</TableBody>
</Table>
<Copy value={transfer.$id} event="transfer">
<Pill button><i class="icon-duplicate" />Transfer ID</Pill>
</Copy>
</GridItem1>
{/each}
<svelte:fragment slot="empty">
<p>Create a new transfer</p>
</svelte:fragment>
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.transfers.total}</p>
<Pagination
@@ -47,7 +47,7 @@
href={`${base}/console/project-${project}/settings/transfers/destinations/destination-${destination.$id}`}>
<svelte:fragment slot="title">
<div class="u-flex u-gap-16 u-cross-center">
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${destination.type}.svg`}
alt="technology" />
@@ -1,6 +1,5 @@
<script lang="ts">
import { page } from '$app/stores';
import { Submit, trackEvent } from '$lib/actions/analytics';
import Card from '$lib/components/card.svelte';
import Heading from '$lib/components/heading.svelte';
import Output from '$lib/components/output.svelte';
@@ -19,16 +18,14 @@
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import type { PageData } from './$types';
const permissions = ['Users', 'Databases', 'Documents', 'Files', 'Functions'];
let errors = permissions.map((permission) => {
return {
[permission]: false
};
});
export let data: PageData;
let isChecking = false;
let errorMessage = null;
let errors = {};
const destinationId = $page.params.destination;
const runChecks = async () => {
@@ -38,35 +35,31 @@
try {
await sdkForProject.transfers.validateDestination(destinationId);
isChecking = false;
trackEvent(Submit.DestinationValidate, {
customId: !!destinationId
addNotification({
message: `Destination is valid`,
type: 'success'
});
} catch (error) {
if (error.response.errors) {
errors = error.response.errors;
} else {
errors = permissions.map((permission) => {
return {
[permission]: true
};
});
}
isChecking = false;
} catch (error) {
addNotification({
type: 'error',
title: 'Error',
message: error.message
});
errors = error.response.errors ?? {};
errorMessage = error.message;
console.error(error);
}
isChecking = false;
};
onMount(() => {
runChecks();
let lastCheck: any = data.destination.lastCheck;
errors = lastCheck.errors ?? {};
errorMessage = lastCheck.errorMessage ?? null;
});
</script>
@@ -91,7 +84,7 @@
<TableCellText title="Permission">
{permission}
{#if errors[permission]}
{#if errors[permission] && errors[permission].length > 0}
<Helper type="warning">
{#each errors[permission] as error}
{error} <br />
@@ -99,7 +92,7 @@
</Helper>
{/if}
</TableCellText>
<TableCellText title="Permission Level">
<TableCellText title="Status">
<Pill
danger={errors[permission]}
success={!errors[permission]}
@@ -15,7 +15,7 @@
<Container>
<CardGrid>
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${$destination.type}.svg`}
alt={`${$destination.type} Logo`} />
@@ -54,7 +54,7 @@
href={`${base}/console/project-${project}/settings/transfers/sources/source-${source.$id}`}>
<svelte:fragment slot="title">
<div class="u-flex u-gap-16 u-cross-center">
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${source.type}.svg`}
alt="technology" />
@@ -18,16 +18,14 @@
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import type { PageData } from './$types';
const permissions = ['Users', 'Databases', 'Documents', 'Files', 'Functions'];
export let data: PageData;
let isChecking = false;
let errorMessage = null;
let errors = permissions.map((permission) => {
return {
[permission]: false
};
});
let errors = {};
const sourceId = $page.params.source;
const runChecks = async () => {
@@ -35,7 +33,14 @@
errorMessage = null;
try {
await sdkForProject.transfers.validateSource(sourceId);
let result = await sdkForProject.transfers.validateSource(sourceId);
addNotification({
message: `Destination is valid`,
type: 'success'
});
errors = result.errors ?? {};
isChecking = false;
} catch (error) {
@@ -44,17 +49,19 @@
title: 'Error',
message: error.message
});
errors = error.response.errors;
errors = error.response.errors ?? {};
errorMessage = error.message;
console.error(error);
}
isChecking = false;
};
onMount(() => {
runChecks();
let lastCheck: any = data.source.lastCheck;
errors = lastCheck.errors ?? {};
errorMessage = lastCheck.errorMessage ?? null;
});
</script>
@@ -79,7 +86,7 @@
<TableCellText title="Permission">
{permission}
{#if errors[permission]}
{#if errors[permission] && errors[permission].length > 0}
<Helper type="warning">
{#each errors[permission] as error}
{error} <br />
@@ -15,7 +15,7 @@
<Container>
<CardGrid>
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${$source.type}.svg`}
alt={`${$source.type} Logo`} />
@@ -1,9 +1,77 @@
<script lang="ts">
import { browser } from '$app/environment';
import { invalidate } from '$app/navigation';
import CardGrid from '$lib/components/cardGrid.svelte';
import Output from '$lib/components/output.svelte';
import Status from '$lib/components/status.svelte';
import { Dependencies } from '$lib/constants';
import Button from '$lib/elements/forms/button.svelte';
import { toLocaleDateTime } from '$lib/helpers/date';
import { Container } from '$lib/layout';
import { sdkForConsole } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import { execute, transfer } from '../store';
// import type { PageData } from './$types';
//let data: PageData;
if (browser) {
sdkForConsole.client.subscribe<Models.Transfer>('console', (message) => {
if (message.events.includes('transfers.*.create')) {
invalidate(Dependencies.TRANSFERS);
return;
}
if (message.events.includes('transfers.*.update')) {
invalidate(Dependencies.TRANSFERS);
invalidate(Dependencies.TRANSFER);
return;
}
if (message.events.includes('transfers.*.delete')) {
invalidate(Dependencies.TRANSFERS);
invalidate(Dependencies.TRANSFER);
return;
}
});
}
</script>
<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<button class="button u-center">Begin Transfer</button>
<CardGrid>
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
<div class="avatar is-medium" aria-hidden="true">🛫</div>
<div>
<div class="u-flex u-gap-12 u-cross-center">
<p><b>Transfer ID: </b></p>
<Output value={$transfer.$id}><b>{$transfer.$id}</b></Output>
</div>
</div>
</div>
<svelte:fragment slot="aside">
<div class="u-flex u-main-space-between">
<div>
<p>Created at: {toLocaleDateTime($transfer.$createdAt)}</p>
<p>Updated at: {toLocaleDateTime($transfer.$updatedAt)}</p>
</div>
<div class="u-flex u-flex-vertical u-cross-end">
<Status status={$transfer.status}>
{$transfer.status}
</Status>
<!-- <p class="text">
</p> -->
</div>
</div>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button secondary on:click={() => execute.set($transfer)}>Retry</Button>
</svelte:fragment>
</CardGrid>
</div>
</Container>
@@ -1,5 +1,10 @@
<script lang="ts">
import Heading from '$lib/components/heading.svelte';
import { Container } from '$lib/layout';
</script>
<Container />
<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<Heading tag="h2" size="5">Logs</Heading>
</div>
</Container>
@@ -20,7 +20,7 @@
<Container>
<CardGrid>
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
<div class="avatar is-medium">
<div class="image-item">
<span class="icon-text"> 🛫 </span>
</div>
<div>
@@ -44,7 +44,7 @@
<a
class="u-stretch u-flex u-cross-center u-gap-16 card"
href={`/console/project-${$project.$id}/settings/transfers/sources/source-${data.source.$id}`}>
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${data.source.type}.svg`}
alt="technology" />
@@ -59,7 +59,7 @@
</a>
{:else}
<div class="u-stretch u-flex u-cross-center u-gap-16 card">
<div class="avatar is-medium">
<div class="image-item">
<span class="icon-question-mark-circle" />
</div>
<div>
@@ -74,10 +74,10 @@
<a
class="u-stretch u-flex u-cross-center u-gap-16 card"
href={`/console/project-${$project.$id}/settings/transfers/destinations/destination-${data.destination.$id}`}>
<div class="avatar is-medium">
<div class="image-item">
<img
src={`${base}/icons/${$app.themeInUse}/color/${data.destination.type}.svg`}
alt="technology" />
alt="destination provider" />
</div>
<div>
<Heading tag="h6" size="7">{data.destination.name}</Heading>
@@ -89,7 +89,7 @@
</a>
{:else}
<div class="u-stretch u-flex u-cross-center u-gap-16 card">
<div class="avatar is-medium">
<div class="image-item">
<span class="icon-question-mark-circle" />
</div>
<div>
@@ -1,4 +0,0 @@
<script lang="ts">
</script>
<div />
@@ -19,7 +19,7 @@
type="checkbox"
name="isVerified"
required
bind:checked={$createDestination.type.length} />
bind:checked={$createDestination.type} />
<ul class="grid-box common-section">
{#each options.filter((p) => p !== 'Local') as destination}
<li class="grid-box-item">
@@ -1,11 +1,14 @@
<script lang="ts">
import { InputText } from '$lib/elements/forms';
import FormList from '$lib/elements/forms/formList.svelte';
import InputSecret from '$lib/elements/forms/inputSecret.svelte';
import { WizardStep } from '$lib/layout';
import { onMount } from 'svelte';
import { createDestination } from '../store';
import FirebaseAuthflow from './FirebaseAuthflow.svelte';
/**
* @type {Record<string, Record<string, { type: string; label: string; placeholder: string; required: boolean; value?: string; }>>}
*/
let credentialSchemas = {
nhost: {
host: {
@@ -37,7 +40,7 @@
value: 'postgres'
},
password: {
type: 'string',
type: 'password',
label: 'Password',
placeholder: 'password',
required: true,
@@ -71,7 +74,7 @@
required: true
},
password: {
type: 'string',
type: 'password',
label: 'Password',
placeholder: 'password',
required: true
@@ -91,7 +94,7 @@
required: true
},
key: {
type: 'string',
type: 'password',
label: 'Key',
placeholder: 'API Key',
required: true
@@ -123,43 +126,29 @@
});
}
});
let firebaseFallback = false;
</script>
<WizardStep>
<svelte:fragment slot="title">Provide Credentials</svelte:fragment>
<svelte:fragment slot="subtitle"
>Please provide your authentication details for your provider.</svelte:fragment>
{#if $createDestination.type === 'firebase' && !firebaseFallback}
<FirebaseAuthflow />
<div class="flex flex-row justify-center">
<button
class="tag tooltip"
on:click|preventDefault={() => {
firebaseFallback = true;
}}>
<span class="icon-lock-closed" aria-hidden="true" />
<span class="text">Manual Authentication</span>
<span class="tooltip-popup" role="tooltip">
<p class="text u-margin-block-start-8">
Manually enter your account credentials.
</p>
</span>
</button>
</div>
{:else}
<FormList>
{#each Object.keys(credentialSchemas[$createDestination.type]) as key}
<FormList>
{#each Object.keys(credentialSchemas[$createDestination.type]) as key}
{#if credentialSchemas[$createDestination.type][key].type === 'password'}
<InputSecret
id={key}
label={credentialSchemas[$createDestination.type][key].label}
placeholder={credentialSchemas[$createDestination.type][key].placeholder}
bind:value={$createDestination.data[key]}
required={credentialSchemas[$createDestination.type][key].required} />
{:else}
<InputText
id={key}
label={credentialSchemas[$createDestination.type][key].label}
placeholder={credentialSchemas[$createDestination.type][key].placeholder}
bind:value={$createDestination.data[key]}
required={credentialSchemas[$createDestination.type][key].required} />
{/each}
</FormList>
{/if}
{/if}
{/each}
</FormList>
</WizardStep>
@@ -18,11 +18,12 @@
import Heading from '$lib/components/heading.svelte';
import Output from '$lib/components/output.svelte';
import Helper from '$lib/elements/forms/helper.svelte';
import Button from '$lib/elements/forms/button.svelte';
const permissions = ['Users', 'Databases', 'Documents', 'Files', 'Functions'];
let errors = permissions.map((permission) => {
return {
[permission]: false
[permission]: []
};
});
let isChecking = false;
@@ -54,24 +55,14 @@
customId: !!$createDestination.id
});
} catch (error) {
if (error.response.errors) {
errors = error.response.errors;
} else {
errors = permissions.map((permission) => {
return {
[permission]: true
};
});
}
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.DestinationValidate);
errors = error.response.errors ?? {};
errorMessage = error.message;
console.error(error);
isChecking = false;
canProgress = false;
}
}
@@ -104,6 +95,11 @@
<div class="u-flex u-gap-16 u-cross-center card">
<Output value={errorMessage}>{errorMessage}</Output>
</div>
<Button disabled={isChecking} on:click={validate}>
<span class="icon-check-circle" aria-hidden="true" />
<span class="text">Re-run Checks</span>
</Button>
</Card>
{/if}
<TableScroll>
@@ -117,7 +113,7 @@
<TableCellText title="Permission">
{permission}
{#if errors[permission]}
{#if errors[permission] && errors[permission].length > 0}
<Helper type="warning">
{#each errors[permission] as error}
{error} <br />
@@ -1,9 +1,56 @@
<script lang="ts">
import { app } from '$lib/stores/app';
import EmptyLight from '$lib/images/empty-light.svg';
import EmptyDark from '$lib/images/empty-dark.svg';
import Heading from '$lib/components/heading.svelte';
import Button from '$lib/elements/forms/button.svelte';
import { base } from '$app/paths';
/**
* Redirect to OAuth2 screen -> Get token -> Create service account -> Get Projects -> Request user to select project -> Create destination
*/
let stage = 0;
function track() {
console.log('test');
}
</script>
<div>
<button class="button">Redirect to Google</button>
<article class="card u-grid u-cross-center u-width-full-line common-section">
<div class="u-flex u-flex-vertical u-cross-center u-gap-24">
<button
type="button"
on:click|preventDefault
on:click={track}
aria-label={`Login with google`}>
<div class="grid-box u-flex">
<div class="image-item">
<img
width="200"
height="200"
src={`${base}/icons/${$app.themeInUse}/color/firebase.svg`}
alt="technology" />
</div>
<span class="icon-arrow-right" style="align-self: center;" />
<div class="image-item">
<img
width="200"
height="200"
src={`${base}/icons/${$app.themeInUse}/color/appwrite.svg`}
alt="technology" />
</div>
</div>
</button>
<slot>
<div class="u-text-center">
<Heading size="7" tag="h2">Login with google to get started.</Heading>
</div>
<div class="u-flex u-gap-16 u-main-center">
<Button secondary on:click on:click={track}>Login with Google</Button>
</div>
</slot>
</div>
</article>
</div>
@@ -19,7 +19,7 @@
type="checkbox"
name="isVerified"
required
bind:checked={$createSource.type.length} />
bind:checked={$createSource.type} />
<ul class="grid-box common-section">
{#each options.filter((p) => p !== 'Local') as source}
<li class="grid-box-item">
@@ -1,6 +1,7 @@
<script lang="ts">
import { InputText } from '$lib/elements/forms';
import FormList from '$lib/elements/forms/formList.svelte';
import InputSecret from '$lib/elements/forms/inputSecret.svelte';
import { WizardStep } from '$lib/layout';
import { onMount } from 'svelte';
import { createSource } from '../store';
@@ -8,6 +9,9 @@
// Scan the API AST for all the available credentials
/**
* @type {Record<string, Record<string, { type: string; label: string; placeholder: string; required: boolean; value?: string; }>>}
*/
let credentialSchemas = {
nhost: {
host: {
@@ -28,8 +32,7 @@
type: 'string',
label: 'Database',
placeholder: 'postgres',
required: true,
value: 'postgres'
required: true
},
username: {
type: 'string',
@@ -39,7 +42,7 @@
value: 'postgres'
},
password: {
type: 'string',
type: 'password',
label: 'Password',
placeholder: 'password',
required: true,
@@ -75,7 +78,7 @@
value: 'postgres'
},
password: {
type: 'string',
type: 'password',
label: 'Password',
placeholder: 'password',
required: true
@@ -136,6 +139,7 @@
>Please provide your authentication details for your provider.</svelte:fragment>
{#if $createSource.type === 'firebase' && !firebaseFallback}
<FirebaseAuthflow />
<br />
<div class="flex flex-row justify-center">
<button
class="tag tooltip"
@@ -148,7 +152,7 @@
<span class="tooltip-popup" role="tooltip">
<p class="text u-margin-block-start-8">
Manually enter your account credentials.
Manually enter service account credentials.
</p>
</span>
</button>
@@ -156,12 +160,21 @@
{:else}
<FormList>
{#each Object.keys(credentialSchemas[$createSource.type]) as key}
<InputText
id={key}
label={credentialSchemas[$createSource.type][key].label}
placeholder={credentialSchemas[$createSource.type][key].placeholder}
bind:value={$createSource.data[key]}
required={credentialSchemas[$createSource.type][key].required} />
{#if credentialSchemas[$createSource.type][key].type === 'password'}
<InputSecret
id={key}
label={credentialSchemas[$createSource.type][key].label}
placeholder={credentialSchemas[$createSource.type][key].placeholder}
bind:value={$createSource.data[key]}
required={credentialSchemas[$createSource.type][key].required} />
{:else}
<InputText
id={key}
label={credentialSchemas[$createSource.type][key].label}
placeholder={credentialSchemas[$createSource.type][key].placeholder}
bind:value={$createSource.data[key]}
required={credentialSchemas[$createSource.type][key].required} />
{/if}
{/each}
</FormList>
{/if}
@@ -17,9 +17,11 @@
import Card from '$lib/components/card.svelte';
import Heading from '$lib/components/heading.svelte';
import Output from '$lib/components/output.svelte';
import Helper from '$lib/elements/forms/helper.svelte';
import Button from '$lib/elements/forms/button.svelte';
const permissions = ['Users', 'Databases', 'Documents', 'Files', 'Functions'];
let returnedPermissions = permissions;
let errors = {};
let isChecking = false;
let errorMessage = null;
let canProgress = false;
@@ -28,6 +30,7 @@
isChecking = true;
errorMessage = null;
canProgress = false;
errors = {};
try {
switch ($createSource.type) {
@@ -63,9 +66,6 @@
break;
}
//TODO: Update this to use the response from the API
returnedPermissions = permissions;
isChecking = false;
canProgress = true;
addNotification({
@@ -81,11 +81,12 @@
type: 'error'
});
trackError(error, Submit.SourceValidate);
errors = error.response.errors ?? {};
errorMessage = error.message;
console.error(error);
returnedPermissions = [];
isChecking = false;
canProgress = false;
} finally {
isChecking = false;
}
}
@@ -110,13 +111,21 @@
<TableRow>
<TableCellText title="Permission">
{permission}
{#if errors[permission] && errors[permission].length > 0}
<Helper type="warning">
{#each errors[permission] as error}
{error} <br />
{/each}
</Helper>
{/if}
</TableCellText>
<TableCellText title="Permission Level">
<Pill
danger={!returnedPermissions.includes(permission)}
success={returnedPermissions.includes(permission)}
danger={errors[permission]}
success={!errors[permission]}
warning={isChecking}>
{#if returnedPermissions.includes(permission) && !isChecking}
{#if !errors[permission] && !isChecking}
<span class="icon-check-circle" aria-hidden="true" />
{:else if isChecking}
<span class="icon-question-mark-circle" aria-hidden="true" />
@@ -146,6 +155,13 @@
<div class="u-flex u-gap-16 u-cross-center card">
<Output value={errorMessage}>{errorMessage}</Output>
</div>
<br />
<Button disabled={isChecking} on:click={validate}>
<span class="icon-check-circle" aria-hidden="true" />
<span class="text">Re-run Checks</span>
</Button>
</Card>
{/if}
</div>
@@ -29,7 +29,7 @@
<h2 class="heading-level-6 common-section">Sources</h2>
<input
class="u-hide"
bind:checked={$createTransfer.source.length}
bind:checked={$createTransfer.source}
type="checkbox"
name="hasSelected"
required />
@@ -28,7 +28,7 @@
<section class="common-section">
<input
class="u-hide"
bind:checked={$createTransfer.destination.length}
bind:checked={$createTransfer.destination}
type="checkbox"
name="hasSelected"
required />
@@ -1,5 +1,4 @@
<script lang="ts">
import { Submit, trackError } from '$lib/actions/analytics';
import { WizardStep } from '$lib/layout';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
@@ -18,69 +17,59 @@
import Heading from '$lib/components/heading.svelte';
import Output from '$lib/components/output.svelte';
import Helper from '$lib/elements/forms/helper.svelte';
import Button from '$lib/elements/forms/button.svelte';
const permissions = ['Users', 'Databases', 'Documents', 'Files', 'Functions'];
let isChecking = false;
let errorMessage = null;
let sourceErrors = permissions.map((permission) => {
return {
[permission]: false
};
});
let destinationErrors = sourceErrors;
let sourceErrors = {};
let destinationErrors = {};
let canProgress = false;
async function validate() {
isChecking = true;
errorMessage = null;
canProgress = false;
let sourceResponse = null;
try {
await sdkForProject.transfers.validateSource(
$createTransfer.source,
$createTransfer.resources
);
} catch (error) {
addNotification({
type: 'error',
title: 'Error',
message: error.message
});
sourceErrors = error.response.errors ?? {};
errorMessage = error.message;
canProgress = false;
}
try {
await sdkForProject.transfers.validateDestination(
$createTransfer.destination,
$createTransfer.resources
);
isChecking = false;
canProgress = true;
} catch (error) {
if (!sourceResponse) {
if (error.response.errors) {
sourceErrors = error.response.errors;
} else {
sourceErrors = permissions.map((permission) => {
return {
[permission]: true
};
});
}
} else {
if (error.response.errors) {
destinationErrors = error.response.errors;
} else {
destinationErrors = permissions.map((permission) => {
return {
[permission]: true
};
});
}
}
addNotification({
message: error.message,
type: 'error'
type: 'error',
title: 'Error',
message: error.message
});
trackError(error, Submit.SourceValidate);
destinationErrors = error.response.errors ?? {};
errorMessage = error.message;
console.error(error);
isChecking = false;
canProgress = false;
}
if (!errorMessage) {
canProgress = true;
}
isChecking = false;
}
onMount(async () => {
@@ -106,11 +95,14 @@
<TableCellText title="Permission">
{permission}
{#if sourceErrors[permission]}
{#if (sourceErrors[permission] && sourceErrors[permission].length > 0) || (destinationErrors[permission] && destinationErrors[permission].length > 0)}
<Helper type="warning">
{#each sourceErrors[permission] as error}
{error} <br />
{/each}
{#each destinationErrors[permission] as error}
{error} <br />
{/each}
</Helper>
{/if}
</TableCellText>
@@ -163,6 +155,13 @@
<div class="u-flex u-gap-16 u-cross-center card">
<Output value={errorMessage}>{errorMessage}</Output>
</div>
<br />
<Button disabled={isChecking} on:click={validate}>
<span class="icon-check-circle" aria-hidden="true" />
<span class="text">Re-run Checks</span>
</Button>
</Card>
{/if}
</div>
@@ -0,0 +1,44 @@
// vite.config.js
import { sveltekit } from 'file:///Users/ionicisere/Documents/github/console/node_modules/@sveltejs/kit/src/exports/vite/index.js';
var config = {
plugins: [sveltekit()],
optimizeDeps: {
include: ['echarts', 'prismjs']
},
ssr: {
noExternal: ['echarts', 'prismjs', '@analytics/google-analytics', 'analytics']
},
define: {
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
},
legacy: {
buildSsrCjsExternalHeuristics: true
},
server: {
port: 3e3
}
};
var testConfig = {
resolve: {
// hotfix for https://github.com/vitest-dev/vitest/issues/2834
conditions: ['browser']
},
test: {
include: ['tests/**/*.test.ts'],
environment: 'jsdom',
globals: true,
threads: true,
setupFiles: ['./tests/unit/setup.ts'],
deps: {
inline: ['@analytics/type-utils']
}
}
};
var vite_config_default = process.env.VITEST
? {
...config,
...testConfig
}
: config;
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvaW9uaWNpc2VyZS9Eb2N1bWVudHMvZ2l0aHViL2NvbnNvbGVcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9pb25pY2lzZXJlL0RvY3VtZW50cy9naXRodWIvY29uc29sZS92aXRlLmNvbmZpZy5qc1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvaW9uaWNpc2VyZS9Eb2N1bWVudHMvZ2l0aHViL2NvbnNvbGUvdml0ZS5jb25maWcuanNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tICdAc3ZlbHRlanMva2l0L3ZpdGUnO1xuXG4vKiogQHR5cGUge2ltcG9ydCgndml0ZScpLlVzZXJDb25maWd9ICovXG5jb25zdCBjb25maWcgPSB7XG4gICAgcGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcbiAgICBvcHRpbWl6ZURlcHM6IHtcbiAgICAgICAgaW5jbHVkZTogWydlY2hhcnRzJywgJ3ByaXNtanMnXVxuICAgIH0sXG4gICAgc3NyOiB7XG4gICAgICAgIG5vRXh0ZXJuYWw6IFsnZWNoYXJ0cycsICdwcmlzbWpzJywgJ0BhbmFseXRpY3MvZ29vZ2xlLWFuYWx5dGljcycsICdhbmFseXRpY3MnXVxuICAgIH0sXG4gICAgZGVmaW5lOiB7XG4gICAgICAgICdpbXBvcnQubWV0YS5lbnYuVkVSQ0VMX0FOQUxZVElDU19JRCc6IEpTT04uc3RyaW5naWZ5KHByb2Nlc3MuZW52LlZFUkN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JQUNWLFNBQVMsQ0FBQyxXQUFXLFNBQVM7QUFBQSxFQUNsQztBQUFBLEVBQ0EsS0FBSztBQUFBLElBQ0QsWUFBWSxDQUFDLFdBQVcsV0FBVywrQkFBK0IsV0FBVztBQUFBLEVBQ2pGO0FBQUEsRUFDQSxRQUFRO0FBQUEsSUFDSix1Q0FBdUMsS0FBSyxVQUFVLFFBQVEsSUFBSSxtQkFBbUI7QUFBQSxFQUN6RjtBQUFBLEVBQ0EsUUFBUTtBQUFBLElBQ0osK0JBQStCO0FBQUEsRUFDbkM7QUFBQSxFQUNBLFFBQVE7QUFBQSxJQUNKLE1BQU07QUFBQSxFQUNWO0FBQ0o7QUFHQSxJQUFNLGFBQWE7QUFBQSxFQUNmLFNBQVM7QUFBQTtBQUFBLElBRUwsWUFBWSxDQUFDLFNBQVM7QUFBQSxFQUMxQjtBQUFBLEVBQ0EsTUFBTTtBQUFBLElBQ0YsU0FBUyxDQUFDLG9CQUFvQjtBQUFBLElBQzlCLGFBQWE7QUFBQSxJQUNiLFNBQVM7QUFBQSxJQUNULFNBQVM7QUFBQSxJQUNULFlBQVksQ0FBQyx1QkFBdUI7QUFBQSxJQUNwQyxNQUFNO0FBQUEsTUFDRixRQUFRLENBQUMsdUJBQXVCO0FBQUEsSUFDcEM7QUFBQSxFQUNKO0FBQ0o7QUFFQSxJQUFPLHNCQUFRLFFBQVEsSUFBSSxTQUNyQjtBQUFBLEVBQ0ksR0FBRztBQUFBLEVBQ0gsR0FBRztBQUNQLElBQ0E7IiwKICAibmFtZXMiOiBbXQp9Cg==
@@ -0,0 +1,44 @@
// vite.config.js
import { sveltekit } from 'file:///Users/ionicisere/Documents/github/console/node_modules/@sveltejs/kit/src/exports/vite/index.js';
var config = {
plugins: [sveltekit()],
optimizeDeps: {
include: ['echarts', 'prismjs']
},
ssr: {
noExternal: ['echarts', 'prismjs', '@analytics/google-analytics', 'analytics']
},
define: {
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
},
legacy: {
buildSsrCjsExternalHeuristics: true
},
server: {
port: 3e3
}
};
var testConfig = {
resolve: {
// hotfix for https://github.com/vitest-dev/vitest/issues/2834
conditions: ['browser']
},
test: {
include: ['tests/**/*.test.ts'],
environment: 'jsdom',
globals: true,
threads: true,
setupFiles: ['./tests/unit/setup.ts'],
deps: {
inline: ['@analytics/type-utils']
}
}
};
var vite_config_default = process.env.VITEST
? {
...config,
...testConfig
}
: config;
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvaW9uaWNpc2VyZS9Eb2N1bWVudHMvZ2l0aHViL2NvbnNvbGVcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9pb25pY2lzZXJlL0RvY3VtZW50cy9naXRodWIvY29uc29sZS92aXRlLmNvbmZpZy5qc1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvaW9uaWNpc2VyZS9Eb2N1bWVudHMvZ2l0aHViL2NvbnNvbGUvdml0ZS5jb25maWcuanNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tICdAc3ZlbHRlanMva2l0L3ZpdGUnO1xuXG4vKiogQHR5cGUge2ltcG9ydCgndml0ZScpLlVzZXJDb25maWd9ICovXG5jb25zdCBjb25maWcgPSB7XG4gICAgcGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcbiAgICBvcHRpbWl6ZURlcHM6IHtcbiAgICAgICAgaW5jbHVkZTogWydlY2hhcnRzJywgJ3ByaXNtanMnXVxuICAgIH0sXG4gICA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