diff --git a/web/satellite/src/components/browser/FileBrowser.vue b/web/satellite/src/components/browser/FileBrowser.vue index 5793405b4838..9bd511e9be9c 100644 --- a/web/satellite/src/components/browser/FileBrowser.vue +++ b/web/satellite/src/components/browser/FileBrowser.vue @@ -188,7 +188,6 @@ import TooManyObjectsBanner from '@/components/browser/TooManyObjectsBanner.vue' import UpEntry from '@/components/browser/UpEntry.vue'; import Dropzone from '@/components/browser/Dropzone.vue'; -import FileIcon from '@/../static/images/objects/file.svg'; import BlackArrowExpand from '@/../static/images/common/BlackArrowExpand.svg'; import UploadIcon from '@/../static/images/browser/upload.svg'; @@ -260,13 +259,6 @@ const path = computed((): string => { return obStore.state.path; }); -/** - * Return files that are currently being uploaded from the store. - */ -const filesUploading = computed((): BrowserObject[] => { - return obStore.state.uploading; -}); - /** * Return file browser path from store. */ @@ -277,47 +269,23 @@ const currentPath = computed((): string => { /** * Returns bucket objects count from store. */ -const objectsCount = computed((): number => { +const bucketObjectsCount = computed((): number => { const name: string = obStore.state.bucket; const data: Bucket | undefined = bucketsStore.state.page.buckets.find(bucket => bucket.name === name); - return data?.objectCount || 0; + return data?.objectCount ?? 0; }); /** * Indicates if locked files entry is displayed. */ const lockedFilesEntryDisplayed = computed((): boolean => { - return (objectsCount.value - obStore.state.objectsCount) > 0 && - objectsCount.value <= NUMBER_OF_DISPLAYED_OBJECTS && + return bucketObjectsCount.value > 0 && + obStore.state.objectsCount === 0 && !isLoading.value && !currentPath.value; }); -/** - * Return up to five files currently being uploaded for display purposes. - */ -const formattedFilesUploading = computed((): BrowserObject[] => { - if (filesUploading.value.length > 5) { - return filesUploading.value.slice(0, 5); - } - - return filesUploading.value; -}); - -/** - * Return the text of how many files in total are being uploaded to be displayed to give users more context. - */ -const formattedFilesWaitingToBeUploaded = computed((): string => { - let file = 'file'; - - if (filesUploading.value.length > 1) { - file = 'files'; - } - - return `${filesUploading.value.length} ${file}`; -}); - const bucketName = computed((): string => { return obStore.state.bucket; }); @@ -485,13 +453,6 @@ async function upload(e: Event): Promise { target.value = ''; } -/** - * Cancel the upload of the current file that's passed in as an argument. - */ -function cancelUpload(fileName: string): void { - obStore.cancelUpload(fileName); -} - /** * Call the list method from the store, which will trigger a re-render and fetch all files under the current path passed in as an argument. */ diff --git a/web/satellite/src/components/modals/EnterBucketPassphraseModal.vue b/web/satellite/src/components/modals/EnterBucketPassphraseModal.vue index 800c7f25bde4..96ced2c43441 100644 --- a/web/satellite/src/components/modals/EnterBucketPassphraseModal.vue +++ b/web/satellite/src/components/modals/EnterBucketPassphraseModal.vue @@ -90,8 +90,6 @@ const projectsStore = useProjectsStore(); const router = useRouter(); const notify = useNotify(); -const NUMBER_OF_DISPLAYED_OBJECTS = 1000; - const enterError = ref(''); const passphrase = ref(''); const isLoading = ref(false); @@ -126,7 +124,7 @@ const bucketObjectCount = computed((): number => { (bucket: Bucket) => bucket.name === bucketName.value, ); - return data?.objectCount || 0; + return data?.objectCount ?? 0; }); /** @@ -162,7 +160,7 @@ async function onContinue(): Promise { bucketsStore.setPassphrase(passphrase.value); await bucketsStore.setS3Client(selectedProjectID.value); const count: number = await bucketsStore.getObjectsCount(bucketName.value); - if (bucketObjectCount.value > count && bucketObjectCount.value <= NUMBER_OF_DISPLAYED_OBJECTS) { + if (count === 0 && bucketObjectCount.value > 0) { isWarningState.value = true; isLoading.value = false; return; diff --git a/web/satellite/src/store/modules/bucketsStore.ts b/web/satellite/src/store/modules/bucketsStore.ts index 21cda5231b35..3d8ad24365be 100644 --- a/web/satellite/src/store/modules/bucketsStore.ts +++ b/web/satellite/src/store/modules/bucketsStore.ts @@ -240,35 +240,12 @@ export const useBucketsStore = defineStore('buckets', () => { } async function getObjectsCount(name: string): Promise { - const maxKeys = 1000; // Default max keys count. - const abortController = new AbortController(); - - const request = state.s3Client.send(new ListObjectsV2Command({ + const response = await state.s3Client.send(new ListObjectsV2Command({ Bucket: name, - MaxKeys: maxKeys, - }), { abortSignal: abortController.signal }); - - const timeout = setTimeout(() => { - abortController.abort(); - }, 10000); // abort request in 10 seconds. - - let response: ListObjectsV2CommandOutput; - try { - response = await request; - clearTimeout(timeout); - } catch (error) { - clearTimeout(timeout); - - if (abortController.signal.aborted) { - return 0; - } - - throw error; - } - - if (!response || response.KeyCount === undefined) return 0; + MaxKeys: 1, // We need to know if there is at least 1 decryptable object. + })); - return response.IsTruncated ? maxKeys : response.KeyCount; + return (!response || response.KeyCount === undefined) ? 0 : response.KeyCount; } function setBucketToDelete(bucket: string): void { diff --git a/web/satellite/src/store/modules/objectBrowserStore.ts b/web/satellite/src/store/modules/objectBrowserStore.ts index a0846fee2ea9..c144955170a8 100644 --- a/web/satellite/src/store/modules/objectBrowserStore.ts +++ b/web/satellite/src/store/modules/objectBrowserStore.ts @@ -408,17 +408,12 @@ export const useObjectBrowserStore = defineStore('objectBrowser', () => { async function getObjectCount(): Promise { assertIsInitialized(state); - const paginator = paginateListObjectsV2({ client: state.s3, pageSize: MAX_KEY_COUNT }, { + const response = await state.s3.send(new ListObjectsV2Command({ Bucket: state.bucket, - MaxKeys: MAX_KEY_COUNT, - }); - - let keyCount = 0; - for await (const response of paginator) { - keyCount += response.KeyCount ?? 0; - } + MaxKeys: 1, // We need to know if there is at least 1 decryptable object. + })); - state.objectsCount = keyCount; + state.objectsCount = (!response || response.KeyCount === undefined) ? 0 : response.KeyCount; } async function upload({ e }: { e: DragEvent | Event }): Promise { diff --git a/web/satellite/vuetify-poc/src/components/dialogs/EnterBucketPassphraseDialog.vue b/web/satellite/vuetify-poc/src/components/dialogs/EnterBucketPassphraseDialog.vue index 2373b48c1a42..ae679c5c2aa8 100644 --- a/web/satellite/vuetify-poc/src/components/dialogs/EnterBucketPassphraseDialog.vue +++ b/web/satellite/vuetify-poc/src/components/dialogs/EnterBucketPassphraseDialog.vue @@ -118,8 +118,6 @@ const projectsStore = useProjectsStore(); const notify = useNotify(); const { isLoading, withLoading } = useLoading(); -const NUMBER_OF_DISPLAYED_OBJECTS = 1000; - const passphrase = ref(''); const isPassphraseVisible = ref(false); const isWarningState = ref(false); @@ -155,7 +153,7 @@ const bucketObjectCount = computed((): number => { (bucket: Bucket) => bucket.name === bucketName.value, ); - return data?.objectCount || 0; + return data?.objectCount ?? 0; }); /** @@ -179,7 +177,7 @@ async function onContinue(): Promise { bucketsStore.setPassphrase(passphrase.value); await bucketsStore.setS3Client(projectsStore.state.selectedProject.id); const count: number = await bucketsStore.getObjectsCount(bucketName.value); - if (bucketObjectCount.value > count && bucketObjectCount.value <= NUMBER_OF_DISPLAYED_OBJECTS) { + if (count === 0 && bucketObjectCount.value > 0) { isWarningState.value = true; isLoading.value = false; return; @@ -200,7 +198,10 @@ watch(innerContent, comp => { if (!comp) { passphrase.value = ''; isWarningState.value = false; - return; } }); + +watch(passphrase, () => { + if (isWarningState.value) isWarningState.value = false; +});