Skip to content

Commit d5c68dd

Browse files
authored
Merge pull request #2935 from appwrite/fix-uploadvas-flow
fix: upload vars and mobile ux
2 parents 1e4082c + 7eb40e4 commit d5c68dd

8 files changed

Lines changed: 169 additions & 50 deletions

File tree

src/lib/components/cardGrid.svelte

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88

99
<Card.Base>
1010
<Layout.Stack gap="xl" justifyContent="space-around">
11-
<Layout.GridFraction gap="xxxl" rowGap="xl" start={1} end={2}>
12-
<Layout.Stack gap="xxs">
11+
<div class="card-grid-content">
12+
<Layout.Stack gap="xxs" class="card-grid-main">
1313
<Typography.Title size="s" truncate><slot name="title" /></Typography.Title>
1414
{#if $$slots.default}
1515
<Typography.Text>
1616
<slot />
1717
</Typography.Text>
1818
{/if}
1919
</Layout.Stack>
20-
<div style:overflow={overflow ? 'visible' : 'hidden'}>
20+
<div class="card-grid-aside" style:overflow={overflow ? 'visible' : 'hidden'}>
2121
<Layout.Stack {gap}>
2222
<slot name="aside" />
2323
</Layout.Stack>
2424
</div>
25-
</Layout.GridFraction>
25+
</div>
2626
{#if $$slots.actions && !hideFooter}
2727
<span
2828
style="margin-left: calc(-1* var(--space-9));margin-right: calc(-1* var(--space-9));width:auto;">
@@ -34,3 +34,25 @@
3434
{/if}
3535
</Layout.Stack>
3636
</Card.Base>
37+
38+
<style>
39+
.card-grid-content {
40+
display: grid;
41+
gap: var(--space-10);
42+
align-items: start;
43+
grid-template-columns: minmax(0, 1fr);
44+
}
45+
46+
.card-grid-main,
47+
.card-grid-aside {
48+
min-width: 0;
49+
}
50+
51+
@media (min-width: 769px) {
52+
.card-grid-content {
53+
column-gap: var(--space-13);
54+
row-gap: var(--space-10);
55+
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
56+
}
57+
}
58+
</style>

src/lib/components/variables/environmentVariables.svelte

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import DeleteVariableModal from './deleteVariableModal.svelte';
3232
import UpdateVariableModal from './updateVariableModal.svelte';
3333
import { Click, trackEvent } from '$lib/actions/analytics';
34+
import { isSmallViewport } from '$lib/stores/viewport';
3435
3536
const DOCS_LINKS: Record<ProductLabel, string> = {
3637
site: 'https://appwrite.io/docs/products/sites/develop#accessing-environment-variables',
@@ -62,18 +63,26 @@
6263
const createSource = $derived(analyticsCreateSource || analyticsSource);
6364
const docsLink = $derived(DOCS_LINKS[productLabel]);
6465
65-
const tableColumns = [
66-
{ id: 'key', width: { min: 300 } },
67-
{ id: 'value', width: { min: 280 } },
68-
{ id: 'actions', width: 40 }
69-
];
66+
const tableColumns = $derived(
67+
$isSmallViewport
68+
? [
69+
{ id: 'key', width: { min: 420 } },
70+
{ id: 'value', width: { min: 240 } },
71+
{ id: 'actions', width: 40 }
72+
]
73+
: [
74+
{ id: 'key', width: { min: 300 } },
75+
{ id: 'value', width: { min: 280 } },
76+
{ id: 'actions', width: 40 }
77+
]
78+
);
7079
</script>
7180

7281
<Accordion title="Environment variables" badge="Optional" hideDivider>
7382
<Layout.Stack gap="xl">
7483
Set up environment variables to securely manage keys and settings for your project.
7584
<Layout.Stack gap="l">
76-
<Layout.Stack direction="row">
85+
<Layout.Stack direction="row" gap="s">
7786
<Layout.Stack direction="row" gap="s">
7887
<Button
7988
secondary
@@ -137,7 +146,7 @@
137146
{:else if variables?.length}
138147
<Paginator items={variables} limit={6} hideFooter={variables.length <= 6}>
139148
{#snippet children(paginatedItems)}
140-
<Table.Root let:root columns={tableColumns}>
149+
<Table.Root class="responsive-table" let:root columns={tableColumns}>
141150
<svelte:fragment slot="header" let:root>
142151
<Table.Header.Cell column="key" {root}>Key</Table.Header.Cell>
143152
<Table.Header.Cell column="value" {root}>Value</Table.Header.Cell>

src/lib/components/variables/importVariablesModal.svelte

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
77
import { Icon, Layout, Selector, Tooltip, Typography, Upload } from '@appwrite.io/pink-svelte';
88
import { parse } from '$lib/helpers/envfile';
9+
import { removeFile } from '$lib/helpers/files';
910
1011
export let show = false;
1112
export let variables: Partial<Models.Variable>[];
1213
1314
let files: FileList;
1415
let error: string;
1516
let secret = false;
17+
$: filesList = files?.length
18+
? Array.from(files).map((file) => ({
19+
...file,
20+
name: file.name,
21+
size: file.size,
22+
extension: file.type,
23+
removable: true
24+
}))
25+
: [];
1626
1727
async function handleSubmit() {
1828
try {
@@ -52,28 +62,32 @@
5262
<Layout.Stack>
5363
<Upload.Dropzone bind:files>
5464
<Layout.Stack alignItems="center" gap="s">
55-
<Layout.Stack
56-
alignItems="center"
57-
justifyContent="center"
58-
direction="row"
59-
gap="s">
60-
<Typography.Text variant="l-500">
65+
<Layout.Stack alignItems="center" justifyContent="center" inline>
66+
<Typography.Text variant="l-500" align="center" inline>
6167
Drag and drop files here or click to upload
62-
</Typography.Text>
63-
<Tooltip>
64-
<Layout.Stack alignItems="center" justifyContent="center" inline>
65-
<Icon icon={IconInfo} size="s" />
68+
<Layout.Stack
69+
style="display: inline-flex; vertical-align: middle;"
70+
inline
71+
alignItems="center"
72+
justifyContent="center">
73+
<Tooltip>
74+
<Icon icon={IconInfo} size="s" />
75+
<svelte:fragment slot="tooltip"
76+
>Only .env files allowed</svelte:fragment>
77+
</Tooltip>
6678
</Layout.Stack>
67-
<svelte:fragment slot="tooltip">
68-
Only .env files allowed
69-
</svelte:fragment>
70-
</Tooltip>
79+
</Typography.Text>
7180
</Layout.Stack>
72-
<Typography.Caption variant="400">
81+
<Typography.Caption variant="400" align="center">
7382
Up to 100 variables allowed
7483
</Typography.Caption>
7584
</Layout.Stack>
7685
</Upload.Dropzone>
86+
{#if files?.length}
87+
<Upload.List
88+
bind:files={filesList}
89+
on:remove={(e) => (files = removeFile(e.detail, files))} />
90+
{/if}
7791
{#if variables?.length > 0}
7892
<Alert.Inline status="info" dismissible>
7993
This action can create and update variables but can not delete them.

src/lib/layout/shell.svelte

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@
7676
showAccountMenu = false;
7777
}
7878
79+
function closeOpenDialogs() {
80+
if (typeof document === 'undefined') return;
81+
82+
const openDialogs = Array.from(
83+
document.querySelectorAll('dialog[open]')
84+
) as HTMLDialogElement[];
85+
86+
for (const dialog of openDialogs) {
87+
dialog.close();
88+
}
89+
90+
document.documentElement.classList.remove('u-overflow-hidden');
91+
}
92+
7993
/**
8094
* Cancel navigation when wizard is open and triggered by popstate
8195
*/
@@ -184,6 +198,7 @@
184198
$: isProjectBlocked = getIsProjectBlocked(selectedProject);
185199
$: {
186200
if ($isSidebarOpen) {
201+
closeOpenDialogs();
187202
yOnMenuOpen = window.scrollY;
188203
bodyStyle.set({ position: 'fixed', top: `-${window.scrollY}px` });
189204
} else if (!$isSidebarOpen) {
@@ -260,7 +275,7 @@
260275
<style lang="scss">
261276
.shell-sidebar-area {
262277
position: relative;
263-
z-index: 2;
278+
z-index: 20;
264279
}
265280
266281
.content {
@@ -335,7 +350,7 @@
335350
height: 100vh;
336351
right: 0;
337352
top: 0;
338-
z-index: 10;
353+
z-index: 19;
339354
background-color: #56565c1a;
340355
backdrop-filter: blur(5px);
341356
transition:

src/routes/(console)/project-[region]-[project]/createVariableModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<Modal
5050
bind:show={showCreate}
5151
onSubmit={handleVariable}
52-
title={`Create' ${isGlobal ? 'global' : 'environment'} variable`}>
52+
title={`Create ${isGlobal ? 'global' : 'environment'} variables`}>
5353
<svelte:fragment slot="description">
5454
<span>
5555
Set the environment variables or secret keys that will be passed to {!isGlobal

src/routes/(console)/project-[region]-[project]/settings/updateInstallations.svelte

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<svelte:fragment slot="aside">
8585
{#if total > 0}
8686
<Layout.Stack gap="l">
87-
<Layout.Stack direction="row" justifyContent="flex-end">
87+
<div class="installations-action-row">
8888
<FormButton
8989
secondary
9090
href={configureGitHub()}
@@ -94,7 +94,7 @@
9494
<Icon icon={IconPlus} slot="start" size="s" />
9595
Add installation
9696
</FormButton>
97-
</Layout.Stack>
97+
</div>
9898

9999
<Table.Root
100100
let:root
@@ -233,3 +233,16 @@
233233
</Card.Base>
234234
</svelte:fragment>
235235
</CardGrid>
236+
237+
<style>
238+
.installations-action-row {
239+
display: flex;
240+
justify-content: flex-start;
241+
}
242+
243+
@media (min-width: 769px) {
244+
.installations-action-row {
245+
justify-content: flex-end;
246+
}
247+
}
248+
</style>

src/routes/(console)/project-[region]-[project]/updateVariables.svelte

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import SecretVariableModal from './secretVariableModal.svelte';
4040
import { Confirm } from '$lib/components';
4141
import { resolveRoute, withPath } from '$lib/stores/navigation';
42+
import { isSmallViewport } from '$lib/stores/viewport';
4243
4344
export let project: Models.Project;
4445
export let variableList: Models.VariableList;
@@ -266,6 +267,18 @@
266267
});
267268
})
268269
: false;
270+
271+
$: variableColumns = $isSmallViewport
272+
? [
273+
{ id: 'key', width: { min: 380, max: 520 } },
274+
{ id: 'value', width: { min: 200, max: 320 } },
275+
{ id: 'actions', width: 50 }
276+
]
277+
: [
278+
{ id: 'key', width: { min: 280, max: 420 } },
279+
{ id: 'value', width: { min: 200, max: 400 } },
280+
{ id: 'actions', width: 50 }
281+
];
269282
</script>
270283

271284
<CardGrid>
@@ -288,8 +301,8 @@
288301
{/if}
289302
<svelte:fragment slot="aside">
290303
<Layout.Stack gap="l">
291-
<Layout.Stack direction="row">
292-
<Layout.Stack direction="row" gap="s">
304+
<Layout.Stack direction="row" gap="s" wrap={$isSmallViewport ? 'wrap' : 'nowrap'}>
305+
<Layout.Stack direction="row" gap="s" wrap={$isSmallViewport ? 'wrap' : 'nowrap'}>
293306
<Button
294307
secondary
295308
on:mousedown={() => {
@@ -345,13 +358,7 @@
345358
</p>
346359
</Alert.Inline>
347360
{/if}
348-
<Table.Root
349-
columns={[
350-
{ id: 'key', width: { min: 200, max: 400 } },
351-
{ id: 'value', width: { min: 200, max: 400 } },
352-
{ id: 'actions', width: 50 }
353-
]}
354-
let:root>
361+
<Table.Root class="responsive-table" columns={variableColumns} let:root>
355362
<svelte:fragment slot="header" let:root>
356363
<Table.Header.Cell column="key" {root}>Key</Table.Header.Cell>
357364
<Table.Header.Cell column="value" {root}>Value</Table.Header.Cell>
@@ -366,7 +373,11 @@
366373
) !== undefined
367374
: false}
368375

369-
<Layout.Stack gap="xxs" alignItems="center" direction="row">
376+
<Layout.Stack
377+
gap="xxs"
378+
alignItems="center"
379+
direction="row"
380+
class="variable-key-cell">
370381
{#if isConflicting && hasConflictOnPage}
371382
<span
372383
class="icon-exclamation u-color-text-warning"
@@ -526,3 +537,16 @@
526537
<p>Are you sure you want to delete this variable? This action is irreversible.</p>
527538
</Confirm>
528539
{/if}
540+
541+
<style>
542+
:global(.variable-key-cell) {
543+
min-width: 0;
544+
}
545+
546+
:global(.variable-key-cell > :last-child) {
547+
min-width: 0;
548+
overflow: hidden;
549+
text-overflow: ellipsis;
550+
white-space: nowrap;
551+
}
552+
</style>

0 commit comments

Comments
 (0)