Skip to content

Commit 8c3d90a

Browse files
just-at-ubercodemmaaliakseireact
authored
Feature/dsl graph workflow history container (Part 2) (#254)
* Pr branch (#214) * added simple route to tree graph * added new component for workflow graph * now displaying a svg circle, added some styling * added a simple line generator to display grah * moved code from js project to graph vue component, added new data in data.json * removed old file, fixed click issues by a temporay hack' * trying to integrate cytoscape graph@ * removed and changed some imports to make cytoscape graph work * updated store import * added loading of workflow to history component for testing * removed typescript files * added new test data * added demo-data * added store * added event function map but in pure js * added old tree component which will be updated * changed name of store * updated npm package of cytoscape to 3.16.0 * renamed tree vue file * changed to receive events as props@ * history now loads workflow container instead of graph * modiefied graph container to receive new props and set a small delay of displaying graph * changed with and height of graph to fix problem with zoom * now looping over events instead of workflow@ * added a new event map to get event info * changed all eventtypes to map to servers json format * updated store to receive both workflow id and child id * updated graph component to send correct data to store * added a function to set route to child * changed the way childworkflow route is set in event map * changed how parent is routed to * changed variable name for parent route * removed old function for routing * removed home btn * added a simpler way to change the route@ * added query to route to route to the graph format and not grid * renamed showGraph variable to showTimeLine * renamed variables and functions from showGraph to showTimeline * toggling with flag instead of true false variable * added a function setWorkflow which rezises the split window based on the variable graphView * removed old link to tree graph * added a refresh btn which forces a reload of the graph container * sending isworkflow running to the history component from index * refresh functioning, only on mount needs to bw fixed * removed debugging msg * Refresh btn now only shows if there is more data to reload * only sending the prop (events) to graphView if it has been fetched and has length * removed redundant code and changed variable names to better represent their functionalities * revomed debugging code * displaying graph on right side works but is hacky - needs to be fixed * added flexbox to the container when the dag graph is displayed to layout the slider on the right * added functionality which check route query to determine how to split the window@ * new name for class to match current class naming style * removed commented code and console log * changed to listen to query updates rather than store to update currently selected node * removed node list from graph and not used function * removed commented code * added new function zoomtonode which is called on mount, if a eventId exist on query * removed old console log * removed not used method in store set rendered nodes * removed functionality regarding rendered nodes (only relevant when we have a node list to the graph * removed old console logs * removed another debug console log * added omit to router query when routing from/to child to avoid trying to display a node with same eventId which doesnt exist@ * added a check to see if eventId is definied on graph mount * update route query when a node is clicked * added a watch function which watches changes in event id query and then scrolls the grid to that event * removed old on click functioanlity and added new to allow deselection of node * removed eventlist and moved childbtn to topbar * removed event list and all css linked to it and node list * added and extra if statement to check if you have already clicked on bg * removed old getters and setters in vue store * added functionality to check if a node is clicked or not * added matching top bar to canvas (same as grid) * added new btn styling to match rest of the page, using the predefinted mixins@ * added proper buttons for parent and child routes@ * removed unecessary css code * styled refresh button * added a check to enableSplitting to not do it on graph view * removed clickinfo from eventmap * updated name of event info and removed click info * removed old static workflow loading functionality and its corresponding data and props * removed old event map functions and renamed the current one * removed old code and renamed some variables * removed old demo data * changed child btn text to To Child * changed variable names for better readability. Added overflow ellipse for workflow name text * added new variables names to store for better readability regarding childworkflow * added functionality to show child btn for previous execution run id * functionality for changing the name of the parent btn, and only use run id as route * updated continued as new event to return run ID * added a new mutation to update route for new executions * Change cytoscape version * added functionality to make graph display child btn on grid click * refractored current code for better readability * removed onNodeClick function which is not necessary anymore * added an extra check to make sure refresh btn is not showed unecessarily * updated even connection functionality to not break for different chunk sizes * removed old console log * removed legend imports in graph component * added legend to graph container * added graph legend component and changed its styling a bit * small html and css fixes * moved legend to bottom of graph * removed chunckWorfklow and code that is not used * removed old graph file * fixed pr comment on this=self, and simplified zoom * removed unused import * passing eventId as prop instead of listening to changes in query * removed unnecessary async prefix for viewInit * update to check for prop and not for route query * changed from let to const for zoom lvl * added map mupations to connect to store * resolved merge conflicts * added demo data to gitignore * commented out demo data * making sure cytoscape version stays on 3.16.0 * added a new file for calculating the layout using timestamps * added a new file which keeps track of events and nodes and builds the graph * removed unused function * Order nodes by timestamp in graph visualization * Enable chrono edges * Avoid overlapping edges * Apply lint --fix * Disable chrono edges for large workflows * Fix timeline elements test * Use showGraph url parameter in tests Co-authored-by: Aliaksei Talkachou <[email protected]> * removing git ignore file * updating package-lock and updating ordering in cytoscape component * refactoring get-event-connections. fixing lint. adding missing licenses. * minor refactorings * minor refactoring * updating start date in license headers * moving files to a more logical structure. * small refactor * small refactor for legend * adding license header * fixing lint * moving constants * small rename refactor for graphView values. * adjusting line in legend * moving constants out of helper into constants file. * moving comments for constants. * moving more constants out * reordering constants * minor refactoring. removing some warnings in console. * adjusting whitespace in legend * fixing lint * minor refactoring of CytoscapeLayout for better readability. * minor refactor * minor refactoring * adjusting ordering * breaking apart cytoscape layout into smaller helpers * moving graph styles from helpers to constants. * fixed unnecessary code * moving out helper function * removing route.query * setting split direction to computed field * adjusting name for split size constant * fixing error in console * removing unused packages. * breaking apart graph helper into smaller files. * adding license headers * fixing lint * removing unused prop * moving to computed prop * moving constant. moving to computed field * simplifying code * reference helper * removing unused variables * moving out more constants * separating get event connections into smaller files. * minor refactoring * moving more constants out * fixing lint * updating comment * adding feature flag * fixing feature flag height and stopping it from hiding timeline. * fixing lint * tweaking vuex store to have graph namespace for application separation. * fixing lint * removing direct import reference to store in components. * addressing PR comments * removing unnecessary this from template * fixing lint * added container path * moving workflow history to containers folder. * fixing whitespace. removing helper moved to another location. * fixing lint * add containers shortcut * moving settings-workflow-history into containers * fixing lint * Add container for workflow history to support graphEnabled to control graph feature * fix lint * updating event name for graph * fixing tests by providing store mock Co-authored-by: Emma Tysk <[email protected]> Co-authored-by: Aliaksei Talkachou <[email protected]>
1 parent c112355 commit 8c3d90a

File tree

9 files changed

+92
-11
lines changed

9 files changed

+92
-11
lines changed

client/containers/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ export {
2525
getters as settingsWorkflowHistoryGetters,
2626
mutations as settingsWorkflowHistoryMutations,
2727
} from './settings-workflow-history';
28-
export { component as WorkflowHistory } from './workflow-history';
28+
export {
29+
container as WorkflowHistory,
30+
getDefaultState as getWorkflowHistoryDefaultState,
31+
} from './workflow-history';

client/containers/workflow-history/component.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ import {
2828
} from 'vue-virtual-scroller';
2929
import debounce from 'lodash-es/debounce';
3030
import omit from 'lodash-es/omit';
31-
import Timeline from './components/timeline.vue';
32-
import WorkflowGraph from './components/workflow-graph';
33-
import EventDetail from './components/event-detail.vue';
31+
import { EventDetail, Timeline, WorkflowGraph } from './components';
3432
import { GRAPH_VIEW_DAG, GRAPH_VIEW_TIMELINE } from './constants';
3533
import { getDefaultSplitSize } from './helpers';
3634
import { DetailList, FeatureFlag, HighlightToggle } from '~components';
@@ -72,10 +70,11 @@ export default {
7270
'eventId',
7371
'events',
7472
'format',
73+
'graphEnabled',
74+
'graphView',
7575
'isWorkflowRunning',
7676
'loading',
7777
'runId',
78-
'graphView',
7978
'timelineEvents',
8079
'workflowHistoryEventHighlightList',
8180
'workflowHistoryEventHighlightListEnabled',
@@ -368,7 +367,7 @@ export default {
368367
</div>
369368
</div>
370369
<div class="actions">
371-
<feature-flag name="workflowGraph">
370+
<feature-flag name="workflowGraph" v-if="graphEnabled">
372371
<a href="#" @click.prevent="toggleShowDagGraph()"
373372
>{{ graphView === GRAPH_VIEW_DAG ? 'hide' : 'show' }} graph</a
374373
>
@@ -403,7 +402,7 @@ export default {
403402
>
404403
<feature-flag
405404
name="workflowGraph"
406-
v-if="graphView === GRAPH_VIEW_DAG && events.length"
405+
v-if="graphEnabled && graphView === GRAPH_VIEW_DAG && events.length"
407406
>
408407
<WorkflowGraph
409408
:events="events"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
export { default as EventDetail } from './event-detail';
23+
export { default as Timeline } from './timeline';
24+
export { default as WorkflowGraph } from './workflow-graph';

client/containers/workflow-history/components/workflow-graph/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default {
6868
mounted() {
6969
this.delayedShow();
7070
this.eventsSnapShot = this.events;
71-
this.$store.commit('resetState');
71+
this.$store.commit('resetGraphState');
7272
},
7373
7474
computed: {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
import { connect } from 'vuex-connect';
23+
24+
const stateToProps = {
25+
graphEnabled: state => state.workflowHistory.graphEnabled,
26+
};
27+
28+
export default connect({
29+
stateToProps,
30+
});

client/containers/workflow-history/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
// THE SOFTWARE.
2121

2222
import Component from './component';
23+
import Connector from './connector';
2324

24-
const component = Component;
25+
const getDefaultState = () => ({
26+
graphEnabled: true,
27+
});
2528

26-
export { component };
29+
const container = Connector('WorkflowHistory', Component);
30+
31+
export { container, getDefaultState };

client/store/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Vuex from 'vuex';
2424
import VuexPersistence from 'vuex-persist';
2525
import {
2626
getSettingsWorkflowHistoryDefaultState,
27+
getWorkflowHistoryDefaultState,
2728
settingsWorkflowHistoryGetters,
2829
settingsWorkflowHistoryMutations,
2930
} from '~containers';
@@ -59,7 +60,7 @@ const graphMutations = {
5960
parentRoute(state, route) {
6061
state.graph.parentRoute = route;
6162
},
62-
resetState(state) {
63+
resetGraphState(state) {
6364
Object.assign(state.graph, getGraphDefaultState());
6465
},
6566
};
@@ -78,6 +79,7 @@ const graphGetters = {
7879
const getDefaultState = () => ({
7980
graph: getGraphDefaultState(),
8081
settingsWorkflowHistory: getSettingsWorkflowHistoryDefaultState(),
82+
workflowHistory: getWorkflowHistoryDefaultState(),
8183
});
8284

8385
const state = getDefaultState();

client/test/scenario.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import Router from 'vue-router';
2323
import Vue from 'vue';
24+
import Vuex from 'vuex';
2425
import moment from 'moment';
2526
import fetchMock from 'fetch-mock';
2627
import qs from 'friendly-querystring';
@@ -34,6 +35,7 @@ import fixtures from './fixtures';
3435
export default function Scenario(test) {
3536
// eslint-disable-next-line no-param-reassign
3637
test.scenario = this;
38+
this.storeConfig = {};
3739
this.mochaTest = test;
3840
this.api = fetchMock.sandbox().catch((url, req, opts) => {
3941
let msg = `Unexpected request: ${url}${
@@ -64,6 +66,8 @@ Scenario.prototype.render = function render(attachToBody) {
6466

6567
const el = document.createElement('div');
6668

69+
const store = new Vuex.Store(this.storeConfig);
70+
6771
if (attachToBody || this.isDebuggingJustThisTest()) {
6872
document.body.appendChild(el);
6973
}
@@ -72,6 +76,7 @@ Scenario.prototype.render = function render(attachToBody) {
7276
// vue just throws this away, not sure why
7377
el,
7478
router: this.router,
79+
store,
7580
template: '<App/>',
7681
components: { App: main.App },
7782
mixins: [
@@ -227,6 +232,12 @@ Scenario.prototype.withNewsFeed = function withNewsFeed() {
227232
return this;
228233
};
229234

235+
Scenario.prototype.withStoreConfig = function withStoreConfig(config = {}) {
236+
this.storeConfig = config;
237+
238+
return this;
239+
};
240+
230241
Scenario.prototype.withWorkflows = function withWorkflows({
231242
status,
232243
query,

client/test/workflow.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ describe('Workflow', () => {
4646
},
4747
])
4848
.withNewsFeed()
49+
.withStoreConfig({
50+
state: {
51+
workflowHistory: {
52+
graphEnabled: true,
53+
},
54+
},
55+
})
4956
.withWorkflow(
5057
extendedOptions.workflowId,
5158
extendedOptions.runId,

0 commit comments

Comments
 (0)