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
2 changes: 2 additions & 0 deletions public/locales/de-DE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@
"definition-id": "Definitions-ID",
"definition-details": "Definitionsdetails",
"tenant-id": "Mandanten-ID",
"history-ttl": "Verlaufs-Aufbewahrungsdauer",
"history-ttl-updated": "Verlaufs-Aufbewahrungsdauer aktualisiert.",
"click-to-copy": "Klicken zum Kopieren",
"history-mode-active": "Verlaufsmodus aktiv",
"enable-history-mode": "Verlaufsmodus aktivieren",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@
"definition-id": "Definition ID",
"definition-details": "Definition details",
"tenant-id": "Tenant ID",
"history-ttl": "History Time To Live",
"history-ttl-updated": "History time to live updated.",
"click-to-copy": "Click to copy",
"history-mode-active": "History Mode Active",
"enable-history-mode": "Enable History Mode",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/es-ES/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@
"change-definition": "Cambiar definición",
"definition-id": "ID de definición",
"tenant-id": "ID del inquilino",
"history-ttl": "Tiempo de vida del historial",
"history-ttl-updated": "Tiempo de vida del historial actualizado.",
"click-to-copy": "Clic para copiar",
"history-mode-active": "Modo historial activo",
"enable-history-mode": "Activar modo historial",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fr-FR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@
"change-definition": "Changer de définition",
"definition-id": "ID de définition",
"tenant-id": "ID du locataire",
"history-ttl": "Durée de conservation de l'historique",
"history-ttl-updated": "Durée de conservation de l'historique mise à jour.",
"click-to-copy": "Cliquer pour copier",
"history-mode-active": "Mode historique actif",
"enable-history-mode": "Activer le mode historique",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/nl-NL/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@
"change-definition": "Definitie wijzigen",
"definition-id": "Definitie-ID",
"tenant-id": "Tenant-ID",
"history-ttl": "Bewaartermijn geschiedenis",
"history-ttl-updated": "Bewaartermijn geschiedenis bijgewerkt.",
"click-to-copy": "Klik om te kopiëren",
"history-mode-active": "Geschiedenismodus actief",
"enable-history-mode": "Geschiedenismodus inschakelen",
Expand Down
9 changes: 9 additions & 0 deletions src/api/resources/process_definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ const activate_process_definition = (state, id) =>
state.api.process.definition.suspend,
)

const update_history_ttl = (state, id, historyTimeToLive) =>
PUT(
`/process-definition/${id}/history-time-to-live`,
{ historyTimeToLive },
state,
state.api.process.definition.update_history_ttl,
)

const delete_process_definition = (state, id) =>
DELETE(
`/process-definition/${id}?cascade=true`,
Expand All @@ -129,6 +137,7 @@ const process_definition = {
activity_instance_statistics: get_activity_instance_statistics,
suspend: suspend_process_definition,
activate: activate_process_definition,
update_history_ttl,
remove: delete_process_definition,
}

Expand Down
10 changes: 10 additions & 0 deletions src/api/resources/process_definition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ describe("api/resources/process_definition", () => {
});
});

it("update_history_ttl() PUTs the history time to live", () => {
process_definition.update_history_ttl(state, "def-1", 30);
expect_api_call(PUT, {
url: "/process-definition/def-1/history-time-to-live",
body: { historyTimeToLive: 30 },
state,
signal: state.api.process.definition.update_history_ttl,
});
});

