Skip to content

Commit d8d8cd6

Browse files
bartlomiejuyyx990803
authored andcommitted
toggle component tree recursively with alt key pressed (#265)
1 parent 032f57f commit d8d8cd6

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/devtools/views/components/ComponentInstance.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- arrow wrapper for better hit box -->
1515
<span class="arrow-wrapper"
1616
v-if="instance.children.length"
17-
@click.stop="toggle()">
17+
@click.stop="toggle">
1818
<span class="arrow right" :class="{ rotated: expanded }">
1919
</span>
2020
</span>
@@ -71,19 +71,20 @@ export default {
7171
}
7272
},
7373
methods: {
74-
toggle () {
75-
this.toggleWithValue(!this.expanded)
74+
toggle (event) {
75+
this.toggleWithValue(!this.expanded, event.altKey)
7676
},
7777
expand () {
7878
this.toggleWithValue(true)
7979
},
8080
collapse () {
8181
this.toggleWithValue(false)
8282
},
83-
toggleWithValue (val) {
84-
this.$store.commit('components/TOGGLE_INSTANCE', {
85-
id: this.instance.id,
86-
expanded: val
83+
toggleWithValue (val, recursive = false) {
84+
this.$store.dispatch('components/toggleInstance', {
85+
instance: this.instance,
86+
expanded: val,
87+
recursive
8788
})
8889
},
8990
select () {

src/devtools/views/components/module.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,25 @@ const mutations = {
3030
}
3131
}
3232

33+
const actions = {
34+
toggleInstance ({commit, dispatch}, {instance, expanded, recursive}) {
35+
commit('TOGGLE_INSTANCE', {id: instance.id, expanded})
36+
37+
if (recursive) {
38+
instance.children.forEach((child) => {
39+
dispatch('toggleInstance', {
40+
instance: child,
41+
expanded,
42+
recursive
43+
})
44+
})
45+
}
46+
}
47+
}
48+
3349
export default {
3450
namespaced: true,
3551
state,
36-
mutations
52+
mutations,
53+
actions
3754
}

0 commit comments

Comments
 (0)