diff --git a/client/src/app/TabsProvider.js b/client/src/app/TabsProvider.js index e1d509e48a..c494bc8119 100644 --- a/client/src/app/TabsProvider.js +++ b/client/src/app/TabsProvider.js @@ -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'; @@ -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) { @@ -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)) + ); +} diff --git a/client/src/app/__tests__/TabsProviderSpec.js b/client/src/app/__tests__/TabsProviderSpec.js index 82b64d4c79..348b4d78ad 100644 --- a/client/src/app/__tests__/TabsProviderSpec.js +++ b/client/src/app/__tests__/TabsProviderSpec.js @@ -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 { @@ -1134,7 +1135,6 @@ describe('TabsProvider', function() { expect(tabsProvider.hasProvider('cmmn')).to.be.true; }); - it('should disable HTTL hint', async function() { // given @@ -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"'); + }); + + }); diff --git a/client/src/app/tabs/bpmn/__tests__/DiagramSpec.js b/client/src/app/tabs/bpmn/__tests__/DiagramSpec.js index 452f0a3ab5..5700b46789 100644 --- a/client/src/app/tabs/bpmn/__tests__/DiagramSpec.js +++ b/client/src/app/tabs/bpmn/__tests__/DiagramSpec.js @@ -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 }}'); }); }); diff --git a/client/src/app/tabs/bpmn/diagram.bpmn b/client/src/app/tabs/bpmn/diagram.bpmn index cfee010d09..ee949232a8 100644 --- a/client/src/app/tabs/bpmn/diagram.bpmn +++ b/client/src/app/tabs/bpmn/diagram.bpmn @@ -1,6 +1,6 @@ - + diff --git a/client/src/util/Flags.js b/client/src/util/Flags.js index a6626e3a83..8760905e2a 100644 --- a/client/src/util/Flags.js +++ b/client/src/util/Flags.js @@ -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'; +