mirror of
https://github.com/tloncorp/landscape.git
synced 2024-11-28 12:14:31 +03:00
storage: hardcode url to mimic groups
This commit is contained in:
parent
7211a66d7a
commit
e28d104dd8
4
ui/src/env.d.ts
vendored
4
ui/src/env.d.ts
vendored
@ -1,6 +1,8 @@
|
||||
interface ImportMetaEnv extends Readonly<Record<string, string | boolean | undefined>> {
|
||||
interface ImportMetaEnv
|
||||
extends Readonly<Record<string, string | boolean | undefined>> {
|
||||
readonly VITE_LAST_WIPE: string;
|
||||
readonly VITE_STORAGE_VERSION: string;
|
||||
readonly VITE_SHIP_URL: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
|
@ -15,8 +15,21 @@ import { useCallback, useState } from 'react';
|
||||
|
||||
export const useMockData = import.meta.env.MODE === 'mock';
|
||||
|
||||
export const isStagingHosted =
|
||||
import.meta.env.DEV &&
|
||||
(import.meta.env.VITE_SHIP_URL.endsWith('.test.tlon.systems') ||
|
||||
window.location.hostname.endsWith('.test.tlon.systems'));
|
||||
export const isHosted =
|
||||
import.meta.env.DEV || window.location.hostname.endsWith('.tlon.network');
|
||||
isStagingHosted ||
|
||||
(import.meta.env.DEV &&
|
||||
(import.meta.env.VITE_SHIP_URL.endsWith('.tlon.network') ||
|
||||
window.location.hostname.endsWith('.tlon.network')));
|
||||
|
||||
export const hostingUploadURL = isStagingHosted
|
||||
? 'https://memex.test.tlon.systems'
|
||||
: isHosted
|
||||
? 'https://memex.tlon.network'
|
||||
: '';
|
||||
|
||||
export async function fakeRequest<T>(data: T, time = 300): Promise<T> {
|
||||
return new Promise((resolve) => {
|
||||
|
@ -3,6 +3,7 @@ import { StorageUpdate } from '@/gear';
|
||||
import _ from 'lodash';
|
||||
import { BaseStorageState } from '@/gear';
|
||||
import { BaseState } from '../base';
|
||||
import { hostingUploadURL } from '@/logic/utils';
|
||||
|
||||
export type StorageState = BaseStorageState & BaseState<BaseStorageState>;
|
||||
|
||||
@ -27,8 +28,10 @@ const configuration = (
|
||||
buckets: new Set(data.buckets),
|
||||
currentBucket: data.currentBucket,
|
||||
region: data.region,
|
||||
presignedUrl: data.presignedUrl,
|
||||
service: data.service,
|
||||
// if landscape is not up to date we need to default these so the
|
||||
// client init logic still works
|
||||
presignedUrl: data.presignedUrl || hostingUploadURL,
|
||||
service: data.service || 'credentials',
|
||||
};
|
||||
}
|
||||
return state;
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
reduceStateN,
|
||||
BaseState,
|
||||
} from '../base';
|
||||
import { hostingUploadURL, isHosted } from '@/logic/utils';
|
||||
|
||||
enableMapSet();
|
||||
|
||||
@ -44,9 +45,30 @@ export const useStorage = createState<BaseStorageState>(
|
||||
}
|
||||
numLoads += 1;
|
||||
if (numLoads === 2) {
|
||||
set({ loaded: true });
|
||||
const {
|
||||
s3: { credentials, configuration },
|
||||
} = get();
|
||||
|
||||
if (!credentials?.endpoint && isHosted) {
|
||||
set({
|
||||
loaded: true,
|
||||
s3: {
|
||||
credentials,
|
||||
configuration: {
|
||||
...configuration,
|
||||
presignedUrl:
|
||||
configuration.presignedUrl || hostingUploadURL,
|
||||
service: 'presigned-url',
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
set({ loaded: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
window.useStorage = useStorage;
|
||||
|
Loading…
Reference in New Issue
Block a user