From 11eb8ed25c1d1809aac4375c2a72abc58d00dd50 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Mar 2025 12:02:08 +0100 Subject: [PATCH] fix: upload variables modal --- .../project-[project]/updateVariables.svelte | 34 ++++---- .../uploadVariablesModal.svelte | 77 ++++++++++++------- 2 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/routes/(console)/project-[project]/updateVariables.svelte b/src/routes/(console)/project-[project]/updateVariables.svelte index 7bb39273e..06e4793c2 100644 --- a/src/routes/(console)/project-[project]/updateVariables.svelte +++ b/src/routes/(console)/project-[project]/updateVariables.svelte @@ -219,11 +219,22 @@ >. {/if} - - + + + + + + + {#if variableList.total} + + {/if} + {@const sum = variableList.total} {#if sum} @@ -307,7 +318,7 @@ showVariablesModal = true; toggle(e); }}> - Edit + Update {#if !isGlobal} {/if} { handleVariableDeleted(variable); @@ -349,16 +361,6 @@ Create a {isGlobal ? 'global variable' : 'variable'} to get started {/if} - - - - diff --git a/src/routes/(console)/project-[project]/uploadVariablesModal.svelte b/src/routes/(console)/project-[project]/uploadVariablesModal.svelte index 0086fca11..127193428 100644 --- a/src/routes/(console)/project-[project]/uploadVariablesModal.svelte +++ b/src/routes/(console)/project-[project]/uploadVariablesModal.svelte @@ -4,22 +4,35 @@ import { Button } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import type { Models } from '@appwrite.io/console'; - import { Layout, Typography, Upload } from '@appwrite.io/pink-svelte'; + import { IconInfo } from '@appwrite.io/pink-icons-svelte'; + import { + Icon, + InlineCode, + Layout, + Selector, + Tooltip, + Typography, + Upload + } from '@appwrite.io/pink-svelte'; import { parse } from 'envfile'; - export let isGlobal: boolean; export let show = false; export let variableList: Models.VariableList; - export let sdkCreateVariable: (key: string, value: string) => Promise; + export let sdkCreateVariable: ( + key: string, + value: string, + secret?: boolean + ) => Promise; export let sdkUpdateVariable: ( variableId: string, key: string, - value: string + value: string, + secret?: boolean ) => Promise; let files: FileList; + let secret = false; let error: string; - export let product: 'function' | 'site' = 'function'; async function handleSubmit() { try { @@ -49,8 +62,8 @@ (variable) => variable.key === key ); return found - ? sdkUpdateVariable(found.$id, key, value) - : sdkCreateVariable(key, value); + ? sdkUpdateVariable(found.$id, key, value, secret) + : sdkCreateVariable(key, value, secret); }) ); @@ -64,36 +77,44 @@ error = e.message; } } - - const title = `Import new ${isGlobal ? 'global' : 'environment'} variables`; - -
-

- {title} from - .env - file that will be passed to {!isGlobal - ? `your ${product}` - : 'all functions and sites within your project'}. -

- - {#if variableList.total > 0} - - Existing {isGlobal ? 'global' : 'environment'} variables will be updated. They will not - be deleted if they are not present in your .env file. - - {/if} -
+ + + Import new environment variables from file. + - - Upload a file + + + + Drag and drop files here or click to upload + + + + + + Only .env files allowed + + + Up to 100 variables allowed + {#if variableList.total > 0} + + This action can create and update variables but can not delete them. + + {/if} + +