mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Go to list page if deleting with empty history (#6203)
This commit is contained in:
@@ -43,6 +43,7 @@ import cx from "classnames";
|
|||||||
import { useRatingKeybinds } from "src/hooks/keybinds";
|
import { useRatingKeybinds } from "src/hooks/keybinds";
|
||||||
import { ConfigurationContext } from "src/hooks/Config";
|
import { ConfigurationContext } from "src/hooks/Config";
|
||||||
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
gallery: GQL.GalleryDataFragment;
|
gallery: GQL.GalleryDataFragment;
|
||||||
@@ -167,7 +168,7 @@ export const GalleryPage: React.FC<IProps> = ({ gallery, add }) => {
|
|||||||
function onDeleteDialogClosed(deleted: boolean) {
|
function onDeleteDialogClosed(deleted: boolean) {
|
||||||
setIsDeleteAlertOpen(false);
|
setIsDeleteAlertOpen(false);
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
history.goBack();
|
goBackOrReplace(history, "/galleries");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import { Button, Tab, Tabs } from "react-bootstrap";
|
|||||||
import { GroupSubGroupsPanel } from "./GroupSubGroupsPanel";
|
import { GroupSubGroupsPanel } from "./GroupSubGroupsPanel";
|
||||||
import { GroupPerformersPanel } from "./GroupPerformersPanel";
|
import { GroupPerformersPanel } from "./GroupPerformersPanel";
|
||||||
import { Icon } from "src/components/Shared/Icon";
|
import { Icon } from "src/components/Shared/Icon";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
const validTabs = ["default", "scenes", "performers", "subgroups"] as const;
|
const validTabs = ["default", "scenes", "performers", "subgroups"] as const;
|
||||||
type TabKey = (typeof validTabs)[number];
|
type TabKey = (typeof validTabs)[number];
|
||||||
@@ -276,7 +277,7 @@ const GroupPage: React.FC<IProps> = ({ group, tabKey }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.goBack();
|
goBackOrReplace(history, "/groups");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEditing(value?: boolean) {
|
function toggleEditing(value?: boolean) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import TextUtils from "src/utils/text";
|
|||||||
import { RatingSystem } from "src/components/Shared/Rating/RatingSystem";
|
import { RatingSystem } from "src/components/Shared/Rating/RatingSystem";
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
image: GQL.ImageDataFragment;
|
image: GQL.ImageDataFragment;
|
||||||
@@ -156,7 +157,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
|
|||||||
function onDeleteDialogClosed(deleted: boolean) {
|
function onDeleteDialogClosed(deleted: boolean) {
|
||||||
setIsDeleteAlertOpen(false);
|
setIsDeleteAlertOpen(false);
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
history.goBack();
|
goBackOrReplace(history, "/images");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import { HeaderImage } from "src/components/Shared/DetailsPage/HeaderImage";
|
|||||||
import { LightboxLink } from "src/hooks/Lightbox/LightboxLink";
|
import { LightboxLink } from "src/hooks/Lightbox/LightboxLink";
|
||||||
import { PatchComponent } from "src/patch";
|
import { PatchComponent } from "src/patch";
|
||||||
import { ILightboxImage } from "src/hooks/Lightbox/types";
|
import { ILightboxImage } from "src/hooks/Lightbox/types";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
performer: GQL.PerformerDataFragment;
|
performer: GQL.PerformerDataFragment;
|
||||||
@@ -330,7 +331,7 @@ const PerformerPage: React.FC<IProps> = PatchComponent(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.goBack();
|
goBackOrReplace(history, "/performers");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEditing(value?: boolean) {
|
function toggleEditing(value?: boolean) {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import { lazyComponent } from "src/utils/lazyComponent";
|
|||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
import { TruncatedText } from "src/components/Shared/TruncatedText";
|
||||||
import { PatchComponent, PatchContainerComponent } from "src/patch";
|
import { PatchComponent, PatchContainerComponent } from "src/patch";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
const SubmitStashBoxDraft = lazyComponent(
|
const SubmitStashBoxDraft = lazyComponent(
|
||||||
() => import("src/components/Dialogs/SubmitDraft")
|
() => import("src/components/Dialogs/SubmitDraft")
|
||||||
@@ -909,7 +910,7 @@ const SceneLoader: React.FC<RouteComponentProps<ISceneParams>> = ({
|
|||||||
) {
|
) {
|
||||||
loadScene(queueScenes[currentQueueIndex + 1].id);
|
loadScene(queueScenes[currentQueueIndex + 1].id);
|
||||||
} else {
|
} else {
|
||||||
history.goBack();
|
goBackOrReplace(history, "/scenes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import { FavoriteIcon } from "src/components/Shared/FavoriteIcon";
|
|||||||
import { ExternalLinkButtons } from "src/components/Shared/ExternalLinksButton";
|
import { ExternalLinkButtons } from "src/components/Shared/ExternalLinksButton";
|
||||||
import { AliasList } from "src/components/Shared/DetailsPage/AliasList";
|
import { AliasList } from "src/components/Shared/DetailsPage/AliasList";
|
||||||
import { HeaderImage } from "src/components/Shared/DetailsPage/HeaderImage";
|
import { HeaderImage } from "src/components/Shared/DetailsPage/HeaderImage";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
studio: GQL.StudioDataFragment;
|
studio: GQL.StudioDataFragment;
|
||||||
@@ -378,7 +379,7 @@ const StudioPage: React.FC<IProps> = ({ studio, tabKey }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.goBack();
|
goBackOrReplace(history, "/studios");
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDeleteAlert() {
|
function renderDeleteAlert() {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import { ExpandCollapseButton } from "src/components/Shared/CollapseButton";
|
|||||||
import { FavoriteIcon } from "src/components/Shared/FavoriteIcon";
|
import { FavoriteIcon } from "src/components/Shared/FavoriteIcon";
|
||||||
import { AliasList } from "src/components/Shared/DetailsPage/AliasList";
|
import { AliasList } from "src/components/Shared/DetailsPage/AliasList";
|
||||||
import { HeaderImage } from "src/components/Shared/DetailsPage/HeaderImage";
|
import { HeaderImage } from "src/components/Shared/DetailsPage/HeaderImage";
|
||||||
|
import { goBackOrReplace } from "src/utils/history";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
tag: GQL.TagDataFragment;
|
tag: GQL.TagDataFragment;
|
||||||
@@ -420,7 +421,7 @@ const TagPage: React.FC<IProps> = ({ tag, tabKey }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
history.goBack();
|
goBackOrReplace(history, "/tags");
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDeleteAlert() {
|
function renderDeleteAlert() {
|
||||||
|
|||||||
11
ui/v2.5/src/utils/history.ts
Normal file
11
ui/v2.5/src/utils/history.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { useHistory } from "react-router-dom";
|
||||||
|
|
||||||
|
type History = ReturnType<typeof useHistory>;
|
||||||
|
|
||||||
|
export function goBackOrReplace(history: History, defaultPath: string) {
|
||||||
|
if (history.length > 1) {
|
||||||
|
history.goBack();
|
||||||
|
} else {
|
||||||
|
history.replace(defaultPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user