chore(trace-viewer): only show source tab when soureces are includes (#10338)

This commit is contained in:
Pavel Feldman 2021-11-15 23:37:39 -08:00 committed by GitHub
parent 565ac910e7
commit 9485e62a00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View file

@ -30,6 +30,7 @@ export type ContextEntry = {
actions: trace.ActionTraceEvent[];
events: trace.ActionTraceEvent[];
objects: { [key: string]: any };
hasSource: boolean;
};
export type PageEntry = {
@ -55,5 +56,6 @@ export function createEmptyContext(): ContextEntry {
actions: [],
events: [],
objects: {},
hasSource: false
};
}

View file

@ -48,6 +48,8 @@ export class TraceModel {
traceEntry = entry;
if (entry.filename.endsWith('.network'))
networkEntry = entry;
if (entry.filename.includes('src@'))
this.contextEntry.hasSource = true;
this._entries.set(entry.filename, entry);
}
this._snapshotStorage = new PersistentSnapshotStorage(this._entries);

View file

@ -124,7 +124,7 @@ export const Workbench: React.FunctionComponent<{
{ id: 'network', title: 'Network', count: networkCount, render: () => <NetworkTab action={selectedAction} /> },
];
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')
if (contextEntry.hasSource)
tabs.push({ id: 'source', title: 'Source', count: 0, render: () => <SourceTab action={selectedAction} /> });
return <div className='vbox workbench' onDragOver={event => { event.preventDefault(); setDragOver(true); }}>