mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Add git installation in project settings
This commit is contained in:
1 parent
2866a84646
commit
da58902008
12 files changed
+430
-27
No files matched your search
Generated
+8
-8
@@ -7,8 +7,8 @@
|
||||
"name": "@appwrite/console",
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.65",
|
||||
"@appwrite.io/pink": "^0.0.6-rc.10",
|
||||
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.68",
|
||||
"@appwrite.io/pink": "0.0.6-rc.10",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
@@ -148,9 +148,9 @@
|
||||
},
|
||||
"node_modules/@appwrite.io/console": {
|
||||
"name": "matej-appwrite-console",
|
||||
"version": "7.1.65",
|
||||
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.65.tgz",
|
||||
"integrity": "sha512-410zM0jX+ndZP/g6biKc7M96mV9Bir/86v9rlkrI+C4CaPzU1FPNOWNfmQNUgFvYriKaw9f2p79/3LlfCheIjg==",
|
||||
"version": "7.1.68",
|
||||
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.68.tgz",
|
||||
"integrity": "sha512-as9TjhuBpIXoUtVNTvvVV7umdrNp2cpnKuMC2HusQLlAtrZOdVjZfaoaEyCxpAdkbUIrIuvmEwW8fvb39UNsFA==",
|
||||
"dependencies": {
|
||||
"cross-fetch": "3.1.5",
|
||||
"isomorphic-form-data": "2.0.0"
|
||||
@@ -167,9 +167,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@appwrite.io/pink-icons": {
|
||||
"version": "0.0.6-rc.5",
|
||||
"resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.0.6-rc.5.tgz",
|
||||
"integrity": "sha512-Jv6ecAPhOp50SMiwBiWjK1yl+E/ZK0GzqVxo3nSoo2hIGO8GhfUhgK+yNJc0J9ccV0QjrU+3xxcmzuBWNXJfkA=="
|
||||
"version": "0.0.6-rc.14",
|
||||
"resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.0.6-rc.14.tgz",
|
||||
"integrity": "sha512-OHkW3nOc7aTNlf+kdcSojlimWR+NKUJoYNCcC6ysQs7GnD/ny+en6bpT6u1X5EYEszO/IUQuQYDZhURFeGGO1A=="
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.18.6",
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.65",
|
||||
"@appwrite.io/pink": "^0.0.6-rc.10",
|
||||
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.68",
|
||||
"@appwrite.io/pink": "0.0.6-rc.10",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
|
||||
@@ -211,5 +211,7 @@ export enum Submit {
|
||||
BucketUpdateExtensions = 'submit_bucket_update_extensions',
|
||||
FileCreate = 'submit_file_create',
|
||||
FileDelete = 'submit_file_delete',
|
||||
FileUpdatePermissions = 'submit_file_update_permissions'
|
||||
FileUpdatePermissions = 'submit_file_update_permissions',
|
||||
InstallationCreate = 'submit_installation_create',
|
||||
InstallationDelete = 'submit_installation_delete'
|
||||
}
|
||||
@@ -5,7 +5,8 @@ export const INTERVAL = 5 * 60000; // default interval to check for feedback
|
||||
export enum Dependencies {
|
||||
ORGANIZATION = 'dependency:organization',
|
||||
PROJECT = 'dependency:project',
|
||||
PROJECT_SETTINGS = 'dependency:project_settings',
|
||||
PROJECT_VARIABLES = 'dependency:project_variables',
|
||||
PROJECT_INSTALLATIONS = 'dependency:project_installations',
|
||||
PROJECTS = 'dependency:projects',
|
||||
ACCOUNT = 'dependency:account',
|
||||
ACCOUNT_SESSIONS = 'dependency:account_sessions',
|
||||
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
Storage,
|
||||
Teams,
|
||||
Users,
|
||||
Project as ProjectApi
|
||||
Project as ProjectApi,
|
||||
Vcs
|
||||
} from '@appwrite.io/console';
|
||||
|
||||
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
|
||||
@@ -35,7 +36,8 @@ const sdkForProject = {
|
||||
projectApi: new ProjectApi(clientProject),
|
||||
storage: new Storage(clientProject),
|
||||
teams: new Teams(clientProject),
|
||||
users: new Users(clientProject)
|
||||
users: new Users(clientProject),
|
||||
vcs: new Vcs(clientProject)
|
||||
};
|
||||
|
||||
export const sdk = {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { parse } from 'dotenv';
|
||||
|
||||
export let redeployMessage: string;
|
||||
export let isGlobal: boolean;
|
||||
export let showEditor = false;
|
||||
export let variableList: Models.VariableList;
|
||||
|
||||
@@ -111,9 +112,10 @@
|
||||
</script>
|
||||
|
||||
<Modal headerDivider={false} bind:show={showEditor} onSubmit={handleSubmit} size="big">
|
||||
<svelte:fragment slot="header">Raw editor</svelte:fragment>
|
||||
<svelte:fragment slot="header">Editor</svelte:fragment>
|
||||
<p>
|
||||
Edit environment variables below or download as a <span class="inline-code">.{tab}</span> file.
|
||||
Edit {isGlobal ? 'global' : 'environment'} variables below or download as a
|
||||
<span class="inline-code">.{tab}</span> file.
|
||||
</p>
|
||||
|
||||
<div class="editor-border">
|
||||
|
||||
@@ -16,31 +16,98 @@
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import type { PageData } from './$types';
|
||||
import UpdateVariables from '../updateVariables.svelte';
|
||||
import GitInstallationModal from './GitInstallationModal.svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import PaginationInline from '$lib/components/paginationInline.svelte';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from '$lib/elements/table';
|
||||
import Table from '$lib/elements/table/table.svelte';
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import DropList from '$lib/components/dropList.svelte';
|
||||
import DropListItem from '$lib/components/dropListItem.svelte';
|
||||
import GitDisconnectModal from './GitDisconnectModal.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const sdkCreateVariable = async (key: string, value: string) => {
|
||||
await sdk.forProject.projectApi.createVariable(key, value);
|
||||
await invalidate(Dependencies.PROJECT_SETTINGS);
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
};
|
||||
|
||||
const sdkUpdateVariable = async (variableId: string, key: string, value: string) => {
|
||||
await sdk.forProject.projectApi.updateVariable(variableId, key, value);
|
||||
await invalidate(Dependencies.PROJECT_SETTINGS);
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
};
|
||||
|
||||
const sdkDeleteVariable = async (variableId: string) => {
|
||||
await sdk.forProject.projectApi.deleteVariable(variableId);
|
||||
await invalidate(Dependencies.PROJECT_SETTINGS);
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
};
|
||||
|
||||
let name: string = null;
|
||||
let showDelete = false;
|
||||
let showGitIstall = false;
|
||||
let showGitDisconnect = false;
|
||||
let selectedInstallation: Models.Installation;
|
||||
|
||||
const endpoint = sdk.forConsole.client.config.endpoint;
|
||||
const projectId = $page.params.project;
|
||||
|
||||
let showInstallationDropdown: boolean[] = [];
|
||||
let installationsSum = data.installations.total;
|
||||
let installationsLimit = 10;
|
||||
let installationsOffset = 0;
|
||||
|
||||
// TODO: Fix. Should not run on initial load. We get data from page.ts
|
||||
$: if (installationsOffset !== null) {
|
||||
(async () => {
|
||||
data.installations = await sdk.forProject.vcs.listInstallations([
|
||||
Query.offset(installationsOffset),
|
||||
Query.limit(installationsLimit)
|
||||
]);
|
||||
})();
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
name ??= $project.name;
|
||||
|
||||
if (browser) {
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
|
||||
const alert = urlParams.get('alert') ?? '';
|
||||
|
||||
let notified = false;
|
||||
|
||||
if (alert === 'installation-created') {
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Git installation has been successfully added`
|
||||
});
|
||||
trackEvent(Submit.InstallationCreate);
|
||||
notified = true;
|
||||
} else if (alert === 'installation-updated') {
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Git installation has been successfully updated`
|
||||
});
|
||||
trackEvent(Submit.InstallationCreate);
|
||||
notified = true;
|
||||
}
|
||||
|
||||
if (notified) {
|
||||
window.history.replaceState(
|
||||
{},
|
||||
document.title,
|
||||
window.location.origin + window.location.pathname
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function updateName() {
|
||||
@@ -88,7 +155,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function configureGitHub() {
|
||||
sdk.forProject.vcs.createGitHubInstallation(
|
||||
window.location.href + '?alert=installation-updated'
|
||||
);
|
||||
}
|
||||
|
||||
$: services.load($project);
|
||||
|
||||
function getInstallationLink(installation: Models.Installation) {
|
||||
if (installation.provider === 'GitHub') {
|
||||
return `https://github.com/${installation.organization}`;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getInstallationIcon(installation: Models.Installation) {
|
||||
if (installation.provider === 'GitHub') {
|
||||
return `icon-github`;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -157,6 +246,151 @@
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Git configuration</Heading>
|
||||
<p class="text">
|
||||
Add a Git installation to your project. You can connect a repository in your
|
||||
function settings.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if data.installations.total > 0}
|
||||
<div>
|
||||
<div class="u-flex u-flex-vertical-mobile u-main-end">
|
||||
<ul class="buttons-list">
|
||||
<li class="buttons-list-item">
|
||||
<Button secondary on:click={() => (showGitIstall = true)}>
|
||||
<span class="icon-plus" />
|
||||
<span class="text">Add installation</span>
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<Table noMargin noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead>Installations</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.installations.installations as installation, i}
|
||||
<TableRow>
|
||||
<TableCell title="installations">
|
||||
<div class="u-flex u-main-space-between u-cross-center">
|
||||
<div
|
||||
class="u-flex u-main-start u-cross-center u-gap-8">
|
||||
<div class="avatar">
|
||||
<span
|
||||
class={getInstallationIcon(
|
||||
installation
|
||||
)} />
|
||||
</div>
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-cross-center u-gap-4">
|
||||
<h6>{installation.organization}</h6>
|
||||
<a
|
||||
href={getInstallationLink(
|
||||
installation
|
||||
)}
|
||||
target="_blank"
|
||||
><span
|
||||
style="font-size: 1rem; color: hsl(var(--color-neutral-70));"
|
||||
class="icon-external-link" /></a>
|
||||
</div>
|
||||
<p
|
||||
class="u-x-small"
|
||||
style="color: hsl(var(--color-neutral-70));">
|
||||
Last configure: {toLocaleDateTime(
|
||||
installation.$updatedAt
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<DropList
|
||||
bind:show={showInstallationDropdown[i]}
|
||||
placement="bottom-start"
|
||||
noArrow>
|
||||
<button
|
||||
class="button is-text is-only-icon"
|
||||
aria-label="more options"
|
||||
on:click|preventDefault={() =>
|
||||
(showInstallationDropdown[i] =
|
||||
!showInstallationDropdown[i])}>
|
||||
<span
|
||||
class="icon-dots-horizontal"
|
||||
aria-hidden="true" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem
|
||||
icon="external-link"
|
||||
on:click={() => {
|
||||
showInstallationDropdown[
|
||||
i
|
||||
] = false;
|
||||
configureGitHub();
|
||||
}}>
|
||||
Configure {installation.provider}
|
||||
</DropListItem>
|
||||
<DropListItem
|
||||
icon="x-circle"
|
||||
on:click={async () => {
|
||||
showInstallationDropdown[
|
||||
i
|
||||
] = false;
|
||||
showGitDisconnect = true;
|
||||
selectedInstallation =
|
||||
installation;
|
||||
}}>
|
||||
Disconnect
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p class="text">Total installations: {installationsSum}</p>
|
||||
<PaginationInline
|
||||
sum={installationsSum}
|
||||
limit={installationsLimit}
|
||||
bind:offset={installationsOffset} />
|
||||
</div>
|
||||
{:else}
|
||||
<article class="card-git card is-border-dashed is-no-shadow">
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-gap-32">
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-gap-8">
|
||||
<ul class="avatars-group">
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar"><span class="icon-github" /></div>
|
||||
</li>
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar"><span class="icon-gitlab" /></div>
|
||||
</li>
|
||||
<li class="avatars-group-item">
|
||||
<div class="avatar"><span class="icon-bitBucket" /></div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<span class="icon-arrow-narrow-down" />
|
||||
|
||||
<div class="avatar"><span class="icon-server" /></div>
|
||||
</div>
|
||||
<button
|
||||
on:click={() => (showGitIstall = true)}
|
||||
class="button is-secondary">
|
||||
<span class="text">Add Installation</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<UpdateVariables
|
||||
{sdkCreateVariable}
|
||||
{sdkUpdateVariable}
|
||||
@@ -190,3 +424,22 @@
|
||||
</Container>
|
||||
|
||||
<Delete bind:showDelete />
|
||||
|
||||
{#if showGitIstall}
|
||||
<GitInstallationModal bind:showGitIstall />
|
||||
{/if}
|
||||
|
||||
{#if showGitDisconnect}
|
||||
<GitDisconnectModal bind:showGitDisconnect {selectedInstallation} />
|
||||
{/if}
|
||||
|
||||
<style lang="scss" global>
|
||||
.card-git .avatar {
|
||||
border-color: hsl(var(--color-neutral-10));
|
||||
border-width: 0.0625rem;
|
||||
}
|
||||
|
||||
.theme-dark .card-git .avatar {
|
||||
border-color: hsl(var(--color-neutral-150));
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,14 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
|
||||
export const load: PageLoad = async ({ depends }) => {
|
||||
depends(Dependencies.PROJECT_SETTINGS);
|
||||
depends(Dependencies.PROJECT_VARIABLES);
|
||||
depends(Dependencies.PROJECT_INSTALLATIONS);
|
||||
|
||||
return {
|
||||
variables: await sdk.forProject.projectApi.listVariables()
|
||||
variables: await sdk.forProject.projectApi.listVariables(),
|
||||
installations: await sdk.forProject.vcs.listInstallations([Query.limit(10)])
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import Modal from '$lib/components/modal.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import Button from '$lib/elements/forms/button.svelte';
|
||||
import { TableBody, TableCell, TableRow } from '$lib/elements/table';
|
||||
import { base } from '$app/paths';
|
||||
import { app } from '$lib/stores/app';
|
||||
import Table from '$lib/elements/table/table.svelte';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let showGitDisconnect: boolean;
|
||||
export let selectedInstallation: Models.Installation;
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await sdk.forProject.vcs.deleteInstallation(selectedInstallation.$id);
|
||||
await invalidate(Dependencies.PROJECT_INSTALLATIONS);
|
||||
addNotification({
|
||||
message: `${selectedInstallation.organization} has been disconnected from your project`,
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.InstallationDelete, {
|
||||
customId: selectedInstallation.$id
|
||||
});
|
||||
showGitDisconnect = false;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
trackError(error, Submit.InstallationDelete);
|
||||
showGitDisconnect = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}
|
||||
bind:show={showGitDisconnect}
|
||||
onSubmit={handleSubmit}
|
||||
size="small">
|
||||
<svelte:fragment slot="header">Disconnect installation</svelte:fragment>
|
||||
|
||||
{#if selectedInstallation.functions.length > 0}
|
||||
<p>
|
||||
Are you sure you want to disconnect this git installation? This will affect future
|
||||
deployments to the following functions:
|
||||
</p>
|
||||
|
||||
<div style="max-height: 170px;">
|
||||
<div class="u-flex u-flex-vertical u-gap-12">
|
||||
{#each selectedInstallation.functions as func}
|
||||
<div class="u-flex u-main-space-between u-cross-center u-width-full-line">
|
||||
<div class="u-flex u-main-start u-cross-center u-gap-8">
|
||||
<div class="avatar">
|
||||
<img
|
||||
src={`${base}/icons/${$app.themeInUse}/color/${
|
||||
func.runtime.split('-')[0]
|
||||
}.svg`}
|
||||
alt="technology" />
|
||||
</div>
|
||||
<h6>{func.name}</h6>
|
||||
</div>
|
||||
|
||||
<p class="u-x-small" style="color: hsl(var(--color-neutral-70));">
|
||||
Last deployed: 12m ago
|
||||
</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p>Are you sure you want to disconnect this git installation?</p>
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showGitDisconnect = false)}>Cancel</Button>
|
||||
<Button secondary submit={true}>Disconnect</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
import Modal from '$lib/components/modal.svelte';
|
||||
import Button from '$lib/elements/forms/button.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let showGitIstall: boolean;
|
||||
|
||||
function connectGitHub() {
|
||||
sdk.forProject.vcs.createGitHubInstallation(
|
||||
window.location.href + '?alert=installation-created'
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal headerDivider={false} bind:show={showGitIstall} size="big">
|
||||
<svelte:fragment slot="header">Connect to Git</svelte:fragment>
|
||||
<p>Select a provider to import an existing git repositories.</p>
|
||||
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-gap-16">
|
||||
<button
|
||||
on:click={() => connectGitHub()}
|
||||
class="button is-secondary u-width-full-line u-main-center">
|
||||
<span class="icon-github" aria-hidden="true" />
|
||||
<span class="text">Continue with GitHub</span>
|
||||
</button>
|
||||
<button disabled class="button is-secondary u-width-full-line u-main-center">
|
||||
<span class="icon-gitlab" aria-hidden="true" />
|
||||
<span class="text">GitLab (coming soon)</span>
|
||||
</button>
|
||||
<button disabled class="button is-secondary u-width-full-line u-main-center">
|
||||
<span class="icon-bitBucket" aria-hidden="true" />
|
||||
<span class="text">BitBucket (comong soon)</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (showGitIstall = false)}>Cancel</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -145,7 +145,7 @@
|
||||
showPromoteModal = false;
|
||||
|
||||
await invalidate(Dependencies.VARIABLES);
|
||||
await invalidate(Dependencies.PROJECT_SETTINGS);
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
@@ -188,7 +188,7 @@
|
||||
<li class="buttons-list-item">
|
||||
<Button text on:click={() => (showEditorModal = true)}>
|
||||
<span class="icon-code" />
|
||||
<span class="text">Raw editor</span>
|
||||
<span class="text">Editor</span>
|
||||
</Button>
|
||||
</li>
|
||||
<li class="buttons-list-item">
|
||||
@@ -334,6 +334,7 @@
|
||||
|
||||
{#if showEditorModal}
|
||||
<RawVariableEditor
|
||||
{isGlobal}
|
||||
{sdkCreateVariable}
|
||||
{sdkUpdateVariable}
|
||||
{sdkDeleteVariable}
|
||||
@@ -356,6 +357,7 @@
|
||||
|
||||
{#if showVariablesUpload}
|
||||
<UploadVariables
|
||||
{isGlobal}
|
||||
{redeployMessage}
|
||||
{sdkCreateVariable}
|
||||
{sdkUpdateVariable}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import Alert from '$lib/components/alert.svelte';
|
||||
import { Button, InputFile } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { parse } from 'dotenv';
|
||||
|
||||
export let redeployMessage: string;
|
||||
export let isGlobal: boolean;
|
||||
export let show = false;
|
||||
export let variableList: Models.VariableList;
|
||||
export let sdkCreateVariable: (key: string, value: string) => Promise<any>;
|
||||
@@ -60,10 +62,21 @@
|
||||
</script>
|
||||
|
||||
<Modal headerDivider={false} bind:show onSubmit={handleSubmit} bind:error>
|
||||
<svelte:fragment slot="header">Upload Variables</svelte:fragment>
|
||||
<p>
|
||||
Upload multiple environment variables via a .env file that will be passed to your function.
|
||||
</p>
|
||||
<svelte:fragment slot="header"
|
||||
>Import {isGlobal ? 'global' : 'environment'} variables</svelte:fragment>
|
||||
<div class="u-flex u-flex-vertical u-gap-24">
|
||||
<p>
|
||||
Upload multiple {isGlobal ? 'global' : 'environment'} variables via a .env file that will
|
||||
be passed to {isGlobal ? 'all functions within your project' : 'your function'}.
|
||||
</p>
|
||||
|
||||
{#if variableList.total > 0}
|
||||
<Alert type="info">
|
||||
Existing {isGlobal ? 'global' : 'environment'} variables will be updated. They will not
|
||||
be deleted if they are not present in your .env file.
|
||||
</Alert>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<InputFile bind:files />
|
||||
|
||||
|
||||
Reference in new issue
Block a user