mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Add support for submitting stash-box scene updates by draft (#2577)
This commit is contained in:
@@ -8,7 +8,12 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||
|
||||
interface IProps {
|
||||
show: boolean;
|
||||
entity: { name?: string | null; id: string; title?: string | null };
|
||||
entity: {
|
||||
name?: string | null;
|
||||
id: string;
|
||||
title?: string | null;
|
||||
stash_ids: { stash_id: string; endpoint: string }[];
|
||||
};
|
||||
boxes: Pick<GQL.StashBox, "name" | "endpoint">[];
|
||||
query: DocumentNode;
|
||||
onHide: () => void;
|
||||
@@ -59,6 +64,12 @@ export const SubmitStashBoxDraft: React.FC<IProps> = ({
|
||||
const handleSelectBox = (e: React.ChangeEvent<HTMLSelectElement>) =>
|
||||
setSelectedBox(Number.parseInt(e.currentTarget.value) ?? 0);
|
||||
|
||||
// If the scene has an attached stash_id from that endpoint, the operation will be an update
|
||||
const isUpdate =
|
||||
entity.stash_ids.find(
|
||||
(id) => id.endpoint === boxes[selectedBox].endpoint
|
||||
) !== undefined;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
icon="paper-plane"
|
||||
@@ -87,10 +98,24 @@ export const SubmitStashBoxDraft: React.FC<IProps> = ({
|
||||
))}
|
||||
</Form.Control>
|
||||
</Form.Group>
|
||||
<Button onClick={handleSubmit}>
|
||||
<FormattedMessage id="actions.submit" />{" "}
|
||||
{`"${entity.name ?? entity.title}"`}
|
||||
</Button>
|
||||
<div className="text-right">
|
||||
{isUpdate && (
|
||||
<span className="mr-2">
|
||||
<FormattedMessage
|
||||
id="stashbox.submit_update"
|
||||
values={{ endpoint_name: boxes[selectedBox].name }}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
variant={isUpdate ? "primary" : "success"}
|
||||
>
|
||||
<FormattedMessage
|
||||
id={`actions.${isUpdate ? "submit_update" : "submit"}`}
|
||||
/>{" "}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user