Fix parent/child links on tag pages (#3978)

This commit is contained in:
WithoutPants 2023-08-01 14:14:28 +10:00 committed by GitHub
parent 29fb570582
commit 15f91fda13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View file

@ -34,7 +34,7 @@ type SceneMarkerFragment = Pick<GQL.SceneMarker, "id" | "title" | "seconds"> & {
interface IProps {
tag?: Partial<TagDataFragment>;
tagType?: "performer" | "scene" | "gallery" | "image";
tagType?: "performer" | "scene" | "gallery" | "image" | "details";
performer?: Partial<PerformerDataFragment>;
marker?: SceneMarkerFragment;
movie?: Partial<MovieDataFragment>;
@ -49,6 +49,7 @@ export const TagLink: React.FC<IProps> = (props: IProps) => {
let link: string = "#";
let title: string = "";
if (props.tag) {
id = props.tag.id || "";
switch (props.tagType) {
case "scene":
case undefined:
@ -63,8 +64,10 @@ export const TagLink: React.FC<IProps> = (props: IProps) => {
case "image":
link = NavUtils.makeTagImagesUrl(props.tag);
break;
case "details":
link = NavUtils.makeTagUrl(id);
break;
}
id = props.tag.id || "";
title = props.tag.name || "";
} else if (props.performer) {
link = NavUtils.makePerformerScenesUrl(props.performer);

View file

@ -17,7 +17,12 @@ export const TagDetailsPanel: React.FC<ITagDetails> = ({ tag, fullWidth }) => {
return (
<>
{tag.parents.map((p) => (
<TagLink key={p.id} tag={p} hoverPlacement="bottom" />
<TagLink
key={p.id}
tag={p}
hoverPlacement="bottom"
tagType="details"
/>
))}
</>
);
@ -31,7 +36,12 @@ export const TagDetailsPanel: React.FC<ITagDetails> = ({ tag, fullWidth }) => {
return (
<>
{tag.children.map((c) => (
<TagLink key={c.id} tag={c} hoverPlacement="bottom" />
<TagLink
key={c.id}
tag={c}
hoverPlacement="bottom"
tagType="details"
/>
))}
</>
);

View file

@ -213,6 +213,10 @@ const makeMovieScenesUrl = (movie: Partial<GQL.MovieDataFragment>) => {
return `/scenes?${filter.makeQueryParameters()}`;
};
const makeTagUrl = (id: string) => {
return `/tags/${id}`;
};
const makeParentTagsUrl = (tag: Partial<GQL.TagDataFragment>) => {
if (!tag.id) return "#";
const filter = new ListFilterModel(GQL.FilterMode.Tags, undefined);
@ -373,6 +377,7 @@ const NavUtils = {
makeStudioGalleriesUrl,
makeStudioMoviesUrl,
makeStudioPerformersUrl,
makeTagUrl,
makeParentTagsUrl,
makeChildTagsUrl,
makeTagSceneMarkersUrl,