2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import { hot } from 'react-hot-loader';
18 import React, { Component } from 'react';
19 import { Route, withRouter } from 'react-router-dom';
21 import { connect } from 'react-redux';
22 import { PluginPubSub } from 'shared/pubsub/plugin-pubsub';
23 import 'resources/scss/style.scss';
24 import 'bpmn-js-properties-panel/styles/properties.less';
25 import { routes } from 'wfapp/routes';
26 import { USER_ID } from 'wfapp/appConstants';
27 import { getVersionsAction } from 'features/workflow/overview/overviewConstansts';
28 import { setOperationModeAction } from 'features/version/versionConstants';
29 import { setPluginContext } from './pluginContext/pluginContextActions';
30 import { notificationType } from 'wfapp/pluginContext/pluginContextConstants';
31 const RouteWithSubRoutes = route => (
35 render={props => <route.component {...props} routes={route.routes} />}
39 function mapActionsToProps(dispatch) {
41 getOverview: workflowId => {
42 dispatch(getVersionsAction(workflowId));
43 dispatch(setOperationModeAction());
45 setPluginContext: payload => dispatch(setPluginContext(payload))
49 class App extends Component {
53 this.searchParams = qs.parse(location.search, {
54 ignoreQueryPrefix: true
57 if (this.searchParams && this.searchParams.userId) {
58 localStorage.setItem(USER_ID, this.searchParams.userId);
63 if (this.searchParams) {
69 } = this.searchParams;
71 if (eventsClientId && parentUrl) {
72 this.props.setPluginContext({
76 const client = new PluginPubSub(eventsClientId, parentUrl);
77 client.notify(notificationType.READY);
79 if (workflowId && versionId) {
80 this.props.getOverview(workflowId);
81 this.props.history.push(
82 `/workflow/${workflowId}/version/${versionId}/composition`
90 <div className="workflow-app">
91 {routes.map((route, i) => (
92 <RouteWithSubRoutes key={`App.route.${i}`} {...route} />
99 export default hot(module)(