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.
This commit is contained in:
J 2021-02-26 22:12:52 +00:00
parent 347d51fde9
commit 040d8c06ae

View File

@ -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(