Skip to content

Commit 48a2204

Browse files
smith113-pWithoutPants
authored andcommitted
Use StashIDPill to show stash IDs in the tagger view (stashapp#5879)
* Use StashIDPill to show stash IDs in the tagger view This is visually nicer, but more importantly, lets you see easily which stash-boxes are already associated with this scene. * Move into separate component. Add key --------- Co-authored-by: WithoutPants <[email protected]>
1 parent ce19c20 commit 48a2204

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

ui/v2.5/src/components/Tagger/scenes/TaggerScene.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormattedMessage } from "react-intl";
77
import { sortPerformers } from "src/core/performers";
88
import { Icon } from "src/components/Shared/Icon";
99
import { OperationButton } from "src/components/Shared/OperationButton";
10+
import { StashIDPill } from "src/components/Shared/StashID";
1011
import { PerformerLink, TagLink } from "src/components/Shared/TagLink";
1112
import { TruncatedText } from "src/components/Shared/TruncatedText";
1213
import { parsePath, prepareQueryString } from "src/components/Tagger/utils";
@@ -18,7 +19,6 @@ import {
1819
faImage,
1920
} from "@fortawesome/free-solid-svg-icons";
2021
import { objectPath, objectTitle } from "src/core/files";
21-
import { ExternalLink } from "src/components/Shared/ExternalLink";
2222
import { ConfigurationContext } from "src/hooks/Config";
2323
import { SceneQueue } from "src/models/sceneQueue";
2424

@@ -85,6 +85,27 @@ const TaggerSceneDetails: React.FC<ITaggerSceneDetails> = ({ scene }) => {
8585
);
8686
};
8787

88+
type StashID = Pick<GQL.StashId, "endpoint" | "stash_id">;
89+
90+
const StashIDs: React.FC<{ stashIDs: StashID[] }> = ({ stashIDs }) => {
91+
if (!stashIDs.length) {
92+
return null;
93+
}
94+
95+
const stashLinks = stashIDs.map((stashID) => {
96+
const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0];
97+
const link = base ? (
98+
<StashIDPill stashID={stashID} linkType="scenes" />
99+
) : (
100+
<span className="small">{stashID.stash_id}</span>
101+
);
102+
103+
return <div key={stashID.stash_id}>{link}</div>;
104+
});
105+
106+
return <div className="mt-2 sub-content text-right">{stashLinks}</div>;
107+
};
108+
88109
interface ITaggerScene {
89110
scene: GQL.SlimSceneDataFragment;
90111
url: string;
@@ -181,28 +202,6 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
181202
);
182203
}
183204

184-
function maybeRenderStashLinks() {
185-
if (scene.stash_ids.length > 0) {
186-
const stashLinks = scene.stash_ids.map((stashID) => {
187-
const base = stashID.endpoint.match(/https?:\/\/.*?\//)?.[0];
188-
const link = base ? (
189-
<ExternalLink
190-
key={`${stashID.endpoint}${stashID.stash_id}`}
191-
className="small d-block"
192-
href={`${base}scenes/${stashID.stash_id}`}
193-
>
194-
{stashID.stash_id}
195-
</ExternalLink>
196-
) : (
197-
<div className="small">{stashID.stash_id}</div>
198-
);
199-
200-
return link;
201-
});
202-
return <div className="mt-2 sub-content text-right">{stashLinks}</div>;
203-
}
204-
}
205-
206205
function onSpriteClick(ev: React.MouseEvent<HTMLElement>) {
207206
ev.preventDefault();
208207
showLightboxImage(scene.paths.sprite ?? "");
@@ -276,7 +275,7 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
276275
{errorMessage ? (
277276
<div className="text-danger font-weight-bold">{errorMessage}</div>
278277
) : undefined}
279-
{maybeRenderStashLinks()}
278+
<StashIDs stashIDs={scene.stash_ids} />
280279
</div>
281280
<TaggerSceneDetails scene={scene} />
282281
</div>

0 commit comments

Comments
 (0)