Skip to content

Commit 8c41e58

Browse files
committed
feat(api): custom inspector noSelectionText option
1 parent 4f00445 commit 8c41e58

6 files changed

Lines changed: 36 additions & 17 deletions

File tree

docs/plugin/api-reference.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,15 @@ The options are:
164164
- `icon` (optional): [Material icon code](https://material.io/resources/icons/), for example `'star'`
165165
- `treeFilterPlaceholder` (optional): placeholder of the filter input above the tree
166166
- `stateFilterPlaceholder` (optional): placeholder of the filter input in the state inspector
167+
- `noSelectionText` (optional): text displayed in the inspector pane when no node is selected
167168

168169
Example:
169170

170171
```js
172+
const INSPECTOR_ID = 'test-inspector'
173+
171174
api.addInspector({
172-
id: 'test-inspector',
175+
id: INSPECTOR_ID,
173176
label: 'Test inspector',
174177
icon: 'tab_unselected',
175178
treeFilterPlaceholder: 'Search for test...'

packages/api/src/api/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export interface CustomInspectorOptions {
7272
icon?: string
7373
treeFilterPlaceholder?: string
7474
stateFilterPlaceholder?: string
75+
noSelectionText?: string
7576
}
7677

7778
export interface CustomInspectorNode {

packages/app-backend-core/src/index.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import {
2525
getComponentInstance
2626
} from './component'
2727
import { addQueuedPlugins, addPlugin, sendPluginList, addPreviouslyRegisteredPlugins } from './plugin'
28-
import { PluginDescriptor, SetupFunction, TimelineLayerOptions, App, TimelineEventOptions, CustomInspectorOptions } from '@vue/devtools-api'
29-
import { registerApp, selectApp, mapAppRecord, getAppRecordId, waitForAppsRegistration } from './app'
30-
import { sendInspectorTree, getInspector, getInspectorWithAppId, sendInspectorState, editInspectorState } from './inspector'
28+
import { PluginDescriptor, SetupFunction, TimelineLayerOptions, TimelineEventOptions, CustomInspectorOptions } from '@vue/devtools-api'
29+
import { registerApp, selectApp, mapAppRecord, waitForAppsRegistration } from './app'
30+
import { sendInspectorTree, getInspector, getInspectorWithAppId, sendInspectorState, editInspectorState, sendCustomInspectors } from './inspector'
3131
import { showScreenshot } from './timeline-screenshot'
3232

3333
let ctx: BackendContext
@@ -257,17 +257,7 @@ async function connect () {
257257
// Custom inspectors
258258

259259
ctx.bridge.on(BridgeEvents.TO_BACK_CUSTOM_INSPECTOR_LIST, () => {
260-
ctx.bridge.send(BridgeEvents.TO_FRONT_CUSTOM_INSPECTOR_LIST, {
261-
inspectors: ctx.customInspectors.map(i => ({
262-
id: i.id,
263-
appId: getAppRecordId(i.app),
264-
pluginId: i.plugin.descriptor.id,
265-
label: i.label,
266-
icon: i.icon,
267-
treeFilterPlaceholder: i.treeFilterPlaceholder,
268-
stateFilterPlaceholder: i.stateFilterPlaceholder
269-
}))
270-
})
260+
sendCustomInspectors(ctx)
271261
})
272262

273263
ctx.bridge.on(BridgeEvents.TO_BACK_CUSTOM_INSPECTOR_TREE, ({ inspectorId, appId, treeFilter }) => {

packages/app-backend-core/src/inspector.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,18 @@ export async function editInspectorState (inspector: CustomInspector, nodeId: st
3535
value: state.value != null ? parse(state.value, true) : state.value
3636
})
3737
}
38+
39+
export async function sendCustomInspectors (ctx: BackendContext) {
40+
ctx.bridge.send(BridgeEvents.TO_FRONT_CUSTOM_INSPECTOR_LIST, {
41+
inspectors: ctx.customInspectors.map(i => ({
42+
id: i.id,
43+
appId: getAppRecordId(i.app),
44+
pluginId: i.plugin.descriptor.id,
45+
label: i.label,
46+
icon: i.icon,
47+
treeFilterPlaceholder: i.treeFilterPlaceholder,
48+
stateFilterPlaceholder: i.stateFilterPlaceholder,
49+
noSelectionText: i.noSelectionText
50+
}))
51+
})
52+
}

packages/app-frontend/src/features/inspector/custom/CustomInspectorSelectedNodePane.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import { watch } from '@vue/composition-api'
33
import { useCurrentInspector } from '.'
44
import StateInspector from '../StateInspector.vue'
5+
import EmptyPane from '@front/features/layout/EmptyPane.vue'
56
67
export default {
78
components: {
8-
StateInspector
9+
StateInspector,
10+
EmptyPane
911
},
1012
1113
setup () {
@@ -56,4 +58,11 @@ export default {
5658
@edit-state="editState"
5759
/>
5860
</div>
61+
62+
<EmptyPane
63+
v-else-if="inspector.noSelectionText"
64+
:icon="inspector.icon"
65+
>
66+
{{ inspector.noSelectionText }}
67+
</EmptyPane>
5968
</template>

packages/shell-dev-vue3/src/devtools-plugin/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ export default {
121121
id: 'test-inspector',
122122
label: 'Test inspector',
123123
icon: 'tab_unselected',
124-
treeFilterPlaceholder: 'Search for test...'
124+
treeFilterPlaceholder: 'Search for test...',
125+
noSelectionText: 'Select a node to view details'
125126
})
126127

127128
api.addInspector({

0 commit comments

Comments
 (0)