mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 00:13:12 +03:00
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:
parent
347d51fde9
commit
040d8c06ae
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user