Skip to content

Commit

Permalink
Update editing options in workflow (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr authored Jul 29, 2024
2 parents b0b0edc + 01279f3 commit 338397a
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 115 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion src/api-legacy/v1/borehole/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async def execute(self, request):
action in [
'CHECK',
'PATCH',
'DELETE'
]
):
# add supplier exception
Expand Down
50 changes: 45 additions & 5 deletions src/client/cypress/e2e/editor/publicationWorkflow.cy.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -9,7 +9,7 @@ const statusTitles = {
edit: "Change in progress",
control: "In review",
valid: "In validation",
public: "Publication",
public: "Published",
};

const verifyStatusTextsInHeader = status => {
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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");

Expand All @@ -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"]);
});
});
213 changes: 104 additions & 109 deletions src/client/src/commons/form/workflow/workflowForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,35 +283,6 @@ class WorkflowForm extends React.Component {
<div className="bdms-header" data-cy="workflow_status_header">
<TranslationText id={`status${role.toLowerCase()}`} />
</div>
{(this.props.user.data.admin === true ||
this.props.user.data?.roles.indexOf("PUBLIC") >= 0) &&
role === "EDIT" &&
this.props.workflow.data.role === "PUBLIC"
? [
<Icon
key="bdms-workflow-form-push-back-1"
color={readOnly ? null : "blue"}
name="repeat"
/>,
<a
key="bdms-workflow-form-push-back-2"
data-cy="workflow_restart"
className={!readOnly ? "linker" : null}
style={{
marginLeft: "0.2em",
color: readOnly ? "#787878" : null,
}}
onClick={() => {
if (!readOnly) {
this.setState({
modalRestart: true,
});
}
}}>
<TranslationText id={"flowRestart"} />
</a>,
]
: null}
</div>
<div
style={{
Expand Down Expand Up @@ -352,103 +323,127 @@ class WorkflowForm extends React.Component {
) : null}
</div>
</div>
{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 ? (
<div
style={{
flex: "1 1 100%",
padding: "0.8em 0px",
textAlign: "right",
}}>
<div>
{role !== "EDIT" ? (
<div
style={{
flex: "1 1 100%",
padding: "0.8em 0px",
textAlign: "right",
}}>
<>
{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)) && (
<Button
disabled={readOnly || workflows.isSubmitting}
data-cy="workflow_restart"
disabled={readOnly}
loading={workflows.isRejecting === true}
negative
primary
onClick={() => {
this.setState({
modal: 3,
modalRestart: true,
});
}}
size="mini">
<TranslationText id="reject" />
<TranslationText id="flowRestart" />
</Button>
) : null}
<Button
disabled={readOnly || workflows.isRejecting}
data-cy="workflow_submit"
loading={workflows.isSubmitting === true}
onClick={() => {
this.setState({
modal: 1,
});
}}
secondary
size="mini">
<TranslationText id="submit" />
</Button>
<Modal
// basic
closeIcon
onClose={() => {
this.setState({
modal: 0,
});
}}
open={this.state.modal > 0}
size="mini">
<Header content={t(`status-submit-msg-${role.toLowerCase()}`)} />
<Modal.Content>
<p>
<TranslationText id="sure" />
</p>
</Modal.Content>
<Modal.Actions>
{this.state.modal < 3 ? (
<Button
data-cy="workflow_dialog_submit"
disabled={readOnly || workflows.isRejecting}
loading={workflows.isSubmitting === true}
onClick={() => {
this.props
.submitWorkflow(status[role].id, this.state.modal === 2)
.then(() => {
this.setState({
modal: 0,
});
});
}}
secondary>
<Icon name="checkmark" />
&nbsp;
<TranslationText id="submit" />
</Button>
) : (
)}
{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" && (
<Button
disabled={readOnly || workflows.isSubmitting}
loading={workflows.isRejecting === true}
negative
onClick={() => {
this.props.rejectWorkflow(status[role].id).then(() => {
this.setState({
modal: 0,
});
this.setState({
modal: 3,
});
}}>
<Icon name="checkmark" />
&nbsp;
}}
size="mini">
<TranslationText id="reject" />
</Button>
)}
</Modal.Actions>
</Modal>
</div>
</div>
) : null}

<Button
disabled={readOnly || workflows.isRejecting}
data-cy="workflow_submit"
loading={workflows.isSubmitting === true}
onClick={() => {
this.setState({
modal: 1,
});
}}
secondary
size="mini">
<TranslationText id="submit" />
</Button>
<Modal
// basic
closeIcon
onClose={() => {
this.setState({
modal: 0,
});
}}
open={this.state.modal > 0}
size="mini">
<Header content={t(`status-submit-msg-${role.toLowerCase()}`)} />
<Modal.Content>
<p>
<TranslationText id="sure" />
</p>
</Modal.Content>
<Modal.Actions>
{this.state.modal < 3 ? (
<Button
data-cy="workflow_dialog_submit"
disabled={readOnly || workflows.isRejecting}
loading={workflows.isSubmitting === true}
onClick={() => {
this.props
.submitWorkflow(status[role].id, this.state.modal === 2)
.then(() => {
this.setState({
modal: 0,
});
});
}}
secondary>
<Icon name="checkmark" />
&nbsp;
<TranslationText id="submit" />
</Button>
) : (
<Button
disabled={readOnly || workflows.isSubmitting}
loading={workflows.isRejecting === true}
negative
onClick={() => {
this.props.rejectWorkflow(status[role].id).then(() => {
this.setState({
modal: 0,
});
});
}}>
<Icon name="checkmark" />
&nbsp;
<TranslationText id="reject" />
</Button>
)}
</Modal.Actions>
</Modal>
</>
)}
</>
</div>
</div>
) : (
<div
Expand Down

0 comments on commit 338397a

Please sign in to comment.