Add support for submitting stash-box scene updates by draft (#2577)

This commit is contained in:
InfiniteTF
2022-06-01 06:53:31 +02:00
committed by GitHub
parent e51083c26d
commit d68d022893
8 changed files with 332 additions and 267 deletions

View File

@@ -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>
</>
) : (
<>