@@ -39,7 +39,6 @@ export default {
3939 nextPageToken: undefined ,
4040 fetchHistoryPageRetryCount: 0 ,
4141 wfLoading: true ,
42- workflow: undefined ,
4342
4443 history: {
4544 loading: undefined ,
@@ -63,9 +62,12 @@ export default {
6362 ' dateFormat' ,
6463 ' displayWorkflowId' ,
6564 ' domain' ,
65+ ' pendingTaskCount' ,
6666 ' runId' ,
67+ ' taskListName' ,
6768 ' timeFormat' ,
6869 ' timezone' ,
70+ ' workflow' ,
6971 ' workflowHistoryEventHighlightList' ,
7072 ' workflowHistoryEventHighlightListEnabled' ,
7173 ' workflowId' ,
@@ -74,6 +76,9 @@ export default {
7476 this .unwatch .push (
7577 this .$watch (' baseAPIURL' , this .onBaseApiUrlChange , { immediate: true })
7678 );
79+ this .unwatch .push (
80+ this .$watch (' historyUrl' , this .onHistoryUrlChange , { immediate: true })
81+ );
7782 },
7883 beforeDestroy () {
7984 this .clearWatches ();
@@ -134,7 +139,6 @@ export default {
134139 this .nextPageToken = undefined ;
135140 this .fetchHistoryPageRetryCount = 0 ;
136141 this .wfLoading = true ;
137- this .workflow = undefined ;
138142
139143 this .history .loading = undefined ;
140144
@@ -144,17 +148,14 @@ export default {
144148 this .summary .result = undefined ;
145149 this .summary .wfStatus = undefined ;
146150 this .summary .workflow = undefined ;
151+
152+ this .$emit (' clearWorkflow' );
147153 },
148154 clearWatches () {
149155 while (this .unwatch .length ) {
150156 this .unwatch .pop ()();
151157 }
152158 },
153- clearHistoryUrlWatch () {
154- while (this .unwatch .length > 1 ) {
155- this .unwatch .pop ()();
156- }
157- },
158159 fetchHistoryPage (pagedHistoryUrl ) {
159160 if (
160161 ! pagedHistoryUrl ||
@@ -240,80 +241,80 @@ export default {
240241 }
241242 });
242243 },
243- onBaseApiUrlChange (baseAPIURL ) {
244+ fetchTaskList () {
245+ const { taskListName } = this ;
246+
247+ if (! taskListName) {
248+ return Promise .reject (' task list name is required' );
249+ }
250+
251+ this .$http (
252+ ` /api/domains/${ this .$route .params .domain } /task-lists/${ taskListName} `
253+ )
254+ .then (
255+ taskList => {
256+ this .taskList = { name: taskListName, ... taskList };
257+ },
258+ error => {
259+ this .taskList = { name: taskListName };
260+ this .error =
261+ (error .json && error .json .message ) ||
262+ error .status ||
263+ error .message ;
264+ }
265+ )
266+ .finally (() => {
267+ this .loading = false ;
268+ });
269+ },
270+ fetchWorkflowInfo () {
271+ const { baseAPIURL } = this ;
272+
244273 if (this .baseApiUrlRetryCount >= RETRY_COUNT_MAX ) {
245274 return ;
246275 }
247276
248- this .clearHistoryUrlWatch ();
249- this .clearState ();
250277 this .wfLoading = true ;
251278
252279 return this .$http (baseAPIURL)
253280 .then (
254281 wf => {
255- this .workflow = wf ;
282+ this .$emit ( ' setWorkflow ' , wf) ;
256283 this .isWorkflowRunning = ! wf .workflowExecutionInfo .closeTime ;
257- this .setupHistoryUrlWatch ();
258284 this .baseApiUrlRetryCount = 0 ;
285+
286+ return wf;
259287 },
260288 error => {
261289 this .$emit (' onNotification' , {
262290 message: getErrorMessage (error),
263291 type: NOTIFICATION_TYPE_ERROR ,
264292 });
265293 this .baseApiUrlRetryCount += 1 ;
266- setTimeout (
267- () => this .onBaseApiUrlChange (baseAPIURL),
268- RETRY_TIMEOUT
269- );
294+ setTimeout (() => this .fetchWorkflowInfo (), RETRY_TIMEOUT );
270295 }
271296 )
272297 .finally (() => {
273298 this .wfLoading = false ;
274299 });
275300 },
276- onHistoryUrlChange (historyUrl ) {
277- this .fetchHistoryPage (historyUrl).then (this .fetchTaskList );
301+ onBaseApiUrlChange () {
302+ this .clearState ();
303+ },
304+ async onHistoryUrlChange (historyUrl ) {
305+ const workflowInfo = await this .fetchWorkflowInfo ();
306+
307+ if (workflowInfo) {
308+ await this .fetchHistoryPage (historyUrl);
309+ this .fetchTaskList ();
310+ }
278311 },
279312 onNotification (event ) {
280313 this .$emit (' onNotification' , event );
281314 },
282315 onWorkflowHistoryEventParamToggle (event ) {
283316 this .$emit (' onWorkflowHistoryEventParamToggle' , event );
284317 },
285- setupHistoryUrlWatch () {
286- this .clearHistoryUrlWatch ();
287- this .unwatch .push (
288- this .$watch (' historyUrl' , this .onHistoryUrlChange , { immediate: true })
289- );
290- },
291- fetchTaskList () {
292- if (! this .workflow || ! this .workflow .executionConfiguration ) {
293- return Promise .reject (' task list name is required' );
294- }
295-
296- const taskListName = this .workflow .executionConfiguration .taskList .name ;
297-
298- this .$http (
299- ` /api/domains/${ this .$route .params .domain } /task-lists/${ taskListName} `
300- )
301- .then (
302- taskList => {
303- this .taskList = { name: taskListName, ... taskList };
304- },
305- error => {
306- this .taskList = { name: taskListName };
307- this .error =
308- (error .json && error .json .message ) ||
309- error .status ||
310- error .message ;
311- }
312- )
313- .finally (() => {
314- this .loading = false ;
315- });
316- },
317318 },
318319};
319320 </script >
0 commit comments