diff --git a/backend/src/routes/api/buckets/index.ts b/backend/src/routes/api/buckets/index.ts index f35006b..f21a2be 100644 --- a/backend/src/routes/api/buckets/index.ts +++ b/backend/src/routes/api/buckets/index.ts @@ -13,6 +13,7 @@ export default async (fastify: FastifyInstance): Promise => { const { Owner, Buckets } = await s3Client.send(command); reply.send({ owner: Owner, + defaultBucket: process.env.AWS_S3_BUCKET || '', buckets: Buckets, }); } catch (error) { diff --git a/frontend/src/app/components/ObjectBrowser/ObjectBrowser.tsx b/frontend/src/app/components/ObjectBrowser/ObjectBrowser.tsx index fba8364..52f15f1 100644 --- a/frontend/src/app/components/ObjectBrowser/ObjectBrowser.tsx +++ b/frontend/src/app/components/ObjectBrowser/ObjectBrowser.tsx @@ -64,11 +64,13 @@ const ObjectBrowser: React.FC = () => { // Load buckets at startup and when location changes React.useEffect(() => { loadBuckets(bucketName, history, setBucketsList); + setFormSelectBucket(bucketName); }, [location]); // Refresh objects from the bucket when location changes React.useEffect(() => { refreshObjects(bucketName, prefix, setDecodedPrefix, setS3Objects, setS3Prefixes); + setFormSelectBucket(bucketName); }, [location, prefix]); // Handle bucket change in the dropdown diff --git a/frontend/src/app/components/ObjectBrowser/objectBrowserFunctions.ts b/frontend/src/app/components/ObjectBrowser/objectBrowserFunctions.ts index 7c983f9..e6c9cb3 100644 --- a/frontend/src/app/components/ObjectBrowser/objectBrowserFunctions.ts +++ b/frontend/src/app/components/ObjectBrowser/objectBrowserFunctions.ts @@ -8,14 +8,18 @@ import Emitter from '../../utils/emitter'; export const loadBuckets = (bucketName: string, history, setBucketsList) => { axios.get(`${config.backend_api_url}/buckets`) .then(response => { - const { owner, buckets } = response.data; + const { owner, defaultBucket, buckets } = response.data; const newBucketsState = new BucketsList( buckets.map((bucket: any) => new Bucket(bucket.Name, bucket.CreationDate)), new Owner(owner.DisplayName, owner.ID) ); setBucketsList(newBucketsState); if (bucketName === ":bucketName") { - history.push(`/objects/${buckets[0].Name}`); + if ( defaultBucket !== '' ) + history.push(`/objects/${defaultBucket}`); + else { + history.push(`/objects/${buckets[0].Name}`); + } } }) .catch(error => {