mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 08:54:10 +01:00
Fix URL prefix re-inserted when redirecting settings page (#4650)
This commit is contained in:
parent
20ac388f77
commit
409a200ebc
1 changed files with 17 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Tab, Nav, Row, Col, Form } from "react-bootstrap";
|
import { Tab, Nav, Row, Col, Form } from "react-bootstrap";
|
||||||
import { Redirect } from "react-router-dom";
|
import { Redirect, useLocation } from "react-router-dom";
|
||||||
import { LinkContainer } from "react-router-bootstrap";
|
import { LinkContainer } from "react-router-bootstrap";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
|
|
@ -41,24 +41,11 @@ function isTabKey(tab: string | null): tab is TabKey {
|
||||||
return validTabs.includes(tab as TabKey);
|
return validTabs.includes(tab as TabKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SettingTabs: React.FC = () => {
|
const SettingTabs: React.FC<{ tab: TabKey }> = ({ tab }) => {
|
||||||
const tab = new URLSearchParams(location.search).get("tab");
|
|
||||||
|
|
||||||
const { advancedMode, setAdvancedMode } = useSettings();
|
const { advancedMode, setAdvancedMode } = useSettings();
|
||||||
|
|
||||||
const titleProps = useTitleProps({ id: "settings" });
|
const titleProps = useTitleProps({ id: "settings" });
|
||||||
|
|
||||||
if (!isTabKey(tab)) {
|
|
||||||
return (
|
|
||||||
<Redirect
|
|
||||||
to={{
|
|
||||||
...location,
|
|
||||||
search: `tab=${defaultTab}`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tab.Container activeKey={tab} id="configuration-tabs">
|
<Tab.Container activeKey={tab} id="configuration-tabs">
|
||||||
<Helmet {...titleProps} />
|
<Helmet {...titleProps} />
|
||||||
|
|
@ -215,9 +202,23 @@ const SettingTabs: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Settings: React.FC = () => {
|
export const Settings: React.FC = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const tab = new URLSearchParams(location.search).get("tab");
|
||||||
|
|
||||||
|
if (!isTabKey(tab)) {
|
||||||
|
return (
|
||||||
|
<Redirect
|
||||||
|
to={{
|
||||||
|
...location,
|
||||||
|
search: `tab=${defaultTab}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsContext>
|
<SettingsContext>
|
||||||
<SettingTabs />
|
<SettingTabs tab={tab} />
|
||||||
</SettingsContext>
|
</SettingsContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue