, string> = {
@@ -33,14 +32,16 @@ type Props = {
initStore: string;
setInitStore: (v: string) => void;
onOpenDescription: () => void;
+ selectedUrl?: string;
};
-const RemoteZarr = ({ initStore, setInitStore, onOpenDescription }: Props) => {
+const RemoteZarr = ({ initStore, setInitStore, onOpenDescription, selectedUrl = '' }: Props) => {
const [showFetchOptions, setShowFetchOptions] = useState(false);
const [preset, setPreset] = useState
('none');
const [presetValue, setPresetValue] = useState('');
const [headers, setHeaders] = useState([{ key: '', value: '' }]);
const [showCustom, setShowCustom] = useState(false);
+ const [urlValue, setUrlValue] = useState(selectedUrl);
const addHeaderRow = () => setHeaders(h => [...h, { key: '', value: '' }]);
const removeHeaderRow = (i: number) => setHeaders(h => h.filter((_, idx) => idx !== i));
@@ -73,17 +74,16 @@ const RemoteZarr = ({ initStore, setInitStore, onOpenDescription }: Props) => {
className="flex flex-col gap-3"
onSubmit={(e: React.FormEvent) => {
e.preventDefault();
- const input = e.currentTarget.elements[0] as HTMLInputElement;
- const url = input.value;
- if (!url) return;
+ if (!urlValue) return;
const fetchHandler = buildFetchHandler();
- if (fetchHandler && url.startsWith('http://')) {
+ if (fetchHandler && urlValue.startsWith('http://')) {
useGlobalStore.getState().setStatus('Error: Cannot send auth headers over plain HTTP — use HTTPS.');
return;
}
+
const fetchOptions = {
- ...(fetchHandler && { fetch: fetchHandler}),
+ ...(fetchHandler && { fetch: fetchHandler }),
};
useZarrStore.getState().setIcechunkOptions(null);
@@ -93,19 +93,24 @@ const RemoteZarr = ({ initStore, setInitStore, onOpenDescription }: Props) => {
useGlobalStore.getState().setStatus('Fetching...');
useZarrStore.getState().bumpFetchKey();
- setInitStore(url);
+ setInitStore(urlValue);
onOpenDescription();
}}
>
{/* URL + Fetch */}
-
-
+
+ setUrlValue(e.target.value)}
+ />
- {/* FetchOptions */}
+ {/* fetchOptions toggle */}