Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions public/locales/de-DE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@
"groups": "Gruppen",
"users": "Benutzer"
},
"variables": {
"add": "Variable hinzufügen",
"name": "Variablenname",
"type": "Variablentyp",
"value": "Variablenwert",
"confirm-delete": "Variable {{name}} löschen?",
"success-updated": "Variable aktualisiert.",
"success-deleted": "Variable gelöscht."
},
"called-instances": {
"called-process-instance": "Aufgerufene Prozessinstanz",
"process-definition": "Prozessdefinition"
Expand Down
9 changes: 9 additions & 0 deletions public/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@
"groups": "Groups",
"users": "Users"
},
"variables": {
"add": "Add Variable",
"name": "Variable Name",
"type": "Variable Type",
"value": "Variable Value",
"confirm-delete": "Delete variable {{name}}?",
"success-updated": "Variable updated.",
"success-deleted": "Variable deleted."
},
"called-instances": {
"called-process-instance": "Called Process Instance",
"process-definition": "Process Definition"
Expand Down
20 changes: 19 additions & 1 deletion src/api/resources/process_instance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GET, POST } from "../helper.jsx";
import { DELETE, GET, POST, PUT } from "../helper.jsx";

const get_process_instance = (state, instance_id) =>
GET(
Expand Down Expand Up @@ -33,6 +33,22 @@ const get_process_instance_variables = (state, instance_id) =>
state.api.process.instance.variables,
);

const update_process_instance_variable = (state, instance_id, variable_name, body) =>
PUT(
`/process-instance/${instance_id}/variables/${encodeURIComponent(variable_name)}`,
body,
state,
state.api.process.instance.variable_update,
);

const delete_process_instance_variable = (state, instance_id, variable_name) =>
DELETE(
`/process-instance/${instance_id}/variables/${encodeURIComponent(variable_name)}`,
null,
state,
state.api.process.instance.variable_delete,
);

const get_called_process_instances = (state, instance_id) =>
GET(
`/process-instance?superProcessInstance=${instance_id}`,
Expand Down Expand Up @@ -105,6 +121,8 @@ const modify_process_instance_async = (
const process_instance = {
one: get_process_instance,
variables: get_process_instance_variables,
update_variable: update_process_instance_variable,
delete_variable: delete_process_instance_variable,
called: get_called_process_instances,
count: get_process_instance_count,
all: get_all_process_instances,
Expand Down
25 changes: 24 additions & 1 deletion src/api/resources/process_instance.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { describe, it, vi, beforeEach } from "vitest";

vi.mock("../helper.jsx", () => ({
DELETE: vi.fn(),
GET: vi.fn(),
POST: vi.fn(),
PUT: vi.fn(),
}));

import { GET, POST } from "../helper.jsx";
import { DELETE, GET, POST, PUT } from "../helper.jsx";
import { create_mock_state, expect_api_call } from "../../test/helpers.js";
import process_instance from "./process_instance.js";

Expand Down Expand Up @@ -33,6 +35,27 @@ describe("api/resources/process_instance", () => {
});
});

it("update_variable() PUTs a variable payload", () => {
const body = { type: "Integer", value: 42 };
process_instance.update_variable(state, "inst-1", "amount total", body);
expect_api_call(PUT, {
url: "/process-instance/inst-1/variables/amount%20total",
body,
state,
signal: state.api.process.instance.variable_update,
});
});

it("delete_variable() DELETEs the variable endpoint", () => {
process_instance.delete_variable(state, "inst-1", "amount total");
expect_api_call(DELETE, {
url: "/process-instance/inst-1/variables/amount%20total",
body: null,
state,
signal: state.api.process.instance.variable_delete,
});
});

it("called() GETs sub process instances by superProcessInstance", () => {
process_instance.called(state, "inst-1");
expect_api_call(GET, {
Expand Down
Loading