Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/lib/elements/forms/inputFile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
function setFiles(value: FileList) {
if (!value) return;

const hasInvalidExt = Array.from(value).some((file) => {
const fileExtension = file.name.split('.').pop();
return allowedFileExtensions?.length
? !allowedFileExtensions.includes(fileExtension)
: false;
});
if (hasInvalidExt) {
error = 'Invalid file extension';
return;
}

files = value;
input.files = value;
}
Expand Down Expand Up @@ -78,6 +67,20 @@

const handleChange = (event: Event) => {
const target = event.currentTarget as HTMLInputElement;

const isValidFiles = Array.from(target.files).every((file) => {
const fileExtension = file.name.split('.').pop();
return allowedFileExtensions?.length
? allowedFileExtensions.includes(fileExtension)
: true;
});

if (!isValidFiles) {
error = 'Invalid file extension';
target.value = '';
return;
}

setFiles(target.files);
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
TableRow,
TableScroll
} from '$lib/elements/table';
import { deploymentList, execute, func, proxyRuleList } from './store';
import { deploymentList, execute, func, proxyRuleList, showFunctionExecute } from './store';
import { Container, ContainerHeader } from '$lib/layout';
import { app } from '$lib/stores/app';
import { calculateSize, humanFileSize } from '$lib/helpers/sizeConvertion';
Expand Down Expand Up @@ -151,7 +151,10 @@

<Button
secondary
on:click={() => ($execute = $func)}
on:click={() => {
$execute = $func;
$showFunctionExecute = true;
}}
disabled={isCloud && $readOnly && !GRACE_PERIOD_OVERRIDE}>
Execute now
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { showFunctionExecute } from './store';

export let selectedFunction: Models.Function = null;

Expand All @@ -34,13 +35,8 @@
{ label: 'OPTIONS', value: 'OPTIONS' }
];

let show = false;
let submitting = false;

$: if (selectedFunction && !show) {
show = true;
}

const handleSubmit = async () => {
submitting = true;
try {
Expand Down Expand Up @@ -80,7 +76,7 @@

function close() {
selectedFunction = null;
show = false;
$showFunctionExecute = false;
}

afterNavigate(close);
Expand All @@ -89,10 +85,9 @@
<Modal
title="Execute function"
headerDivider={false}
bind:show
bind:show={$showFunctionExecute}
size="big"
onSubmit={handleSubmit}
on:close={close}
bind:error>
<p class="text">
Manually execute your function. <a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { log } from '$lib/stores/logs';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { func } from '../store';
import { func, showFunctionExecute } from '../store';
import type { Models } from '@appwrite.io/console';
import { organization } from '$lib/stores/organization';
import { getServiceLimit, showUsageRatesModal } from '$lib/stores/billing';
Expand Down Expand Up @@ -54,7 +54,10 @@
title="Executions"
buttonText="Execute now"
buttonEvent="execute_function"
buttonMethod={() => (selectedFunction = $func)}>
buttonMethod={() => {
selectedFunction = $func;
$showFunctionExecute = true;
}}>
<svelte:fragment slot="tooltip" let:tier let:limit let:upgradeMethod>
<p class="u-bold">The {tier} plan has limits</p>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { CardGrid, Heading, SvgIcon } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { toLocaleDateTime } from '$lib/helpers/date';
import { execute, func } from '../store';
import { execute, func, showFunctionExecute } from '../store';
</script>

<CardGrid>
Expand All @@ -26,6 +26,11 @@
</svelte:fragment>

<svelte:fragment slot="actions">
<Button secondary on:click={() => ($execute = $func)}>Execute now</Button>
<Button
secondary
on:click={() => {
$execute = $func;
$showFunctionExecute = true;
}}>Execute now</Button>
</svelte:fragment>
</CardGrid>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const proxyRuleList = derived(
($page) => $page.data.proxyRuleList as Models.ProxyRuleList
);
export const execute: Writable<Models.Function> = writable();
export const showFunctionExecute: Writable<boolean> = writable(false);

export const repositories: Writable<{
search: string;
installationId: string;
Expand Down