File tree Expand file tree Collapse file tree 6 files changed +81
-20
lines changed Expand file tree Collapse file tree 6 files changed +81
-20
lines changed Original file line number Diff line number Diff line change 30
30
v-for =" task of tasks"
31
31
:key =" task.id"
32
32
:task =" task"
33
+ @click.native =" openTask(task)"
33
34
>
34
35
<VueButton
35
36
v-if =" task.status !== 'running'"
36
37
icon-left =" play_arrow"
37
38
class =" icon-button"
38
39
v-tooltip =" $t('org.vue.views.project-task-details.actions.play')"
39
- @click = " runTask (task)"
40
+ @click.stop = " openTask (task, true )"
40
41
/>
41
42
<VueButton
42
43
v-else
43
44
icon-left =" stop"
44
45
class =" icon-button"
45
46
v-tooltip =" $t('org.vue.views.project-task-details.actions.stop')"
46
- @click =" stopTask(task)"
47
+ @click.stop =" stopTask(task)"
47
48
/>
48
49
</TaskItem >
50
+
51
+ <VueLoadingIndicator
52
+ v-if =" loading"
53
+ class =" overlay"
54
+ />
49
55
</div >
50
56
</div >
51
57
</VueDropdown >
55
61
import TASK_CHANGED from ' ../graphql/taskChanged.gql'
56
62
import TASK_RUN from ' ../graphql/taskRun.gql'
57
63
import TASK_STOP from ' ../graphql/taskStop.gql'
64
+ import PROJECT_CURRENT from ' ../graphql/projectCurrent.gql'
65
+ import PROJECT_OPEN from ' ../graphql/projectOpen.gql'
58
66
59
67
export default {
60
68
props: {
@@ -69,7 +77,15 @@ export default {
69
77
}
70
78
},
71
79
80
+ data () {
81
+ return {
82
+ loading: false
83
+ }
84
+ },
85
+
72
86
apollo: {
87
+ projectCurrent: PROJECT_CURRENT ,
88
+
73
89
$subscribe: {
74
90
taskChanged: {
75
91
query: TASK_CHANGED
@@ -99,13 +115,31 @@ export default {
99
115
},
100
116
101
117
methods: {
102
- runTask (task ) {
103
- this .$apollo .mutate ({
104
- mutation: TASK_RUN ,
105
- variables: {
106
- id: task .id
107
- }
118
+ async openTask (task , run = false ) {
119
+ this .loading = true
120
+
121
+ if (task .project .id !== this .projectCurrent .id ) {
122
+ await this .$apollo .mutate ({
123
+ mutation: PROJECT_OPEN ,
124
+ variables: {
125
+ id: task .project .id
126
+ }
127
+ })
128
+ }
129
+
130
+ this .$router .push ({
131
+ name: ' project-tasks' ,
132
+ query: { id: task .id }
108
133
})
134
+
135
+ if (run) {
136
+ await this .$apollo .mutate ({
137
+ mutation: TASK_RUN ,
138
+ variables: {
139
+ id: task .id
140
+ }
141
+ })
142
+ }
109
143
},
110
144
111
145
stopTask (task ) {
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ query projects {
7
7
id
8
8
name
9
9
status
10
+ project {
11
+ id
12
+ }
10
13
}
11
14
}
12
15
}
Original file line number Diff line number Diff line change
1
+ import { isSameRoute } from '../util/route'
1
2
2
3
import PROJECT_CURRENT from '../graphql/projectCurrent.gql'
3
4
@@ -26,12 +27,14 @@ export default function ({
26
27
27
28
beforeRouteEnter ( to , from , next ) {
28
29
if ( lastRoute ) {
29
- const { name, params, query } = lastRoute
30
- next ( { name, params, query } )
30
+ if ( ! to . query ) {
31
+ const { name, params, query } = lastRoute
32
+ next ( { name, params, query } )
33
+ return
34
+ }
31
35
lastRoute = null
32
- } else {
33
- next ( )
34
36
}
37
+ next ( )
35
38
} ,
36
39
37
40
beforeRouteLeave ( to , from , next ) {
@@ -41,7 +44,9 @@ export default function ({
41
44
42
45
methods : {
43
46
replaceBaseRoute ( ) {
44
- if ( baseRoute ) this . $router . replace ( baseRoute )
47
+ if ( baseRoute && ! isSameRoute ( this . $route , baseRoute , false ) ) {
48
+ this . $router . replace ( baseRoute )
49
+ }
45
50
}
46
51
}
47
52
}
Original file line number Diff line number Diff line change @@ -41,10 +41,19 @@ export default {
41
41
42
42
Vue . config . optionMergeStrategies . bus = ( parent , child , vm ) => {
43
43
if ( Array . isArray ( parent ) ) {
44
- parent . push ( child )
45
- return parent
46
- } else if ( parent ) {
44
+ if ( Array . isArray ( child ) ) {
45
+ return parent . concat ( child )
46
+ } else {
47
+ parent . push ( child )
48
+ return parent
49
+ }
50
+ } else if ( Array . isArray ( child ) ) {
51
+ child . push ( parent )
52
+ return child
53
+ } else if ( parent && child ) {
47
54
return [ parent , child ]
55
+ } else if ( parent ) {
56
+ return parent
48
57
}
49
58
return child
50
59
}
Original file line number Diff line number Diff line change 1
1
const trailingSlashRE = / \/ ? $ /
2
2
3
- export function isSameRoute ( a , b ) {
3
+ export function isSameRoute ( a , b , checkQuery = true ) {
4
4
if ( ! b ) {
5
5
return false
6
6
} else if ( a . path && b . path ) {
7
7
return (
8
8
a . path . replace ( trailingSlashRE , '' ) === b . path . replace ( trailingSlashRE , '' ) &&
9
9
a . hash === b . hash &&
10
- isObjectEqual ( a . query , b . query )
10
+ ( ! checkQuery || isObjectEqual ( a . query , b . query ) )
11
11
)
12
12
} else if ( a . name && b . name ) {
13
13
return (
14
14
a . name === b . name &&
15
15
a . hash === b . hash &&
16
- isObjectEqual ( a . query , b . query ) &&
17
- isObjectEqual ( a . params , b . params )
16
+ isObjectEqual ( a . params , b . params ) &&
17
+ ( ! checkQuery || isObjectEqual ( a . query , b . query ) )
18
18
)
19
19
} else {
20
20
return false
Original file line number Diff line number Diff line change 6
6
<ApolloQuery
7
7
:query =" require('../graphql/tasks.gql')"
8
8
class =" fill-height"
9
+ @result =" onResult"
9
10
>
10
11
<template slot-scope="{ result: { data, loading } }">
11
12
<VueLoadingIndicator
@@ -82,6 +83,15 @@ export default {
82
83
task
83
84
})
84
85
)
86
+ },
87
+
88
+ onResult ({ loading }) {
89
+ if (! loading && this .$route .query .id ) {
90
+ this .$router .replace ({
91
+ name: ' project-task-details' ,
92
+ params: { id: this .$route .query .id }
93
+ })
94
+ }
85
95
}
86
96
}
87
97
}
You can’t perform that action at this time.
0 commit comments