Skip to content

Commit 4bd91cf

Browse files
committed
feat(timeline): allow disable component events, closes #1545
1 parent 3f7a2df commit 4bd91cf

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BackendContext } from '@vue-devtools/app-backend-api'
22
import { BridgeEvents, HookEvents, stringify } from '@vue-devtools/shared-utils'
3-
import { App, ID, TimelineEventOptions, TimelineLayerOptions, WithId } from '@vue/devtools-api'
3+
import SharedData from '@vue-devtools/shared-utils/lib/shared-data'
4+
import { App, ID, TimelineEventOptions, WithId } from '@vue/devtools-api'
45
import { hook } from './global-hook'
56
import { getAppRecord, getAppRecordId } from './app'
67
import { builtinLayers } from './timeline-builtins'
@@ -68,6 +69,8 @@ function setupBuiltinLayers (ctx: BackendContext) {
6869

6970
hook.on(HookEvents.COMPONENT_EMIT, async (app, instance, event, params) => {
7071
try {
72+
if (!SharedData.componentEventsEnabled) return
73+
7174
const appRecord = await getAppRecord(app, ctx)
7275
const componentId = `${appRecord.id}:${instance.uid}`
7376
const componentDisplay = (await ctx.api.getComponentName(instance)) || '<i>Unknown Component</i>'

packages/app-frontend/src/features/timeline/LayerItem.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export default defineComponent({
9393
<span
9494
class="truncate text-sm"
9595
:class="{
96-
'opacity-50': layer.id === 'performance' && !$shared.performanceMonitoringEnabled,
96+
'opacity-50': (
97+
layer.id === 'component-event' && !$shared.componentEventsEnabled ||
98+
layer.id === 'performance' && !$shared.performanceMonitoringEnabled
99+
),
97100
}"
98101
:style="{
99102
'color': selected ? `#${color}` : undefined
@@ -108,6 +111,17 @@ export default defineComponent({
108111
</div>
109112

110113
<div class="flex items-center space-x-1">
114+
<VueButton
115+
v-if="hover && layer.id === 'component-event'"
116+
class="text-xs px-1 py-0 h-5 hover:opacity-80"
117+
:style="{
118+
backgroundColor: `#${color}28`,
119+
}"
120+
@click.stop="$shared.componentEventsEnabled = !$shared.componentEventsEnabled"
121+
>
122+
{{ $shared.componentEventsEnabled ? 'Disable' : 'Enable' }}
123+
</VueButton>
124+
111125
<VueButton
112126
v-if="hover && layer.id === 'performance'"
113127
class="text-xs px-1 py-0 h-5 hover:opacity-80"

packages/shared-utils/src/shared-data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const internalSharedData = {
1313
cacheVuexSnapshotsEvery: 50,
1414
cacheVuexSnapshotsLimit: 10,
1515
snapshotLoading: false,
16+
componentEventsEnabled: true,
1617
performanceMonitoringEnabled: true,
1718
editableProps: false,
1819
logDetected: true,
@@ -42,7 +43,8 @@ const persisted = [
4243
'timelineScreenshots',
4344
'menuStepScrolling',
4445
'pluginPermissions',
45-
'performanceMonitoringEnabled'
46+
'performanceMonitoringEnabled',
47+
'componentEventsEnabled'
4648
]
4749

4850
const storageVersion = '6.0.0-alpha.1'

0 commit comments

Comments
 (0)