fix: S3 bucket browser small improvements and fixes (#2700)

* fix: S3 bucket browser small improvements and fixes

* Bump file limits to 20 in CE and add a message in the FE
This commit is contained in:
Guillaume Bouvignies
2023-11-24 20:18:02 +01:00
committed by GitHub
parent 4a768c9d6b
commit 9c2125bb89
3 changed files with 44 additions and 10 deletions
@@ -60,9 +60,10 @@
async function loadFiles() {
let availableFiles = await HelpersService.listStoredFiles({
workspace: $workspaceStore!,
maxKeys: 500, // fixed pages of 500 files for now
maxKeys: 1000, // fixed pages of 1000 files for now
marker: paginationMarker
})
for (let file_path of availableFiles.windmill_large_files) {
let split_path = file_path.s3.split('/')
let parent_path: string | undefined = undefined
@@ -70,8 +71,11 @@
let nestingLevel = 0
for (let i = 0; i < split_path.length; i++) {
parent_path = current_path
current_path =
current_path === undefined ? split_path[i] : current_path + '/' + split_path[i]
current_path = current_path === undefined ? split_path[i] : current_path + split_path[i]
if (i < split_path.length - 1) {
current_path += '/'
}
nestingLevel = i * 2
if (allFilesByKey[current_path] !== undefined) {
@@ -81,17 +85,35 @@
type: i === split_path.length - 1 ? 'leaf' : 'folder',
full_key: current_path,
display_name: split_path[i],
collapsed: false,
collapsed: true, // folders collapsed by default
parentPath: parent_path,
nestingLevel: nestingLevel
}
displayedFileKeys.push(current_path)
if (i == 0) {
displayedFileKeys.push(current_path)
}
}
}
displayedFileKeys = displayedFileKeys.sort()
if (availableFiles.next_marker !== undefined) {
paginationMarker = availableFiles.next_marker
}
// before returning, un-collapse the folders containing the selected file (if any)
if (selectedFileKey !== undefined && !emptyString(selectedFileKey.s3)) {
let split_path = selectedFileKey.s3.split('/')
let current_path: string | undefined = undefined
for (let i = 0; i < split_path.length; i++) {
current_path = current_path === undefined ? split_path[i] : current_path + split_path[i]
if (i < split_path.length - 1) {
current_path += '/'
}
let indexOf = displayedFileKeys.indexOf(current_path)
if (indexOf >= 0) {
selectItem(indexOf, true)
}
}
}
}
async function loadFileMetadataPlusPreviewAsync(fileKey: string | undefined) {
@@ -185,7 +207,7 @@
let elt_to_remove = 0
for (let i = index + 1; i < displayedFileKeys.length; i++) {
let file_key = displayedFileKeys[i]
if (file_key.startsWith(item_key + '/')) {
if (file_key.startsWith(item_key)) {
elt_to_remove += 1
} else {
break
@@ -583,6 +583,12 @@
</div>
{:else if tab == 'windmill_lfs'}
<PageHeader title="Windmill Large File Storage" primary={false} />
{#if !$enterpriseLicense}
<Alert type="info" title="S3 storage it limited to 20 files in Windmill CE">
Windmill S3 bucket browser will not work for buckets containing more than 20 files.
Consider upgrading to Windmill EE to use this feature with large buckets.
</Alert>
{/if}
<div class="mt-5 flex gap-1">
{#key s3ResourceInitialPath}
<ResourcePicker