|
1 | 1 | <script>
|
2 |
| -import _ from 'underscore'; |
3 |
| -import { mapGetters, mapState, mapActions } from 'vuex'; |
4 |
| -import { isScrolledToBottom } from '~/lib/utils/scroll_utils'; |
5 |
| -import bp from '~/breakpoints'; |
6 |
| -import CiHeader from '~/vue_shared/components/header_ci_component.vue'; |
7 |
| -import Callout from '~/vue_shared/components/callout.vue'; |
8 |
| -import createStore from '../store'; |
9 |
| -import EmptyState from './empty_state.vue'; |
10 |
| -import EnvironmentsBlock from './environments_block.vue'; |
11 |
| -import ErasedBlock from './erased_block.vue'; |
12 |
| -import Log from './job_log.vue'; |
13 |
| -import LogTopBar from './job_log_controllers.vue'; |
14 |
| -import StuckBlock from './stuck_block.vue'; |
15 |
| -import Sidebar from './sidebar.vue'; |
| 2 | + import _ from 'underscore'; |
| 3 | + import { mapGetters, mapState, mapActions } from 'vuex'; |
| 4 | + import { isScrolledToBottom } from '~/lib/utils/scroll_utils'; |
| 5 | + import bp from '~/breakpoints'; |
| 6 | + import CiHeader from '~/vue_shared/components/header_ci_component.vue'; |
| 7 | + import Callout from '~/vue_shared/components/callout.vue'; |
| 8 | + import createStore from '../store'; |
| 9 | + import EmptyState from './empty_state.vue'; |
| 10 | + import EnvironmentsBlock from './environments_block.vue'; |
| 11 | + import ErasedBlock from './erased_block.vue'; |
| 12 | + import Log from './job_log.vue'; |
| 13 | + import LogTopBar from './job_log_controllers.vue'; |
| 14 | + import StuckBlock from './stuck_block.vue'; |
| 15 | + import Sidebar from './sidebar.vue'; |
16 | 16 |
|
17 |
| -export default { |
18 |
| - name: 'JobPageApp', |
19 |
| - store: createStore(), |
20 |
| - components: { |
21 |
| - CiHeader, |
22 |
| - Callout, |
23 |
| - EmptyState, |
24 |
| - EnvironmentsBlock, |
25 |
| - ErasedBlock, |
26 |
| - Log, |
27 |
| - LogTopBar, |
28 |
| - StuckBlock, |
29 |
| - Sidebar, |
30 |
| - }, |
31 |
| - props: { |
32 |
| - runnerSettingsUrl: { |
33 |
| - type: String, |
34 |
| - required: false, |
35 |
| - default: null, |
| 17 | + export default { |
| 18 | + name: 'JobPageApp', |
| 19 | + store: createStore(), |
| 20 | + components: { |
| 21 | + CiHeader, |
| 22 | + Callout, |
| 23 | + EmptyState, |
| 24 | + EnvironmentsBlock, |
| 25 | + ErasedBlock, |
| 26 | + Log, |
| 27 | + LogTopBar, |
| 28 | + StuckBlock, |
| 29 | + Sidebar, |
36 | 30 | },
|
37 |
| - runnerHelpUrl: { |
38 |
| - type: String, |
39 |
| - required: false, |
40 |
| - default: null, |
| 31 | + props: { |
| 32 | + runnerSettingsUrl: { |
| 33 | + type: String, |
| 34 | + required: false, |
| 35 | + default: null, |
| 36 | + }, |
| 37 | + runnerHelpUrl: { |
| 38 | + type: String, |
| 39 | + required: false, |
| 40 | + default: null, |
| 41 | + }, |
| 42 | + endpoint: { |
| 43 | + type: String, |
| 44 | + required: true, |
| 45 | + }, |
| 46 | + terminalPath: { |
| 47 | + type: String, |
| 48 | + required: false, |
| 49 | + default: null, |
| 50 | + }, |
| 51 | + pagePath: { |
| 52 | + type: String, |
| 53 | + required: true, |
| 54 | + }, |
| 55 | + logState: { |
| 56 | + type: String, |
| 57 | + required: true, |
| 58 | + }, |
41 | 59 | },
|
42 |
| - endpoint: { |
43 |
| - type: String, |
44 |
| - required: true, |
45 |
| - }, |
46 |
| - terminalPath: { |
47 |
| - type: String, |
48 |
| - required: false, |
49 |
| - default: null, |
50 |
| - }, |
51 |
| - pagePath: { |
52 |
| - type: String, |
53 |
| - required: true, |
54 |
| - }, |
55 |
| - logState: { |
56 |
| - type: String, |
57 |
| - required: true, |
58 |
| - }, |
59 |
| - }, |
60 |
| - computed: { |
61 |
| - ...mapState([ |
62 |
| - 'isLoading', |
63 |
| - 'job', |
64 |
| - 'isSidebarOpen', |
65 |
| - 'trace', |
66 |
| - 'isTraceComplete', |
67 |
| - 'traceSize', |
68 |
| - 'isTraceSizeVisible', |
69 |
| - 'isScrollBottomDisabled', |
70 |
| - 'isScrollTopDisabled', |
71 |
| - 'isScrolledToBottomBeforeReceivingTrace', |
72 |
| - 'hasError', |
73 |
| - ]), |
74 |
| - ...mapGetters([ |
75 |
| - 'headerActions', |
76 |
| - 'headerTime', |
77 |
| - 'shouldRenderCalloutMessage', |
78 |
| - 'shouldRenderTriggeredLabel', |
79 |
| - 'hasEnvironment', |
80 |
| - 'isJobStuck', |
81 |
| - 'hasTrace', |
82 |
| - 'emptyStateIllustration', |
83 |
| - 'isScrollingDown', |
84 |
| - 'emptyStateAction', |
85 |
| - ]), |
| 60 | + computed: { |
| 61 | + ...mapState([ |
| 62 | + 'isLoading', |
| 63 | + 'job', |
| 64 | + 'isSidebarOpen', |
| 65 | + 'trace', |
| 66 | + 'isTraceComplete', |
| 67 | + 'traceSize', |
| 68 | + 'isTraceSizeVisible', |
| 69 | + 'isScrollBottomDisabled', |
| 70 | + 'isScrollTopDisabled', |
| 71 | + 'isScrolledToBottomBeforeReceivingTrace', |
| 72 | + 'hasError', |
| 73 | + ]), |
| 74 | + ...mapGetters([ |
| 75 | + 'headerActions', |
| 76 | + 'headerTime', |
| 77 | + 'shouldRenderCalloutMessage', |
| 78 | + 'shouldRenderTriggeredLabel', |
| 79 | + 'hasEnvironment', |
| 80 | + 'isJobStuck', |
| 81 | + 'hasTrace', |
| 82 | + 'emptyStateIllustration', |
| 83 | + 'isScrollingDown', |
| 84 | + 'emptyStateAction', |
| 85 | + ]), |
86 | 86 |
|
87 |
| - shouldRenderContent() { |
88 |
| - return !this.isLoading && !this.hasError; |
89 |
| - }, |
90 |
| - }, |
91 |
| - watch: { |
92 |
| - // Once the job log is loaded, |
93 |
| - // fetch the stages for the dropdown on the sidebar |
94 |
| - job(newVal, oldVal) { |
95 |
| - if (_.isEmpty(oldVal) && !_.isEmpty(newVal.pipeline)) { |
96 |
| - this.fetchStages(); |
| 87 | + shouldRenderContent() { |
| 88 | + return !this.isLoading && !this.hasError; |
97 | 89 | }
|
98 | 90 | },
|
99 |
| - }, |
100 |
| - created() { |
101 |
| - this.throttled = _.throttle(this.toggleScrollButtons, 100); |
102 |
| -
|
103 |
| - this.setJobEndpoint(this.endpoint); |
104 |
| - this.setTraceOptions({ |
105 |
| - logState: this.logState, |
106 |
| - pagePath: this.pagePath, |
107 |
| - }); |
108 |
| -
|
109 |
| - this.fetchJob(); |
110 |
| - this.fetchTrace(); |
| 91 | + watch: { |
| 92 | + // Once the job log is loaded, |
| 93 | + // fetch the stages for the dropdown on the sidebar |
| 94 | + job(newVal, oldVal) { |
| 95 | + if (_.isEmpty(oldVal) && !_.isEmpty(newVal.pipeline)) { |
| 96 | + this.fetchStages(); |
| 97 | + } |
| 98 | + }, |
| 99 | + }, |
| 100 | + created() { |
| 101 | + this.throttled = _.throttle(this.toggleScrollButtons, 100); |
111 | 102 |
|
112 |
| - window.addEventListener('resize', this.onResize); |
113 |
| - window.addEventListener('scroll', this.updateScroll); |
114 |
| - }, |
| 103 | + this.setJobEndpoint(this.endpoint); |
| 104 | + this.setTraceOptions({ |
| 105 | + logState: this.logState, |
| 106 | + pagePath: this.pagePath, |
| 107 | + }); |
115 | 108 |
|
116 |
| - mounted() { |
117 |
| - this.updateSidebar(); |
118 |
| - }, |
| 109 | + this.fetchJob(); |
| 110 | + this.fetchTrace(); |
119 | 111 |
|
120 |
| - destroyed() { |
121 |
| - window.removeEventListener('resize', this.onResize); |
122 |
| - window.removeEventListener('scroll', this.updateScroll); |
123 |
| - }, |
| 112 | + window.addEventListener('resize', this.onResize); |
| 113 | + window.addEventListener('scroll', this.updateScroll); |
| 114 | + }, |
124 | 115 |
|
125 |
| - methods: { |
126 |
| - ...mapActions([ |
127 |
| - 'setJobEndpoint', |
128 |
| - 'setTraceOptions', |
129 |
| - 'fetchJob', |
130 |
| - 'fetchStages', |
131 |
| - 'hideSidebar', |
132 |
| - 'showSidebar', |
133 |
| - 'toggleSidebar', |
134 |
| - 'fetchTrace', |
135 |
| - 'scrollBottom', |
136 |
| - 'scrollTop', |
137 |
| - 'toggleScrollButtons', |
138 |
| - 'toggleScrollAnimation', |
139 |
| - ]), |
140 |
| - onResize() { |
| 116 | + mounted() { |
141 | 117 | this.updateSidebar();
|
142 |
| - this.updateScroll(); |
143 | 118 | },
|
144 |
| - updateSidebar() { |
145 |
| - if (bp.getBreakpointSize() === 'xs') { |
146 |
| - this.hideSidebar(); |
147 |
| - } else if (!this.isSidebarOpen) { |
148 |
| - this.showSidebar(); |
149 |
| - } |
| 119 | +
|
| 120 | + destroyed() { |
| 121 | + window.removeEventListener('resize', this.onResize); |
| 122 | + window.removeEventListener('scroll', this.updateScroll); |
150 | 123 | },
|
151 |
| - updateScroll() { |
152 |
| - if (!isScrolledToBottom()) { |
153 |
| - this.toggleScrollAnimation(false); |
154 |
| - } else if (this.isScrollingDown) { |
155 |
| - this.toggleScrollAnimation(true); |
156 |
| - } |
157 | 124 |
|
158 |
| - this.throttled(); |
| 125 | + methods: { |
| 126 | + ...mapActions([ |
| 127 | + 'setJobEndpoint', |
| 128 | + 'setTraceOptions', |
| 129 | + 'fetchJob', |
| 130 | + 'fetchStages', |
| 131 | + 'hideSidebar', |
| 132 | + 'showSidebar', |
| 133 | + 'toggleSidebar', |
| 134 | + 'fetchTrace', |
| 135 | + 'scrollBottom', |
| 136 | + 'scrollTop', |
| 137 | + 'toggleScrollButtons', |
| 138 | + 'toggleScrollAnimation', |
| 139 | + ]), |
| 140 | + onResize() { |
| 141 | + this.updateSidebar(); |
| 142 | + this.updateScroll(); |
| 143 | + }, |
| 144 | + updateSidebar() { |
| 145 | + if (bp.getBreakpointSize() === 'xs') { |
| 146 | + this.hideSidebar(); |
| 147 | + } else if (!this.isSidebarOpen) { |
| 148 | + this.showSidebar(); |
| 149 | + } |
| 150 | + }, |
| 151 | + updateScroll() { |
| 152 | + if (!isScrolledToBottom()) { |
| 153 | + this.toggleScrollAnimation(false); |
| 154 | + } else if (this.isScrollingDown) { |
| 155 | + this.toggleScrollAnimation(true); |
| 156 | + } |
| 157 | +
|
| 158 | + this.throttled(); |
| 159 | + }, |
159 | 160 | },
|
160 |
| - }, |
161 |
| -}; |
| 161 | + }; |
162 | 162 | </script>
|
163 | 163 | <template>
|
164 | 164 | <div>
|
|
0 commit comments