* feat: add S3 support to download button and PDF preview components Add S3 object and s3:// URL support to AppDownload and AppPdf components, following the same pattern used in AppImage component. Both components now: - Handle partial S3 objects with storage and presigned URL support - Handle s3:// URL format - Construct proper API endpoints for S3 file downloads Fixes #7240 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * handle policy + fix s3 picker --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
97 lines
2.0 KiB
Svelte
97 lines
2.0 KiB
Svelte
<script lang="ts">
|
|
import { Loader2, Pipette } from 'lucide-svelte'
|
|
import { createEventDispatcher } from 'svelte'
|
|
// @ts-ignore
|
|
import type SimpleEditor from './SimpleEditor.svelte'
|
|
|
|
import { Button } from './common'
|
|
|
|
import Toggle from './Toggle.svelte'
|
|
|
|
import S3FilePicker from './S3FilePicker.svelte'
|
|
import FileUpload from './common/fileUpload/FileUpload.svelte'
|
|
|
|
export let value: any
|
|
export let editor: SimpleEditor | undefined = undefined
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
let s3FilePicker: S3FilePicker
|
|
let s3FileUploadRawMode: false
|
|
let el: HTMLTextAreaElement | undefined = undefined
|
|
let rawValue: string | undefined = undefined
|
|
|
|
function evalValueToRaw() {
|
|
rawValue = JSON.stringify(value, null, 2)
|
|
}
|
|
|
|
evalValueToRaw()
|
|
|
|
export function focus() {
|
|
el?.focus()
|
|
if (el) {
|
|
el.style.height = '5px'
|
|
el.style.height = el.scrollHeight + 50 + 'px'
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<S3FilePicker
|
|
bind:this={s3FilePicker}
|
|
bind:selectedFileKey={value}
|
|
onClose={() => {
|
|
rawValue = JSON.stringify(value, null, 2)
|
|
editor?.setCode(rawValue)
|
|
}}
|
|
readOnlyMode={false}
|
|
/>
|
|
|
|
<div class="flex flex-col w-full gap-1">
|
|
<Toggle
|
|
class="flex justify-end"
|
|
bind:checked={s3FileUploadRawMode}
|
|
size="xs"
|
|
options={{ left: 'Raw S3 object input' }}
|
|
/>
|
|
{#if s3FileUploadRawMode}
|
|
{#await import('$lib/components/JsonEditor.svelte')}
|
|
<Loader2 class="animate-spin" />
|
|
{:then Module}
|
|
<Module.default
|
|
bind:editor
|
|
on:focus={(e) => {
|
|
dispatch('focus')
|
|
}}
|
|
code={JSON.stringify(value ?? { s3: '' }, null, 2)}
|
|
bind:value
|
|
/>
|
|
{/await}
|
|
{:else}
|
|
<FileUpload
|
|
allowMultiple={false}
|
|
randomFileKey={true}
|
|
on:addition={(evt) => {
|
|
value = {
|
|
s3: evt.detail?.path ?? ''
|
|
}
|
|
}}
|
|
on:deletion={(evt) => {
|
|
value = {
|
|
s3: ''
|
|
}
|
|
}}
|
|
defaultValue={value?.s3}
|
|
/>
|
|
{/if}
|
|
<Button
|
|
variant="default"
|
|
unifiedSize="sm"
|
|
on:click={() => {
|
|
s3FilePicker?.open?.(value)
|
|
}}
|
|
startIcon={{ icon: Pipette }}
|
|
>
|
|
Choose an object from the catalog
|
|
</Button>
|
|
</div>
|