From 040d8c06aed3d7ed078714ee741bee06832fd882 Mon Sep 17 00:00:00 2001 From: J Date: Fri, 26 Feb 2021 22:12:52 +0000 Subject: [PATCH] interface: fix S3 canUpload logic s3.credentials is always set, but the fields are all '' if s3 is not configured. So prior to this change, if the user had configured an active bucket, they would always be shown an upload dialog even if they had no storage configured. --- pkg/interface/src/logic/lib/useStorage.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/interface/src/logic/lib/useStorage.ts b/pkg/interface/src/logic/lib/useStorage.ts index a85549e006..ec71f96cbf 100644 --- a/pkg/interface/src/logic/lib/useStorage.ts +++ b/pkg/interface/src/logic/lib/useStorage.ts @@ -23,10 +23,14 @@ const useStorage = (s3: S3State, gcp: GcpState, useEffect(() => { // prefer GCP if available, else use S3. - if (gcp.accessKey !== undefined) { - client.current = new GcpClient(gcp.accessKey); + if (gcp.current !== undefined) { + client.current = new GcpClient(gcp.current.accessKey); } else { - if (!s3.credentials) { + // XX ships currently always have S3 credentials, but the fields are all + // set to '' if they are not configured. + if (!s3.credentials || + !s3.credentials.accessKeyId || + !s3.credentials.secretAccessKey) { return; } client.current = new S3({ @@ -38,8 +42,8 @@ const useStorage = (s3: S3State, gcp: GcpState, const canUpload = useMemo( () => - (client && s3.configuration.currentBucket !== "") || false, - [client, s3.configuration.currentBucket] + (client.current && s3.configuration.currentBucket !== "") || false, + [client.current, s3.configuration.currentBucket] ); const upload = useCallback(