it("remove() DELETEs with cascade=true", () => {
process_definition.remove(state, "def-1");
expect_api_call(DELETE, {
Expand Down
69 changes: 50 additions & 19 deletions src/pages/Processes.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSignal } from "@preact/signals";
import { useSignal, useSignalEffect } from "@preact/signals";
import { useContext, useEffect } from "preact/hooks";
import { useLocation, useRoute } from "preact-iso";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -686,7 +686,7 @@ const DefinitionsEmpty = () => {
<a
href="https://docs.operaton.org/manual/latest/installation/full/tomcat/manual/"
target="_blank"
rel="noopener"
rel="noreferrer"
>
{t("processes.empty.how-to")}
</a>
Expand Down Expand Up @@ -716,14 +716,32 @@ const ProcessDefinitionDetails = () => {
};

const DefinitionOverview = () => {
const {
const state = useContext(AppState),
{
api: {
process: {
definition: { one: process_definition, statistics },
definition: { one: process_definition, statistics, update_history_ttl },
},
},
} = useContext(AppState),
[t] = useTranslation();
} = state,
[t] = useTranslation(),
history_ttl = useSignal("");

useSignalEffect(() => {
history_ttl.value =
process_definition.value?.data?.historyTimeToLive ?? "";
});

const submit_history_ttl = async (e, id) => {
e.preventDefault();
const raw = history_ttl.peek();
await engine_rest.process_definition.update_history_ttl(
state,
id,
raw === "" ? null : Number(raw),
);
void engine_rest.process_definition.one(state, id);
};

/** @namespace process_definition.value.data.tenantId **/
/** @namespace process_definition.value.data.deploymentId **/
Expand Down Expand Up @@ -771,6 +789,29 @@ const DefinitionOverview = () => {
<dt>{t("processes.tabs.incidents")}</dt>
<dd>{total_incidents}</dd>
</dl>
<RequestState
signal={update_history_ttl}
on_nothing={() => <></>}
on_success={() => (
<p class="success">{t("processes.history-ttl-updated")}</p>
)}
/>
<form
class="history-ttl-form"
onSubmit={(e) => submit_history_ttl(e, def.id)}
>
<label for="history-ttl">{t("processes.history-ttl")}</label>
<input
id="history-ttl"
name="historyTimeToLive"
type="number"
min="0"
step="1"
value={history_ttl.value}
onInput={(e) => (history_ttl.value = e.currentTarget.value)}
/>
<button type="submit">{t("common.save")}</button>
</form>
</div>
);
}}
Expand Down Expand Up @@ -928,8 +969,7 @@ const InstanceDetails = () => {
params: { selection_id, definition_id, panel },
query,
} = useRoute(),
history_mode = query.history === "true",
[t] = useTranslation();
history_mode = query.history === "true";

if (selection_id) {
if (
Expand Down Expand Up @@ -1044,19 +1084,17 @@ const InstanceVariables = () => {
? Object.entries(
state.api.process.instance.variables.value.data,
).map(
// eslint-disable-next-line react/jsx-key
([name, { type, value }]) => (
<tr>
<tr key={name}>
<td>{name}</td>
<td>{type}</td>
<td>{value}</td>
</tr>
),
)
: state.api.process.instance.variables.value.data.map(
// eslint-disable-next-line react/jsx-key
({ name, type, value }) => (
<tr>
<tr key={name}>
<td>{name}</td>
<td>{type}</td>
<td>{value}</td>
Expand Down Expand Up @@ -1464,13 +1502,6 @@ const JobDefinitions = () => {
);
};

const BackToListBtn = ({ url, title, className }) => (
<a className={`tabs-back ${className || ""}`} href={url} title={title}>
<Icons.arrow_left />
<Icons.list />
</a>
);

const DefinitionsManage = () => {
const state = useContext(AppState),
{ route } = useLocation(),
Expand Down
48 changes: 48 additions & 0 deletions src/pages/Processes.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,54 @@ describe("ProcessesPage — definition detail fetches", () => {
// Heading shows the definition name.
expect(getAllByText("Invoice").length).toBeGreaterThan(0);
});

it("updates the process definition history time to live", async () => {
mockParams = { definition_id: "proc:1" };
signal_response(state.api.process.definition.one, {
id: "proc:1",
name: "Invoice",
key: "invoice",
version: 2,
historyTimeToLive: 30,
});
const { container, getByLabelText } = renderPage(state);

fireEvent.input(getByLabelText("processes.history-ttl"), {
target: { value: "45" },
});
fireEvent.submit(container.querySelector("form.history-ttl-form"));
await Promise.resolve();

expect(engine_rest.process_definition.update_history_ttl).toHaveBeenCalled();
const call = engine_rest.process_definition.update_history_ttl.mock.lastCall;
expect(call[0]).toBe(state);
expect(call[1]).toBe("proc:1");
expect(call[2]).toBe(45);
});

it("clears the process definition history time to live with an empty value", async () => {
mockParams = { definition_id: "proc:1" };
signal_response(state.api.process.definition.one, {
id: "proc:1",
name: "Invoice",
key: "invoice",
version: 2,
historyTimeToLive: 30,
});
const { container, getByLabelText } = renderPage(state);

fireEvent.input(getByLabelText("processes.history-ttl"), {
target: { value: "" },
});
fireEvent.submit(container.querySelector("form.history-ttl-form"));
await Promise.resolve();

expect(engine_rest.process_definition.update_history_ttl).toHaveBeenCalled();
const call = engine_rest.process_definition.update_history_ttl.mock.lastCall;
expect(call[0]).toBe(state);
expect(call[1]).toBe("proc:1");
expect(call[2]).toBeNull();
});
});

describe("ProcessesPage — definition tabs", () => {
Expand Down
1 change: 1 addition & 0 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const createAppState = () => {
rendered_form: signal(null),
activity_instance_statistics: signal(null),
suspend: signal(null),
update_history_ttl: signal(null),
remove: signal(null),
saved_filters: signal(null),
},
Expand Down