diff --git a/public/locales/de-DE/translation.json b/public/locales/de-DE/translation.json index 5f7d6a9..5423267 100644 --- a/public/locales/de-DE/translation.json +++ b/public/locales/de-DE/translation.json @@ -405,6 +405,7 @@ "deployment-id": "Deployment-ID", "decision-requirements-id": "Entscheidungsanforderungs-Definitions-ID", "history-ttl": "Verlaufs-Aufbewahrungsdauer", + "history-ttl-updated": "Verlaufs-Aufbewahrungsdauer aktualisiert.", "sort": { "name": "Name", "key": "Schlüssel", diff --git a/public/locales/en-US/translation.json b/public/locales/en-US/translation.json index ac20fbe..8dc1bea 100644 --- a/public/locales/en-US/translation.json +++ b/public/locales/en-US/translation.json @@ -405,6 +405,7 @@ "deployment-id": "Deployment ID", "decision-requirements-id": "Decision Requirements Definition ID", "history-ttl": "History Time To Live", + "history-ttl-updated": "History time to live updated.", "sort": { "name": "Name", "key": "Key", diff --git a/public/locales/es-ES/translation.json b/public/locales/es-ES/translation.json index 121792c..2faed2a 100644 --- a/public/locales/es-ES/translation.json +++ b/public/locales/es-ES/translation.json @@ -372,6 +372,7 @@ "deployment-id": "ID de despliegue", "decision-requirements-id": "ID de definición de requisitos de decisión", "history-ttl": "Tiempo de vida del historial", + "history-ttl-updated": "Tiempo de vida del historial actualizado.", "sort": { "name": "Nombre", "key": "Clave", diff --git a/public/locales/fr-FR/translation.json b/public/locales/fr-FR/translation.json index 43e715f..3218868 100644 --- a/public/locales/fr-FR/translation.json +++ b/public/locales/fr-FR/translation.json @@ -372,6 +372,7 @@ "deployment-id": "ID de déploiement", "decision-requirements-id": "ID de définition des exigences de décision", "history-ttl": "Durée de conservation de l'historique", + "history-ttl-updated": "Durée de conservation de l'historique mise à jour.", "sort": { "name": "Nom", "key": "Clé", diff --git a/public/locales/nl-NL/translation.json b/public/locales/nl-NL/translation.json index a27f3a1..2813b96 100644 --- a/public/locales/nl-NL/translation.json +++ b/public/locales/nl-NL/translation.json @@ -372,6 +372,7 @@ "deployment-id": "Deployment-ID", "decision-requirements-id": "Beslissingsvereisten-definitie-ID", "history-ttl": "Bewaartermijn geschiedenis", + "history-ttl-updated": "Bewaartermijn geschiedenis bijgewerkt.", "sort": { "name": "Naam", "key": "Sleutel", diff --git a/src/api/resources/decision.js b/src/api/resources/decision.js index a2c3857..17d9a0d 100644 --- a/src/api/resources/decision.js +++ b/src/api/resources/decision.js @@ -1,4 +1,4 @@ -import { GET, GET_TEXT } from '../helper.jsx' +import { GET, PUT } from '../helper.jsx' const get_decision_definition = (state, id) => @@ -13,11 +13,20 @@ const get_decision_definitions = (state, params = {}) => { const get_dmn_xml = (state, id) => GET(`/decision-definition/${id}/xml`, state, state.api.decision.dmn) +const update_history_ttl = (state, id, historyTimeToLive) => + PUT( + `/decision-definition/${id}/history-time-to-live`, + { historyTimeToLive }, + state, + state.api.decision.update_history_ttl, + ) + const decision = { get_decision_definition, get_decision_definitions, get_dmn_xml, + update_history_ttl, } export default decision diff --git a/src/api/resources/decision.test.js b/src/api/resources/decision.test.js index 2a7a0e7..e2b996c 100644 --- a/src/api/resources/decision.test.js +++ b/src/api/resources/decision.test.js @@ -3,9 +3,10 @@ import { describe, it, vi, beforeEach } from "vitest"; vi.mock("../helper.jsx", () => ({ GET: vi.fn(), GET_TEXT: vi.fn(), + PUT: vi.fn(), })); -import { GET } from "../helper.jsx"; +import { GET, PUT } from "../helper.jsx"; import { create_mock_state, expect_api_call } from "../../test/helpers.js"; import decision from "./decision.js"; @@ -41,4 +42,14 @@ describe("api/resources/decision", () => { signal: state.api.decision.dmn, }); }); + + it("update_history_ttl() PUTs the history time to live", () => { + decision.update_history_ttl(state, "dec-1", 30); + expect_api_call(PUT, { + url: "/decision-definition/dec-1/history-time-to-live", + body: { historyTimeToLive: 30 }, + state, + signal: state.api.decision.update_history_ttl, + }); + }); }); diff --git a/src/pages/Decisions.jsx b/src/pages/Decisions.jsx index 9a73c30..d79a05d 100644 --- a/src/pages/Decisions.jsx +++ b/src/pages/Decisions.jsx @@ -1,4 +1,5 @@ import { useContext, useEffect } from 'preact/hooks' +import { useSignal, useSignalEffect } from '@preact/signals' import { useTranslation } from 'react-i18next' import { AppState } from '../state.js' import { useLocation, useRoute } from 'preact-iso' @@ -170,9 +171,24 @@ const DecisionsList = () => { const DecisionDetails = () => { const state = useContext(AppState), - { api: { decision: { definition, dmn } } } = state, - { params: { decision_id } } = useRoute(), - [t] = useTranslation() + { api: { decision: { definition, dmn, update_history_ttl } } } = state, + [t] = useTranslation(), + history_ttl = useSignal('') + + useSignalEffect(() => { + history_ttl.value = definition.value?.data?.historyTimeToLive ?? '' + }) + + const submit_history_ttl = async (e, id) => { + e.preventDefault() + const raw = history_ttl.peek() + await engine_rest.decision.update_history_ttl( + state, + id, + raw === '' ? null : Number(raw), + ) + void engine_rest.decision.get_decision_definition(state, id) + } return
{t("decisions.history-ttl-updated")}
} /> +