Skip to content

Commit

Permalink
feat(client): Ability to set a default history time to live via flags…
Browse files Browse the repository at this point in the history
….json

Related to #3869, #4062

Signed-off-by: Bhandari, Prajwol <[email protected]>
  • Loading branch information
prajwolbhandari1 committed Feb 26, 2024
1 parent 5decf2e commit 72be508
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
15 changes: 13 additions & 2 deletions client/src/app/TabsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ import Flags, {
DISABLE_ZEEBE,
DISABLE_PLATFORM,
DISABLE_CMMN,
DISABLE_HTTL_HINT
DISABLE_HTTL_HINT,
DEFAULT_HISTORY_TTL
} from '../util/Flags';

import BPMNIcon from '../../resources/icons/file-types/BPMN-16x16.svg';
Expand Down Expand Up @@ -627,7 +628,7 @@ export default class TabsProvider {
_getInitialFileContents(type) {
const rawContents = this.getProvider(type).getInitialContents();

return rawContents && replaceExporter(replaceVersions(replaceIds(rawContents, generateId)));
return rawContents && replaceHistoryTimeToLive(replaceExporter(replaceVersions(replaceIds(rawContents, generateId))));
}

_getTabType(file) {
Expand Down Expand Up @@ -750,3 +751,13 @@ function DisableHTTLHintPlugin() {
}
};
}

function replaceHistoryTimeToLive(contents) {
if (!Flags.get(DEFAULT_HISTORY_TTL)) {
return contents.replace('camunda:historyTimeToLive="{{ DEFAULT_HISTORY_TTL }}"', '');
}
return (
contents
.replace('{{ DEFAULT_HISTORY_TTL }}', Flags.get(DEFAULT_HISTORY_TTL))
);
}
34 changes: 32 additions & 2 deletions client/src/app/__tests__/TabsProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import Flags, {
DISABLE_CMMN,
CLOUD_ENGINE_VERSION,
PLATFORM_ENGINE_VERSION,
DISABLE_HTTL_HINT
DISABLE_HTTL_HINT,
DEFAULT_HISTORY_TTL
} from '../../util/Flags';

import {
Expand Down Expand Up @@ -1134,7 +1135,6 @@ describe('TabsProvider', function() {
expect(tabsProvider.hasProvider('cmmn')).to.be.true;
});


it('should disable HTTL hint', async function() {

// given
Expand All @@ -1160,6 +1160,36 @@ describe('TabsProvider', function() {
expect(customLinter.getPlugins()).to.have.length(1);
});

it('should return default history ttl', function() {

// given
Flags.init({});
const tabsProvider = new TabsProvider();

// when
const { file: { contents } } = tabsProvider.createTab('bpmn');

// then
expect(contents).to.not.include('historyTimeToLive');

});

it('should replace history ttl placeholder with version from flag (BPMN)', function() {

// given
Flags.init({
[DEFAULT_HISTORY_TTL]: '30'
});
const tabsProvider = new TabsProvider();

// when
const { file: { contents } } = tabsProvider.createTab('bpmn');

// then
expect(contents).to.include('historyTimeToLive="30"');
});


});


Expand Down
11 changes: 1 addition & 10 deletions client/src/app/tabs/bpmn/__tests__/DiagramSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ describe('tabs/bpmn', function() {
// then
expect(contents).to.contain('id="Definitions_{{ ID }}"');
expect(contents).to.contain('id="Process_{{ ID:process }}"');
});


it('should contain defaults', function() {

// when
const contents = require('../diagram.bpmn');

// then
expect(contents).not.to.contain('camunda:historyTimeToLive="180"');
expect(contents).to.contain('historyTimeToLive="{{ DEFAULT_HISTORY_TTL }}');
});

});
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/tabs/bpmn/diagram.bpmn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_{{ ID }}" targetNamespace="http://bpmn.io/schema/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" exporter="{{ EXPORTER_NAME }}" exporterVersion="{{ EXPORTER_VERSION }}" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="{{ CAMUNDA_PLATFORM_VERSION }}">
<bpmn:process id="Process_{{ ID:process }}" isExecutable="true">
<bpmn:process id="Process_{{ ID:process }}" isExecutable="true" camunda:historyTimeToLive="{{ DEFAULT_HISTORY_TTL }}">
<bpmn:startEvent id="StartEvent_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
Expand Down
2 changes: 2 additions & 0 deletions client/src/util/Flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ export const DISPLAY_VERSION = 'display-version';
export const CLOUD_ENGINE_VERSION = 'c8-engine-version';
export const PLATFORM_ENGINE_VERSION = 'c7-engine-version';
export const DISABLE_HTTL_HINT = 'disable-httl-hint';
export const DEFAULT_HISTORY_TTL = 'default-history-ttl';

0 comments on commit 72be508

Please sign in to comment.