Skip to content

Commit d25612a

Browse files
committed
tweak state inspector labels text and order
1 parent ddd8a94 commit d25612a

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/backend/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ function processProps (instance) {
351351
const prop = props[key]
352352
const options = prop.options
353353
return {
354-
type: 'prop',
354+
type: 'props',
355355
key: prop.path,
356356
value: instance[prop.path],
357357
meta: {
@@ -367,7 +367,7 @@ function processProps (instance) {
367367
const prop = props[key]
368368
key = camelize(key)
369369
return {
370-
type: 'prop',
370+
type: 'props',
371371
key,
372372
value: instance[key],
373373
meta: {
@@ -439,7 +439,7 @@ function processComputed (instance) {
439439
for (const key in defs) {
440440
const def = defs[key]
441441
const type = typeof def === 'function' && def.vuex
442-
? 'vuex'
442+
? 'vuex bindings'
443443
: 'computed'
444444
// use try ... catch here because some computed properties may
445445
// throw error during its evaluation
@@ -503,7 +503,7 @@ function processVuexGetters (instance) {
503503
if (getters) {
504504
return Object.keys(getters).map(key => {
505505
return {
506-
type: 'vuex getter',
506+
type: 'vuex getters',
507507
key,
508508
value: instance[key]
509509
}
@@ -525,7 +525,7 @@ function processFirebaseBindings (instance) {
525525
if (refs) {
526526
return Object.keys(refs).map(key => {
527527
return {
528-
type: 'firebase',
528+
type: 'firebase bindings',
529529
key,
530530
value: instance[key]
531531
}
@@ -547,7 +547,7 @@ function processObservables (instance) {
547547
if (obs) {
548548
return Object.keys(obs).map(key => {
549549
return {
550-
type: 'observable',
550+
type: 'observables',
551551
key,
552552
value: instance[key]
553553
}

src/devtools/components/StateInspector.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="data-wrapper">
3-
<div v-for="type in Object.keys(state)" :class="['data-el', toDisplayType(type)]">
4-
<div class="data-type">{{ toDisplayType(type, true) }}</div>
3+
<div v-for="type in getKeys(state)" :class="['data-el', toDisplayType(type)]">
4+
<div class="data-type">{{ toDisplayType(type) }}</div>
55
<div class="data-fields">
66
<template v-if="Array.isArray(state[type])">
77
<data-field
@@ -27,20 +27,32 @@
2727
<script>
2828
import DataField from './DataField.vue'
2929
30+
const keyOrder = {
31+
undefined: 1,
32+
props: 2,
33+
computed: 3,
34+
state: 1,
35+
getters: 2
36+
}
37+
3038
export default {
3139
props: ['state'],
3240
components: {
3341
DataField
3442
},
3543
methods: {
36-
toDisplayType (type, full) {
44+
getKeys (state) {
45+
return Object.keys(state).sort((a, b) => {
46+
return (
47+
(keyOrder[a] || (a.charCodeAt(0) + 999)) -
48+
(keyOrder[b] || (b.charCodeAt(0) + 999))
49+
)
50+
})
51+
},
52+
toDisplayType (type) {
3753
return type === 'undefined'
3854
? 'data'
39-
: full
40-
? (type === 'vuex' || type === 'firebase')
41-
? type + ' bindings'
42-
: type
43-
: type
55+
: type
4456
}
4557
}
4658
}

0 commit comments

Comments
 (0)