Skip to content

Add option to show original component names #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shells/dev/target/Other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>

<script>
// this computed property should be visible
// this computed property should be visible
// even if component has no 'computed' defined
const computedPropMixin = {
computed: {
Expand All @@ -17,6 +17,7 @@ const computedPropMixin = {
}

export default {
name: 'other-with-mine',
props: ['id'],
mixins: [ computedPropMixin ],
data () {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function findQualifiedChildren (instance) {
*/

function isQualified (instance) {
const name = getInstanceName(instance).toLowerCase()
const name = classify(getInstanceName(instance)).toLowerCase()
return name.indexOf(filter) > -1
}

Expand Down Expand Up @@ -342,7 +342,7 @@ function getInstanceDetails (id) {
export function getInstanceName (instance) {
const name = instance.$options.name || instance.$options._componentTag
if (name) {
return classify(name)
return name
}
const file = instance.$options.__file // injected by vue-loader
if (file) {
Expand Down
Binary file modified src/devtools/assets/MaterialIcons-Regular.woff2
Binary file not shown.
3 changes: 2 additions & 1 deletion src/devtools/components/ActionHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
&:first-of-type
margin-left auto

&:not(.disabled):hover
&:not(.disabled):hover,
&:not(.disabled).active
opacity 1
color $active-color

Expand Down
16 changes: 13 additions & 3 deletions src/devtools/views/components/ComponentInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<span class="arrow right" :class="{ rotated: expanded }">
</span>
</span>
<span class="angle-bracket">&lt;</span><span class="instance-name">{{ instance.name }}</span><span class="angle-bracket">&gt;</span>
<span class="angle-bracket">&lt;</span><span class="instance-name">{{ displayName }}</span><span class="angle-bracket">&gt;</span>
</span>
<span class="info console" v-if="instance.consoleId === '$vm0'">
== {{ instance.consoleId }}
Expand All @@ -39,18 +39,25 @@
v-for="child in sortedChildren"
:key="child.id"
:instance="child"
:depth="depth + 1">
:depth="depth + 1"
:classify-display-name="classifyDisplayName">
</component-instance>
</div>
</div>
</template>

<script>
import { classify } from '../../../util'

export default {
name: 'ComponentInstance',
props: {
instance: Object,
depth: Number
depth: Number,
classifyDisplayName: {
type: Boolean,
default: true
}
},
created () {
// expand root by default
Expand All @@ -71,6 +78,9 @@ export default {
? a.id - b.id
: a.top - b.top
})
},
displayName () {
return this.classifyDisplayName ? classify(this.instance.name) : this.instance.name
}
},
methods: {
Expand Down
25 changes: 23 additions & 2 deletions src/devtools/views/components/ComponentTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
<i class="material-icons">search</i>
<input placeholder="Filter components" @input="filterInstances">
</div>
<a class="button classify-names"
:class="{ active: classifyDisplayName }"
@click="toggleComponentNames"
title="Toggle component names">
<i class="material-icons">text_fields</i>
</a>
</action-header>
<div slot="scroll" class="tree">
<component-instance
v-for="instance in instances"
ref="instances"
:key="instance.id"
:instance="instance"
:depth="0">
:depth="0"
:classifyDisplayName="classifyDisplayName">
</component-instance>
</div>
</scroll-pane>
Expand All @@ -23,7 +30,12 @@ import ScrollPane from 'components/ScrollPane.vue'
import ActionHeader from 'components/ActionHeader.vue'
import ComponentInstance from './ComponentInstance.vue'

import { classify } from '../../../util'
import keyNavMixin from '../../mixins/key-nav'
import storage from '../../storage'

const CLASSIFY_NAMES_KEY = 'CLASSIFY_COMPONENTS_NAMES'
const classifyDisplayName = storage.get(CLASSIFY_NAMES_KEY)

export default {
mixins: [keyNavMixin],
Expand All @@ -32,12 +44,17 @@ export default {
ActionHeader,
ComponentInstance
},
data () {
return {
classifyDisplayName: classifyDisplayName == null ? true : classifyDisplayName
}
},
props: {
instances: Array
},
methods: {
filterInstances (e) {
bridge.send('filter-instances', e.target.value)
bridge.send('filter-instances', classify(e.target.value))
},

onKeyNav (dir) {
Expand Down Expand Up @@ -68,6 +85,10 @@ export default {
} else {
findByIndex(all, currentIndex + 1).select()
}
},

toggleComponentNames () {
storage.set(CLASSIFY_NAMES_KEY, this.classifyDisplayName = !this.classifyDisplayName)
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/specs/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ module.exports = {
.assert.containsText('.data-el.data .data-field:nth-child(4)', 'NaN')
.assert.containsText('.data-el.data .data-field:nth-child(1)', 'Infinity')

// Classify names
.assert.containsText('.instance .instance:nth-child(3)', 'OtherWithMine')
.click('.button.classify-names')
.assert.containsText('.instance .instance:nth-child(3)', 'other-with-mine')
.click('.button.classify-names')
.assert.containsText('.instance .instance:nth-child(3)', 'OtherWithMine')

// expand child instance
.click('.instance .instance:nth-child(2) .arrow-wrapper')
.assert.count('.instance', baseInstanceCount + 2)
Expand Down