Allow publishing generated documents as minor versions
Generated documents (asset list, risk register, SoA, ...) previously
only ever produced a new major version. Every regeneration of an
auto-built register consumed a major number, even when the change was
trivial. They now accept a minor flag and publish as
currentMajor.currentMinor+1 when set, bypassing the approval flow.
To carry the flag through cleanly, the document publish API was
refactored. The three split mutations (publishMajor, publishMinor,
requestDocumentVersionApproval) and the two bulk variants collapse
into a single publishDocument / bulkPublishDocuments, both taking the
new minor: Boolean! and a now-required changelog: String!. The same
shape flows through the CLI ("prb document publish --minor"), the MCP
tool, the n8n operations, and the Relay dialogs, where each
generated-doc dialog gains a "Publish as minor" button. Publishing
minor without an existing major is rejected with
ErrCannotPublishMinorWithoutMajor.
This is a deliberate breaking change for callers of the prior
mutations.
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishAssetListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishAssetListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishAssetListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishAssetListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishDataListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishDataListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishDataListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishDataListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -31,9 +31,7 @@ import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
|
||||
import type { PublishDialog_documentFragment$key } from "#/__generated__/core/PublishDialog_documentFragment.graphql";
|
||||
import type { PublishDialog_publishMajorMutation } from "#/__generated__/core/PublishDialog_publishMajorMutation.graphql";
|
||||
import type { PublishDialog_publishMinorMutation } from "#/__generated__/core/PublishDialog_publishMinorMutation.graphql";
|
||||
import type { PublishDialog_requestApprovalMutation } from "#/__generated__/core/PublishDialog_requestApprovalMutation.graphql";
|
||||
import type { PublishDialog_publishMutation } from "#/__generated__/core/PublishDialog_publishMutation.graphql";
|
||||
import { PeopleMultiSelectField } from "#/components/form/PeopleMultiSelectField";
|
||||
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
@@ -57,9 +55,9 @@ const documentFragment = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
const publishMajorMutation = graphql`
|
||||
mutation PublishDialog_publishMajorMutation($input: PublishMajorDocumentVersionInput!) {
|
||||
publishMajorDocumentVersion(input: $input) {
|
||||
const publishMutation = graphql`
|
||||
mutation PublishDialog_publishMutation($input: PublishDocumentInput!) {
|
||||
publishDocument(input: $input) {
|
||||
document {
|
||||
id
|
||||
status
|
||||
@@ -68,30 +66,6 @@ const publishMajorMutation = graphql`
|
||||
id
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const publishMinorMutation = graphql`
|
||||
mutation PublishDialog_publishMinorMutation($input: PublishMinorDocumentVersionInput!) {
|
||||
publishMinorDocumentVersion(input: $input) {
|
||||
document {
|
||||
id
|
||||
status
|
||||
}
|
||||
documentVersion {
|
||||
id
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const requestApprovalMutation = graphql`
|
||||
mutation PublishDialog_requestApprovalMutation(
|
||||
$input: RequestDocumentVersionApprovalInput!
|
||||
) {
|
||||
requestDocumentVersionApproval(input: $input) {
|
||||
approvalQuorum {
|
||||
id
|
||||
status
|
||||
@@ -166,62 +140,20 @@ export function PublishDialog({
|
||||
},
|
||||
}));
|
||||
|
||||
const [publishMajor, isPublishingMajor]
|
||||
= useMutation<PublishDialog_publishMajorMutation>(publishMajorMutation);
|
||||
const [publishMinor, isPublishingMinor]
|
||||
= useMutation<PublishDialog_publishMinorMutation>(publishMinorMutation);
|
||||
const [requestApproval, isRequesting]
|
||||
= useMutation<PublishDialog_requestApprovalMutation>(requestApprovalMutation);
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishDialog_publishMutation>(publishMutation);
|
||||
|
||||
const isBusy = isPublishingMajor || isPublishingMinor || isRequesting;
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
const actionRef = useRef<"publish" | "publish-minor" | "request-approval">("publish");
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const onPublishCompleted = (_: unknown, errors: ReadonlyArray<{ message: string }> | null) => {
|
||||
if (errors?.length) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: formatError(__("Failed to publish document"), [...errors]),
|
||||
variant: "error",
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Document published successfully."),
|
||||
variant: "success",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
onSuccess();
|
||||
}
|
||||
};
|
||||
|
||||
const onPublishError = (error: Error) => {
|
||||
toast({ title: __("Error"), description: error.message, variant: "error" });
|
||||
};
|
||||
|
||||
const handlePublishMajor = (data: z.infer<typeof publishSchema>) => {
|
||||
publishMajor({
|
||||
variables: { input: { documentId, changelog: data.changelog } },
|
||||
onCompleted: onPublishCompleted,
|
||||
onError: onPublishError,
|
||||
});
|
||||
};
|
||||
|
||||
const handlePublishMinor = (data: z.infer<typeof publishSchema>) => {
|
||||
publishMinor({
|
||||
variables: { input: { documentId, changelog: data.changelog } },
|
||||
onCompleted: onPublishCompleted,
|
||||
onError: onPublishError,
|
||||
});
|
||||
};
|
||||
|
||||
const onRequestApproval = (data: z.infer<typeof publishSchema>) => {
|
||||
requestApproval({
|
||||
const submit = (data: z.infer<typeof publishSchema>, minor: boolean) => {
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
documentId,
|
||||
approverIds: data.approverIds,
|
||||
minor,
|
||||
approverIds: minor ? [] : data.approverIds,
|
||||
changelog: data.changelog,
|
||||
},
|
||||
},
|
||||
@@ -229,19 +161,21 @@ export function PublishDialog({
|
||||
if (errors?.length) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: formatError(__("Failed to request approval"), errors),
|
||||
description: formatError(__("Failed to publish document"), errors),
|
||||
variant: "error",
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Approval requested successfully."),
|
||||
variant: "success",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
reset();
|
||||
onSuccess();
|
||||
return;
|
||||
}
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: !minor && data.approverIds.length > 0
|
||||
? __("Approval requested successfully.")
|
||||
: __("Document published successfully."),
|
||||
variant: "success",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
reset();
|
||||
onSuccess();
|
||||
},
|
||||
onError(error) {
|
||||
toast({ title: __("Error"), description: error.message, variant: "error" });
|
||||
@@ -253,17 +187,9 @@ export function PublishDialog({
|
||||
<Dialog className="max-w-xl" ref={dialogRef} title={__("Publish document")}>
|
||||
<form
|
||||
onSubmit={e => void handleSubmit((data) => {
|
||||
const action = actionRef.current;
|
||||
actionRef.current = "publish";
|
||||
if (action === "publish-minor") {
|
||||
handlePublishMinor(data);
|
||||
} else if (action === "request-approval") {
|
||||
onRequestApproval(data);
|
||||
} else if (data.approverIds.length > 0) {
|
||||
onRequestApproval(data);
|
||||
} else {
|
||||
handlePublishMajor(data);
|
||||
}
|
||||
const minor = minorRef.current;
|
||||
minorRef.current = false;
|
||||
submit(data, minor);
|
||||
})(e)}
|
||||
>
|
||||
<DialogContent padded>
|
||||
@@ -299,49 +225,23 @@ export function PublishDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
{hasApprovers
|
||||
? (
|
||||
<>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { actionRef.current = "publish-minor"; }}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={IconSend}
|
||||
onClick={() => { actionRef.current = "request-approval"; }}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{__("Request approval")}
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
: (
|
||||
<>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { actionRef.current = "publish-minor"; }}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={IconUpload}
|
||||
onClick={() => { actionRef.current = "publish"; }}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{__("Publish as major")}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish as major")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
@@ -30,8 +30,7 @@ import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
|
||||
import type { PublishDocumentsDialog_majorMutation } from "#/__generated__/core/PublishDocumentsDialog_majorMutation.graphql";
|
||||
import type { PublishDocumentsDialog_minorMutation } from "#/__generated__/core/PublishDocumentsDialog_minorMutation.graphql";
|
||||
import type { PublishDocumentsDialog_bulkPublishMutation } from "#/__generated__/core/PublishDocumentsDialog_bulkPublishMutation.graphql";
|
||||
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
||||
|
||||
type Props = {
|
||||
@@ -40,27 +39,11 @@ type Props = {
|
||||
onSave: () => void;
|
||||
};
|
||||
|
||||
const publishMajorMutation = graphql`
|
||||
mutation PublishDocumentsDialog_majorMutation(
|
||||
$input: BulkPublishDocumentVersionsInput!
|
||||
const bulkPublishMutation = graphql`
|
||||
mutation PublishDocumentsDialog_bulkPublishMutation(
|
||||
$input: BulkPublishDocumentsInput!
|
||||
) {
|
||||
bulkPublishMajorDocumentVersions(input: $input) {
|
||||
documentVersions {
|
||||
id
|
||||
}
|
||||
documents {
|
||||
id
|
||||
...DocumentListItemFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const publishMinorMutation = graphql`
|
||||
mutation PublishDocumentsDialog_minorMutation(
|
||||
$input: BulkPublishDocumentVersionsInput!
|
||||
) {
|
||||
bulkPublishMinorDocumentVersions(input: $input) {
|
||||
bulkPublishDocuments(input: $input) {
|
||||
documentVersions {
|
||||
id
|
||||
}
|
||||
@@ -80,18 +63,14 @@ export function PublishDocumentsDialog({
|
||||
const { __ } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const dialogRef = useDialogRef();
|
||||
const actionRef = useRef<"major" | "minor">("major");
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const schema = z.object({
|
||||
changelog: z.string().min(1, __("Changelog is required")),
|
||||
});
|
||||
|
||||
const [publishMajor, isPublishingMajor]
|
||||
= useMutation<PublishDocumentsDialog_majorMutation>(publishMajorMutation);
|
||||
const [publishMinor, isPublishingMinor]
|
||||
= useMutation<PublishDocumentsDialog_minorMutation>(publishMinorMutation);
|
||||
|
||||
const isBusy = isPublishingMajor || isPublishingMinor;
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishDocumentsDialog_bulkPublishMutation>(bulkPublishMutation);
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
@@ -103,45 +82,42 @@ export function PublishDocumentsDialog({
|
||||
},
|
||||
});
|
||||
|
||||
const onCompleted = (_: unknown, errors: ReadonlyArray<{ message: string }> | null) => {
|
||||
if (errors?.length) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: formatError(__("Failed to publish documents"), [...errors]),
|
||||
variant: "error",
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: sprintf(__("%s documents published"), documentIds.length),
|
||||
variant: "success",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
onSave();
|
||||
}
|
||||
};
|
||||
|
||||
const onError = (error: Error) => {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: error.message,
|
||||
variant: "error",
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmit = (data: z.infer<typeof schema>) => {
|
||||
const variables = {
|
||||
input: {
|
||||
documentIds,
|
||||
changelog: data.changelog,
|
||||
const minor = minorRef.current;
|
||||
minorRef.current = false;
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
documentIds,
|
||||
minor,
|
||||
changelog: data.changelog,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (actionRef.current === "minor") {
|
||||
publishMinor({ variables, onCompleted, onError });
|
||||
} else {
|
||||
publishMajor({ variables, onCompleted, onError });
|
||||
}
|
||||
onCompleted(_, errors) {
|
||||
if (errors?.length) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: formatError(__("Failed to publish documents"), [...errors]),
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: sprintf(__("%s documents published"), documentIds.length),
|
||||
variant: "success",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
onSave();
|
||||
},
|
||||
onError(error) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: error.message,
|
||||
variant: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -184,15 +160,15 @@ export function PublishDocumentsDialog({
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
disabled={isBusy}
|
||||
onClick={() => { actionRef.current = "minor"; }}
|
||||
disabled={isPublishing}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isBusy}
|
||||
onClick={() => { actionRef.current = "major"; }}
|
||||
disabled={isPublishing}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
>
|
||||
{sprintf(__("Publish %s documents"), documentIds.length)}
|
||||
</Button>
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishFindingListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishFindingListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishFindingListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishFindingListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishObligationListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishObligationListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishObligationListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishObligationListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishDataProtectionImpactAssessmentListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishDataProtectionImpactAssessmentListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishDataProtectionImpactAssessmentListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishDataProtectionImpactAssessmentListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishProcessingActivityListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishProcessingActivityListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishProcessingActivityListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishProcessingActivityListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -83,6 +83,8 @@ export function PublishTransferImpactAssessmentListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishTransferImpactAssessmentListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -90,8 +92,9 @@ export function PublishTransferImpactAssessmentListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -145,9 +148,19 @@ export function PublishTransferImpactAssessmentListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -84,6 +84,8 @@ export function PublishRiskListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishRiskListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -91,8 +93,9 @@ export function PublishRiskListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -146,9 +149,19 @@ export function PublishRiskListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -85,6 +85,8 @@ export function PublishStatementOfApplicabilityDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishStatementOfApplicabilityDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -92,8 +94,9 @@ export function PublishStatementOfApplicabilityDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
statementOfApplicabilityId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -147,9 +150,19 @@ export function PublishStatementOfApplicabilityDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useToast,
|
||||
} from "@probo/ui";
|
||||
import type { ReactNode } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMutation } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { z } from "zod";
|
||||
@@ -84,6 +84,8 @@ export function PublishVendorListDialog({
|
||||
const [publish, isPublishing]
|
||||
= useMutation<PublishVendorListDialogMutation>(publishMutation);
|
||||
|
||||
const minorRef = useRef(false);
|
||||
|
||||
const approverIds = watch("approverIds");
|
||||
const hasApprovers = approverIds.length > 0;
|
||||
|
||||
@@ -91,8 +93,9 @@ export function PublishVendorListDialog({
|
||||
publish({
|
||||
variables: {
|
||||
input: {
|
||||
minor: minorRef.current,
|
||||
organizationId,
|
||||
approverIds: data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
approverIds: !minorRef.current && data.approverIds.length > 0 ? data.approverIds : undefined,
|
||||
},
|
||||
},
|
||||
onCompleted(response) {
|
||||
@@ -146,9 +149,19 @@ export function PublishVendorListDialog({
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
icon={IconUpload}
|
||||
onClick={() => { minorRef.current = true; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{__("Publish as minor")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
icon={hasApprovers ? IconSend : IconUpload}
|
||||
onClick={() => { minorRef.current = false; }}
|
||||
disabled={isPublishing}
|
||||
>
|
||||
{hasApprovers ? __("Request approval") : __("Publish")}
|
||||
|
||||
Reference in New Issue
Block a user