Skip to content

Use StashIDPill to show stash IDs in the tagger view #5879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions ui/v2.5/src/components/Tagger/scenes/TaggerScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FormattedMessage } from "react-intl";
import { sortPerformers } from "src/core/performers";
import { Icon } from "src/components/Shared/Icon";
import { OperationButton } from "src/components/Shared/OperationButton";
import { StashIDPill } from "src/components/Shared/StashID";
import { PerformerLink, TagLink } from "src/components/Shared/TagLink";
import { TruncatedText } from "src/components/Shared/TruncatedText";
import { parsePath, prepareQueryString } from "src/components/Tagger/utils";
Expand All @@ -18,7 +19,6 @@ import {
faImage,
} from "@fortawesome/free-solid-svg-icons";
import { objectPath, objectTitle } from "src/core/files";
import { ExternalLink } from "src/components/Shared/ExternalLink";
import { ConfigurationContext } from "src/hooks/Config";
import { SceneQueue } from "src/models/sceneQueue";

Expand Down Expand Up @@ -85,6 +85,27 @@ const TaggerSceneDetails: React.FC<ITaggerSceneDetails> = ({ scene }) => {
);
};

type StashID = Pick<GQL.StashId, "endpoint" | "stash_id">;

const StashIDs: React.FC<{ stashIDs: StashID[] }> = ({ stashIDs }) => {
if (!stashIDs.length) {
return null;
}

const stashLinks = stashIDs.map((stashID) => {
const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0];
const link = base ? (
<StashIDPill stashID={stashID} linkType="scenes" />
) : (
<span className="small">{stashID.stash_id}</span>
);

return <div key={stashID.stash_id}>{link}</div>;
});

return <div className="mt-2 sub-content text-right">{stashLinks}</div>;
};

interface ITaggerScene {
scene: GQL.SlimSceneDataFragment;
url: string;
Expand Down Expand Up @@ -181,28 +202,6 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
);
}

function maybeRenderStashLinks() {
if (scene.stash_ids.length > 0) {
const stashLinks = scene.stash_ids.map((stashID) => {
const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0];
const link = base ? (
<ExternalLink
key={`${stashID.endpoint}${stashID.stash_id}`}
className="small d-block"
href={`${base}scenes/${stashID.stash_id}`}
>
{stashID.stash_id}
</ExternalLink>
) : (
<div className="small">{stashID.stash_id}</div>
);

return link;
});
return <div className="mt-2 sub-content text-right">{stashLinks}</div>;
}
}

function onSpriteClick(ev: React.MouseEvent<HTMLElement>) {
ev.preventDefault();
showLightboxImage(scene.paths.sprite ?? "");
Expand Down Expand Up @@ -276,7 +275,7 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
{errorMessage ? (
<div className="text-danger font-weight-bold">{errorMessage}</div>
) : undefined}
{maybeRenderStashLinks()}
<StashIDs stashIDs={scene.stash_ids} />
</div>
<TaggerSceneDetails scene={scene} />
</div>
Expand Down