diff --git a/CHANGELOG.md b/CHANGELOG.md index 64befff77..dfc8a0c76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Use standard prompt dialog for deleting boreholes. - Updated standard alert. - Updated styling of attachment upload button. +- It is now possible to restart a workflow from every publication status. ### Fixed @@ -28,6 +29,7 @@ - `layer_depth_to` was displayed in filter even though it was not selected in the filter settings. - Users can now only import or add new boreholes to workgroups where they have an editor role. - Label for description quality was wrong in lithology filter and settings. +- Boreholes could not be deleted in the detail view if the publication status was not `Change in progess`. ## v2.1.772 - 2024-06-27 diff --git a/src/api-legacy/v1/borehole/producer.py b/src/api-legacy/v1/borehole/producer.py index c4f7af0ed..1e3c31ea0 100644 --- a/src/api-legacy/v1/borehole/producer.py +++ b/src/api-legacy/v1/borehole/producer.py @@ -106,7 +106,6 @@ async def execute(self, request): action in [ 'CHECK', 'PATCH', - 'DELETE' ] ): # add supplier exception diff --git a/src/client/cypress/e2e/editor/publicationWorkflow.cy.js b/src/client/cypress/e2e/editor/publicationWorkflow.cy.js index d7949ee90..8ea2a3d08 100644 --- a/src/client/cypress/e2e/editor/publicationWorkflow.cy.js +++ b/src/client/cypress/e2e/editor/publicationWorkflow.cy.js @@ -1,4 +1,4 @@ -import { createBorehole, loginAsAdmin } from "../helpers/testHelpers"; +import { createBorehole, handlePrompt, loginAsAdmin } from "../helpers/testHelpers"; import { startEditing } from "../helpers/buttonHelpers.js"; const verifyColorForStatus = (status, color) => { @@ -9,7 +9,7 @@ const statusTitles = { edit: "Change in progress", control: "In review", valid: "In validation", - public: "Publication", + public: "Published", }; const verifyStatusTextsInHeader = status => { @@ -26,7 +26,7 @@ const verifyStatusTextsNotInHeader = status => { // Skip the test until deleting of boreholes is fixed (see github issue #1188) describe("Tests the publication workflow.", () => { - it.skip("Publishes a borehole without rejections", () => { + it("Publishes a borehole without rejections", () => { createBorehole({ "extended.original_name": "Borehole to publish" }).as("borehole_id"); cy.get("@borehole_id").then(id => { loginAsAdmin(); @@ -49,6 +49,28 @@ describe("Tests the publication workflow.", () => { verifyColorForStatus("edit", "green"); verifyColorForStatus("control", "orange"); + // Restart workflow + startEditing(); + cy.get('[data-cy="workflow_restart"]').click(); + cy.get('[data-cy="workflow_dialog_confirm_restart"]').click(); + cy.wait("@workflow_edit_list"); + + verifyStatusTextsInHeader(["edit", "control"]); + verifyStatusTextsNotInHeader(["valid", "public"]); + verifyColorForStatus("edit", "orange"); + verifyColorForStatus("control", "red"); + + // Submit for review + startEditing(); + cy.get("[data-cy=workflow_submit]").click(); + cy.get("[data-cy=workflow_dialog_submit]").click(); + cy.wait("@workflow_edit_list"); + + verifyStatusTextsInHeader(["edit", "control"]); + verifyStatusTextsNotInHeader(["valid", "public"]); + verifyColorForStatus("edit", "green"); + verifyColorForStatus("control", "orange"); + // Submit for validation startEditing(); cy.get('[data-cy="workflow_submit"]').click(); @@ -85,8 +107,6 @@ describe("Tests the publication workflow.", () => { // Restart workflow startEditing(); cy.get('[data-cy="workflow_restart"]').click(); - cy.wait("@workflow_edit_list"); - cy.get('[data-cy="workflow_dialog_confirm_restart"]').click(); cy.wait("@workflow_edit_list"); @@ -95,4 +115,24 @@ describe("Tests the publication workflow.", () => { verifyColorForStatus("valid", "red"); verifyColorForStatus("public", "red"); }); + + it("Deletes a borehole if its publication status is not Change in Progress", () => { + createBorehole({ "extended.original_name": "Borehole in review to delete" }).as("borehole_id"); + cy.get("@borehole_id").then(id => { + loginAsAdmin(); + cy.visit(`/${id}/status`); + }); + + // Submit for review + startEditing(); + cy.get("[data-cy=workflow_submit]").click(); + cy.get("[data-cy=workflow_dialog_submit]").click(); + cy.wait("@workflow_edit_list"); + + // Delete + startEditing(); + cy.get("[data-cy=deleteborehole-button]").click(); + handlePrompt("Do you really want to delete this borehole? This cannot be undone.", "Delete"); + cy.wait(["@edit_list", "@borehole"]); + }); }); diff --git a/src/client/src/commons/form/workflow/workflowForm.jsx b/src/client/src/commons/form/workflow/workflowForm.jsx index 299d18b6a..c166f550b 100644 --- a/src/client/src/commons/form/workflow/workflowForm.jsx +++ b/src/client/src/commons/form/workflow/workflowForm.jsx @@ -283,35 +283,6 @@ class WorkflowForm extends React.Component {
- {(this.props.user.data.admin === true || - this.props.user.data?.roles.indexOf("PUBLIC") >= 0) && - role === "EDIT" && - this.props.workflow.data.role === "PUBLIC" - ? [ - , - { - if (!readOnly) { - this.setState({ - modalRestart: true, - }); - } - }}> - - , - ] - : null}
- {status[role].finished === null && - borehole.data.id !== null && - user.data.workgroups - .find(workgroup => workgroup.id === borehole.data.workgroup.id) - ?.roles.indexOf(borehole.data.role) > -1 ? ( -
-
- {role !== "EDIT" ? ( +
+ <> + {role !== "EDIT" && + borehole.data.id !== null && + user.data.workgroups + .find(workgroup => workgroup.id === borehole.data.workgroup.id) + ?.roles.indexOf(borehole.data.role) > -1 && + (status[role].finished === null || + (status[role].finished && role === "PUBLIC" && current === null)) && ( - ) : null} - - { - this.setState({ - modal: 0, - }); - }} - open={this.state.modal > 0} - size="mini"> -
- -

- -

-
- - {this.state.modal < 3 ? ( - - ) : ( + )} + {status[role].finished === null && + borehole.data.id !== null && + user.data.workgroups + .find(workgroup => workgroup.id === borehole.data.workgroup.id) + ?.roles.indexOf(borehole.data.role) > -1 && ( + <> + {role !== "EDIT" && ( )} - - -
-
- ) : null} + + + { + this.setState({ + modal: 0, + }); + }} + open={this.state.modal > 0} + size="mini"> +
+ +

+ +

+
+ + {this.state.modal < 3 ? ( + + ) : ( + + )} + + + + )} + +
) : (