Skip to content

Commit d3fbc09

Browse files
authored
Feature/workflow history toolbar (#279)
* moving workflow into containers * fixing lint * fixing license * changes to the workflow component * more container changes * more container changes * updating containers with workflow container * adding PENDING_TASK_TYPE constants * fixed lint * adding tests for getDefaultState * hooked up initGetters helper method to help initialize getters for unit tests. * finished rest of tests for getters * mutation unit tests * fix lint * workflow history toolbar * adding simple unit test for getDefaultState * fix merge conflict * fixing lint + removing future code
1 parent a1f593b commit d3fbc09

File tree

8 files changed

+166
-10
lines changed

8 files changed

+166
-10
lines changed

client/containers/workflow-history/component.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ import {
2828
} from 'vue-virtual-scroller';
2929
import debounce from 'lodash-es/debounce';
3030
import omit from 'lodash-es/omit';
31-
import { EventDetail, Timeline, WorkflowGraph } from './components';
31+
import {
32+
EventDetail,
33+
FooterToolbar,
34+
Timeline,
35+
WorkflowGraph,
36+
} from './components';
3237
import { GRAPH_VIEW_DAG, GRAPH_VIEW_TIMELINE } from './constants';
3338
import { getDefaultSplitSize } from './helpers';
3439
import { DetailList, FeatureFlag, HighlightToggle } from '~components';
@@ -74,6 +79,7 @@ export default {
7479
'graphView',
7580
'isWorkflowRunning',
7681
'loading',
82+
'pendingTaskCount',
7783
'runId',
7884
'timelineEvents',
7985
'workflowHistoryEventHighlightList',
@@ -82,14 +88,14 @@ export default {
8288
],
8389
created() {
8490
this.onResizeWindow = debounce(() => {
85-
const { scrollerCompact, scrollerGrid, thead, viewSplit } = this.$refs;
91+
const { scrollerCompact, scrollerGrid, viewSplit } = this.$refs;
8692
const scroller = this.isGrid ? scrollerGrid : scrollerCompact;
8793
8894
if (!scroller) {
8995
return;
9096
}
9197
92-
const offsetHeight = this.isGrid ? thead.offsetHeight : 0;
98+
const offsetHeight = this.isGrid ? 60 + 38 : 0;
9399
const viewSplitHeight = viewSplit.$el.offsetHeight;
94100
const scrollerHeight = viewSplitHeight - offsetHeight;
95101
@@ -321,6 +327,7 @@ export default {
321327
DynamicScrollerItem,
322328
'event-detail': EventDetail,
323329
'feature-flag': FeatureFlag,
330+
'footer-toolbar': FooterToolbar,
324331
'highlight-toggle': HighlightToggle,
325332
prism: Prism,
326333
RecycleScroller,
@@ -429,7 +436,7 @@ export default {
429436
v-if="format === 'grid' && showTable"
430437
:class="{ compact: compactDetails }"
431438
>
432-
<div class="thead" ref="thead">
439+
<div class="thead">
433440
<div class="th col-id">ID</div>
434441
<div class="th col-type">
435442
Type
@@ -537,6 +544,7 @@ export default {
537544
</DynamicScrollerItem>
538545
</template>
539546
</DynamicScroller>
547+
<footer-toolbar :pending-task-count="pendingTaskCount" />
540548
</div>
541549
<prism
542550
class="json"
@@ -807,7 +815,7 @@ section.history {
807815
808816
& + .spacer {
809817
width: 100%;
810-
height: 58px;
818+
height: 60px;
811819
}
812820
}
813821
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<script>
2+
// Copyright (c) 2021 Uber Technologies Inc.
3+
//
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
import { ButtonFill } from '~components';
24+
25+
export default {
26+
name: 'footer-toolbar',
27+
props: {
28+
pendingTaskCount: {
29+
type: Number,
30+
default: 0,
31+
},
32+
},
33+
computed: {
34+
pendingTasksButtonDisabled() {
35+
const { pendingTaskCount } = this;
36+
37+
return pendingTaskCount === 0;
38+
},
39+
pendingTasksButtonLabel() {
40+
const { pendingTaskCount } = this;
41+
42+
return `${pendingTaskCount} PENDING TASK${
43+
pendingTaskCount === 1 ? '' : 'S'
44+
}`;
45+
},
46+
},
47+
components: {
48+
'button-fill': ButtonFill,
49+
},
50+
};
51+
</script>
52+
53+
<template>
54+
<div class="footer-toolbar">
55+
<button-fill
56+
:disabled="pendingTasksButtonDisabled"
57+
disabled-label="No pending tasks"
58+
:label="pendingTasksButtonLabel"
59+
size="small"
60+
tag="router-link"
61+
:to="{ name: 'workflow/pending' }"
62+
/>
63+
</div>
64+
</template>
65+
66+
<style lang="stylus">
67+
.footer-toolbar {
68+
background-color: #f8f8f9;
69+
box-shadow: 0 -2px 2px rgba(0, 0, 0, 0.2);
70+
padding: 6px 12px 6px 55px;
71+
position: relative;
72+
}
73+
</style>

client/containers/workflow-history/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
// THE SOFTWARE.
2121

2222
export { default as EventDetail } from './event-detail';
23+
export { default as FooterToolbar } from './footer-toolbar';
2324
export { default as Timeline } from './timeline';
2425
export { default as WorkflowGraph } from './workflow-graph';

client/containers/workflow-history/connector.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@
2020
// THE SOFTWARE.
2121

2222
import { connect } from 'vuex-connect';
23+
import { WORKFLOW_EXECUTION_PENDING_TASK_COUNT } from '../workflow/getter-types';
24+
25+
const gettersToProps = {
26+
pendingTaskCount: WORKFLOW_EXECUTION_PENDING_TASK_COUNT,
27+
};
2328

2429
const stateToProps = {
2530
graphEnabled: state => state.workflowHistory.graphEnabled,
2631
};
2732

2833
export default connect({
34+
gettersToProps,
2935
stateToProps,
3036
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
const getDefaultState = (state = {}) => ({
23+
graphEnabled: true,
24+
...state,
25+
});
26+
27+
export default getDefaultState;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 getDefaultState from './get-default-state';
23+
24+
describe('workflow history getDefaultState', () => {
25+
describe('when state is not passed', () => {
26+
it('should return graphEnabled = true', () => {
27+
const output = getDefaultState();
28+
29+
expect(output.graphEnabled).toEqual(true);
30+
});
31+
});
32+
33+
describe('when state is passed and has graphEnabled = false', () => {
34+
const state = {
35+
graphEnabled: false,
36+
};
37+
38+
it('should return graphEnabled = false', () => {
39+
const output = getDefaultState(state);
40+
41+
expect(output.graphEnabled).toEqual(false);
42+
});
43+
});
44+
});

client/containers/workflow-history/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121

2222
import Component from './component';
2323
import Connector from './connector';
24-
25-
const getDefaultState = () => ({
26-
graphEnabled: true,
27-
});
24+
import getDefaultState from './get-default-state';
2825

2926
const container = Connector('WorkflowHistory', Component);
3027

client/store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const getStoreConfig = ({ router, state }) => {
8484
return storeConfig;
8585
};
8686

87-
const initStore = ({ router, state } = {}) => {
87+
const initStore = ({ router, state }) => {
8888
Vue.use(Vuex);
8989

9090
const storeConfig = getStoreConfig({ router, state });

0 commit comments

Comments
 (0)