mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 00:02:13 +00:00
* feat: add explore button for object storage resources in resource list Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FhmfSxPuTck3yAhDpkfcA * fix: make s3 drawer tooltip reflect explored resource Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FhmfSxPuTck3yAhDpkfcA * fix: honor workspace prop in global s3 explorer and add resource connection error state Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FhmfSxPuTck3yAhDpkfcA * fix: use picker's effective workspace in S3FilePreview requests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FhmfSxPuTck3yAhDpkfcA * fix: pass acting workspace to explore button in ResourcePicker Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FhmfSxPuTck3yAhDpkfcA * chore: update ee-repo-ref to f78df23339e3136e8b6e9148a509508633448dd2 This commit updates the EE repository reference after PR #686 was merged in windmill-ee-private. Previous ee-repo-ref: efb5e014fec34fc580b9dbb1b260494dd76c5462 New ee-repo-ref: f78df23339e3136e8b6e9148a509508633448dd2 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
155 lines
4.9 KiB
Svelte
155 lines
4.9 KiB
Svelte
<script module lang="ts">
|
|
const OBJECT_STORAGE_RESOURCE_TYPES = [
|
|
's3',
|
|
'azure_blob',
|
|
's3_aws_oidc',
|
|
'azure_workload_identity',
|
|
'gcloud_storage'
|
|
]
|
|
|
|
export function isObjectStorageResourceType(resourceType: string | undefined): boolean {
|
|
return resourceType !== undefined && OBJECT_STORAGE_RESOURCE_TYPES.includes(resourceType)
|
|
}
|
|
|
|
export function assetCanBeExplored(
|
|
asset: Asset,
|
|
_resourceMetadata?: { resource_type?: string }
|
|
): boolean {
|
|
return (
|
|
asset.kind === 'ducklake' ||
|
|
asset.kind === 'datatable' ||
|
|
asset.kind === 's3object' ||
|
|
asset.kind === 'volume' ||
|
|
(asset.kind === 'resource' &&
|
|
(isDbType(_resourceMetadata?.resource_type) ||
|
|
isObjectStorageResourceType(_resourceMetadata?.resource_type)))
|
|
)
|
|
}
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import { isDbType } from '$lib/components/dbTypes'
|
|
import { formatAsset, type Asset } from '$lib/components/assets/lib'
|
|
import { Button, ButtonType } from '$lib/components/common'
|
|
import S3FilePicker from '$lib/components/S3FilePicker.svelte'
|
|
import { VolumeService } from '$lib/gen'
|
|
import {
|
|
globalDbManagerDrawer,
|
|
globalS3FilePickerExplorer,
|
|
userStore,
|
|
workspaceStore
|
|
} from '$lib/stores'
|
|
import { isS3Uri } from '$lib/utils'
|
|
import { Database, File, HardDriveIcon } from 'lucide-svelte'
|
|
import DucklakeIcon from './icons/DucklakeIcon.svelte'
|
|
|
|
const {
|
|
asset,
|
|
_resourceMetadata,
|
|
s3FilePicker,
|
|
onClick,
|
|
class: className = '',
|
|
noText = false,
|
|
buttonVariant = 'default',
|
|
btnClasses = '',
|
|
disabled = false,
|
|
workspace = undefined
|
|
}: {
|
|
asset: Asset
|
|
_resourceMetadata?: { resource_type?: string }
|
|
s3FilePicker?: S3FilePicker
|
|
onClick?: () => void
|
|
class?: string
|
|
noText?: boolean
|
|
buttonVariant?: ButtonType.Variant
|
|
btnClasses?: string
|
|
disabled?: boolean
|
|
/** Workspace the explored asset lives in; defaults to the nav workspace. */
|
|
workspace?: string
|
|
} = $props()
|
|
|
|
let dbManagerDrawer = $derived(globalDbManagerDrawer.val)
|
|
let ws = $derived(workspace ?? $workspaceStore)
|
|
const assetUri = $derived(formatAsset(asset))
|
|
// Contexts with a select/upload flow pass their own picker; everything else
|
|
// (e.g. the resources list) falls back to the global read-only explorer.
|
|
let effectiveS3FilePicker = $derived(s3FilePicker ?? globalS3FilePickerExplorer.val)
|
|
let isStorageResource = $derived(
|
|
asset.kind === 'resource' && isObjectStorageResourceType(_resourceMetadata?.resource_type)
|
|
)
|
|
</script>
|
|
|
|
<Button
|
|
disabled={$userStore?.operator || disabled}
|
|
unifiedSize={'md'}
|
|
variant={buttonVariant}
|
|
wrapperClasses={className}
|
|
iconOnly={noText}
|
|
{btnClasses}
|
|
on:click={async () => {
|
|
if (asset.kind === 'resource' && isDbType(_resourceMetadata?.resource_type)) {
|
|
let [resourcePath, specificTable] = asset.path.split('?table=')
|
|
dbManagerDrawer?.openDrawer(
|
|
{
|
|
type: 'database',
|
|
resourceType: _resourceMetadata.resource_type,
|
|
resourcePath,
|
|
specificTable
|
|
},
|
|
ws
|
|
)
|
|
} else if (isStorageResource) {
|
|
effectiveS3FilePicker?.open(undefined, { s3ResourcePath: asset.path, workspace: ws })
|
|
} else if (asset.kind === 's3object' && isS3Uri(assetUri)) {
|
|
effectiveS3FilePicker?.open(assetUri, { workspace: ws })
|
|
} else if (asset.kind === 'volume') {
|
|
const storage = (await VolumeService.getVolumeStorage({ workspace: ws! })) ?? undefined
|
|
effectiveS3FilePicker?.open(
|
|
{ s3: `volumes/${ws}/${asset.path}/`, storage },
|
|
{ workspace: ws }
|
|
)
|
|
} else if (asset.kind === 'ducklake') {
|
|
let ducklake = asset.path.split('/')[0]
|
|
let specificTableSplit = asset.path.split('/')[1]?.split('.') as string[] | undefined
|
|
let [specificSchema, specificTable] =
|
|
specificTableSplit?.length === 2
|
|
? [specificTableSplit[0], specificTableSplit[1]]
|
|
: [undefined, specificTableSplit?.[0]]
|
|
dbManagerDrawer?.openDrawer({ type: 'ducklake', ducklake, specificSchema, specificTable }, ws)
|
|
} else if (asset.kind === 'datatable') {
|
|
let datatable = asset.path.split('/')[0]
|
|
let specificTableSplit = asset.path.split('/')[1]?.split('.') as string[] | undefined
|
|
let [specificSchema, specificTable] =
|
|
specificTableSplit?.length === 2
|
|
? [specificTableSplit[0], specificTableSplit[1]]
|
|
: [undefined, specificTableSplit?.[0]]
|
|
dbManagerDrawer?.openDrawer(
|
|
{
|
|
type: 'database',
|
|
resourceType: 'postgresql',
|
|
resourcePath: `datatable://${datatable}`,
|
|
specificTable,
|
|
specificSchema
|
|
},
|
|
ws
|
|
)
|
|
}
|
|
onClick?.()
|
|
}}
|
|
endIcon={asset.kind === 's3object' || isStorageResource
|
|
? { icon: File }
|
|
: asset.kind === 'resource' || asset.kind === 'datatable'
|
|
? { icon: Database }
|
|
: asset.kind === 'ducklake'
|
|
? { icon: DucklakeIcon }
|
|
: asset.kind === 'volume'
|
|
? { icon: HardDriveIcon }
|
|
: undefined}
|
|
>
|
|
{#if asset.kind === 's3object' || asset.kind === 'volume' || isStorageResource}
|
|
<span class:hidden={noText}>Explore</span>
|
|
{:else if asset.kind === 'resource' || asset.kind === 'ducklake' || asset.kind === 'datatable'}
|
|
<span class:hidden={noText}>Manage</span>
|
|
{/if}
|
|
</Button>
|