Skip to content

Commit

Permalink
feat: define engine profiles globally
Browse files Browse the repository at this point in the history
Closes #2544
  • Loading branch information
smbea committed Nov 3, 2021
1 parent 593a3e6 commit b423620
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 38 deletions.
26 changes: 8 additions & 18 deletions client/src/app/tabs/EngineProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@ import Arrow from '../../../resources/icons/Arrow.svg';
import LinkArrow from '../../../resources/icons/LinkArrow.svg';

import Flags, { DISABLE_ZEEBE, DISABLE_PLATFORM } from '../../util/Flags';
import { ENGINES, ENGINE_PROFILES } from '../../util/Engines';

import css from './EngineProfile.less';

export const engineProfiles = [
{
executionPlatform: 'Camunda Platform',
executionPlatformVersions: [ '7.16', '7.15' ]
},
{
executionPlatform: 'Camunda Cloud',
executionPlatformVersions: [ '1.2', '1.1', '1.0' ]
}
];


export function EngineProfile(props) {
const {
Expand Down Expand Up @@ -262,7 +252,7 @@ function EngineProfileDescription(props) {

const { executionPlatform } = engineProfile;

if (executionPlatform === 'Camunda Platform') {
if (executionPlatform === ENGINES.PLATFORM) {
return (
<Fragment>
<Overlay.Body>
Expand All @@ -275,7 +265,7 @@ function EngineProfileDescription(props) {
</Overlay.Footer>
</Fragment>
);
} else if (executionPlatform === 'Camunda Cloud') {
} else if (executionPlatform === ENGINES.CLOUD) {
return (
<Fragment>
<Overlay.Body>
Expand Down Expand Up @@ -322,12 +312,12 @@ function Link(props) {
function filterEngineOptions() {

if (!Flags.get(DISABLE_PLATFORM) && ! Flags.get(DISABLE_ZEEBE))
return engineProfiles;
return ENGINE_PROFILES;

return engineProfiles.filter(
return ENGINE_PROFILES.filter(
option => (
Flags.get(DISABLE_PLATFORM) && option.executionPlatform != 'Camunda Platform' ||
Flags.get(DISABLE_ZEEBE) && option.executionPlatform != 'Camunda Cloud'
Flags.get(DISABLE_PLATFORM) && option.executionPlatform != ENGINES.PLATFORM ||
Flags.get(DISABLE_ZEEBE) && option.executionPlatform != ENGINES.CLOUD
));
}

Expand All @@ -347,7 +337,7 @@ export function isKnownEngineProfile(engineProfile = {}) {
return false;
}

const knownEngineProfile = engineProfiles.find(({ executionPlatform }) => executionPlatform === engineProfile.executionPlatform);
const knownEngineProfile = ENGINE_PROFILES.find(({ executionPlatform }) => executionPlatform === engineProfile.executionPlatform);

if (!knownEngineProfile || !knownEngineProfile.executionPlatformVersions.includes(engineProfile.executionPlatformVersion)) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions client/src/app/tabs/__tests__/EngineProfileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import {

import {
EngineProfile,
engineProfiles,
toKebapCase
} from '../EngineProfile';

import { ENGINE_PROFILES } from '../../../util/Engines';

import { engineProfile as bpmnEngineProfile } from '../bpmn/BpmnEditor';
import { engineProfile as cloudBpmnEngineProfile } from '../cloud-bpmn/BpmnEditor';
import { engineProfile as dmnEngineProfile } from '../dmn/DmnEditor';
Expand All @@ -33,7 +34,7 @@ import Flags, { DISABLE_ZEEBE, DISABLE_PLATFORM } from '../../../util/Flags';

const spy = sinon.spy;

const allEngineProfiles = engineProfiles.reduce((allEngineProfiles, engineProfile) => {
const allEngineProfiles = ENGINE_PROFILES.reduce((allEngineProfiles, engineProfile) => {
const {
executionPlatform,
executionPlatformVersions
Expand Down
4 changes: 3 additions & 1 deletion client/src/app/tabs/bpmn/BpmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import { DEFAULT_LAYOUT as propertiesPanelDefaultLayout } from '../PropertiesCon

import { EngineProfile } from '../EngineProfile';

import { ENGINES } from '../../../util/Engines';

const NAMESPACE_URL_ACTIVITI = 'http://activiti.org/bpmn';

const NAMESPACE_CAMUNDA = {
Expand Down Expand Up @@ -101,7 +103,7 @@ const COLORS = [{
}];

export const engineProfile = {
executionPlatform: 'Camunda Platform'
executionPlatform: ENGINES.PLATFORM
};


Expand Down
4 changes: 3 additions & 1 deletion client/src/app/tabs/dmn/DmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import { DEFAULT_LAYOUT as overviewDefaultLayout } from './OverviewContainer';

import { EngineProfile } from '../EngineProfile';

import { ENGINES } from '../../../util/Engines';

const EXPORT_AS = [ 'png', 'jpeg', 'svg' ];

const NAMESPACE_URL_DMN11 = 'http://www.omg.org/spec/DMN/20151101/dmn.xsd',
Expand All @@ -80,7 +82,7 @@ const NAMESPACE_URL_DMN11 = 'http://www.omg.org/spec/DMN/20151101/dmn.xsd',
const CONFIG_KEY = 'editor.askDmnMigration';

export const engineProfile = {
executionPlatform: 'Camunda Platform'
executionPlatform: ENGINES.PLATFORM
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
Icon
} from '../../../shared/ui';

import { ENGINES } from '../../../util/Engines';

const DEPLOYMENT_DETAILS_CONFIG_KEY = 'deployment-tool';
const ENGINE_ENDPOINTS_CONFIG_KEY = 'camundaEngineEndpoints';
const PROCESS_DEFINITION_CONFIG_KEY = 'process-definition';
Expand All @@ -41,8 +43,6 @@ const DEFAULT_ENDPOINT = {

const TOMCAT_DEFAULT_URL = 'http://localhost:8080/engine-rest';

const ET_EXECUTION_PLATFORM_NAME = 'Camunda Platform';

export default class DeploymentTool extends PureComponent {

state = {
Expand Down Expand Up @@ -181,7 +181,7 @@ export default class DeploymentTool extends PureComponent {
deployment,
deployedTo: {
executionPlatformVersion: version,
executionPlatform: ET_EXECUTION_PLATFORM_NAME
executionPlatform: ENGINES.PLATFORM
},
context: 'deploymentTool'
}
Expand Down Expand Up @@ -226,7 +226,7 @@ export default class DeploymentTool extends PureComponent {

// If we retrieved the executionPlatformVersion, include it in event
const deployedTo = (version &&
{ executionPlatformVersion: version, executionPlatform: ET_EXECUTION_PLATFORM_NAME }) || undefined;
{ executionPlatformVersion: version, executionPlatform: ENGINES.PLATFORM }) || undefined;

// notify interested parties
triggerAction('emit-event', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import {

import isExecutable from './util/isExecutable';

import { ENGINES } from '../../../util/Engines';

const START_DETAILS_CONFIG_KEY = 'start-instance-tool';

const START_INSTANCE_FAILED = 'Starting process instance failed';

const PROCESS_DEFINITION_CONFIG_KEY = 'process-definition';

const ET_EXECUTION_PLATFORM_NAME = 'Camunda Platform';

export default class StartInstanceTool extends PureComponent {

state = {
Expand Down Expand Up @@ -420,7 +420,7 @@ export default class StartInstanceTool extends PureComponent {
context: 'startInstanceTool',
deployedTo: {
executionPlatformVersion: version,
executionPlatform: ET_EXECUTION_PLATFORM_NAME
executionPlatform: ENGINES.PLATFORM
}
}
});
Expand Down Expand Up @@ -449,7 +449,7 @@ export default class StartInstanceTool extends PureComponent {

// If we retrieved the executionPlatformVersion, include it in event
const deployedTo = (version &&
{ executionPlatformVersion: version, executionPlatform: ET_EXECUTION_PLATFORM_NAME }) || undefined;
{ executionPlatformVersion: version, executionPlatform: ENGINES.PLATFORM }) || undefined;

// notify interested parties
triggerAction('emit-event', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
getEngineProfile as parseEngineProfile
} from '../../../util/parse';

import { ENGINES } from '../../../util/Engines';

const BPMN_TAB_TYPE = 'bpmn';
const CLOUD_BPMN_TAB_TYPE = 'cloud-bpmn';
const DMN_TAB_TYPE = 'dmn';
Expand Down Expand Up @@ -165,8 +167,8 @@ function getDiagramType(tabType) {

function getDefaultExecutionPlatform(type) {
if (type === 'cloud-bpmn') {
return 'Camunda Cloud';
return ENGINES.CLOUD;
}

return 'Camunda Platform';
return ENGINES.PLATFORM;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { getMetrics } from '../../../util';

import { getEngineProfile as parseEngineProfile } from '../../../util/parse';

import { ENGINES } from '../../../util/Engines';

const HTTP_STATUS_PAYLOAD_TOO_BIG = 413;

const BINDING_TYPE_PROPERTY = 'property';
Expand Down Expand Up @@ -257,8 +259,8 @@ export default class DiagramOpenEventHandler extends BaseEventHandler {

function getDefaultExecutionPlatform(type) {
if (type === 'cloud-bpmn') {
return 'Camunda Cloud';
return ENGINES.CLOUD;
}

return 'Camunda Platform';
return ENGINES.PLATFORM;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import DeploymentPluginModal from './DeploymentPluginModal';

import DeploymentPluginValidator from './DeploymentPluginValidator';

const DEPLOYMENT_CONFIG_KEY = 'zeebe-deployment-tool';
import { ENGINES } from '../../../util/Engines';

const ET_EXECUTION_PLATFORM_NAME = 'Camunda Cloud';
const DEPLOYMENT_CONFIG_KEY = 'zeebe-deployment-tool';

const ZEEBE_ENDPOINTS_CONFIG_KEY = 'zeebeEndpoints';

Expand Down Expand Up @@ -395,7 +395,7 @@ export default class DeploymentPlugin extends PureComponent {
targetType: endpoint && endpoint.targetType,
deployedTo: {
executionPlatformVersion: gatewayVersion,
executionPlatform: ET_EXECUTION_PLATFORM_NAME
executionPlatform: ENGINES.CLOUD
}
}
});
Expand All @@ -422,7 +422,7 @@ export default class DeploymentPlugin extends PureComponent {

// If we retrieved the gatewayVersion, include it in event
const deployedTo = (gatewayVersion &&
{ executionPlatformVersion: gatewayVersion, executionPlatform: ET_EXECUTION_PLATFORM_NAME }) || undefined;
{ executionPlatformVersion: gatewayVersion, executionPlatform: ENGINES.CLOUD }) || undefined;

displayNotification({
type: 'error',
Expand Down
25 changes: 25 additions & 0 deletions client/src/util/Engines.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

export const ENGINES = {
PLATFORM: 'Camunda Platform',
CLOUD: 'Camunda Cloud'
};

export const ENGINE_PROFILES = [
{
executionPlatform: ENGINES.PLATFORM,
executionPlatformVersions: [ '7.16', '7.15' ]
},
{
executionPlatform: ENGINES.CLOUD,
executionPlatformVersions: [ '1.2', '1.1', '1.0' ]
}
];

0 comments on commit b423620

Please sign in to comment.