2021-01-07 16:15:34 -08:00
|
|
|
/*
|
|
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-02-24 13:39:51 -08:00
|
|
|
import { ActionEntry, TraceModel } from '../../../server/trace/viewer/traceModel';
|
2021-01-07 16:15:34 -08:00
|
|
|
import { ActionList } from './actionList';
|
2021-02-17 17:51:57 -08:00
|
|
|
import { TabbedPane } from './tabbedPane';
|
2021-01-07 16:15:34 -08:00
|
|
|
import { Timeline } from './timeline';
|
|
|
|
import './workbench.css';
|
|
|
|
import * as React from 'react';
|
|
|
|
import { ContextSelector } from './contextSelector';
|
2021-02-17 17:51:57 -08:00
|
|
|
import { NetworkTab } from './networkTab';
|
|
|
|
import { SourceTab } from './sourceTab';
|
|
|
|
import { SnapshotTab } from './snapshotTab';
|
|
|
|
import { LogsTab } from './logsTab';
|
2021-01-07 16:15:34 -08:00
|
|
|
|
|
|
|
export const Workbench: React.FunctionComponent<{
|
|
|
|
traceModel: TraceModel,
|
|
|
|
}> = ({ traceModel }) => {
|
|
|
|
const [context, setContext] = React.useState(traceModel.contexts[0]);
|
2021-01-14 20:16:02 -08:00
|
|
|
const [selectedAction, setSelectedAction] = React.useState<ActionEntry | undefined>();
|
|
|
|
const [highlightedAction, setHighlightedAction] = React.useState<ActionEntry | undefined>();
|
2021-01-26 15:09:17 -08:00
|
|
|
const [selectedTime, setSelectedTime] = React.useState<number | undefined>();
|
2021-01-07 16:15:34 -08:00
|
|
|
|
|
|
|
const actions = React.useMemo(() => {
|
|
|
|
const actions: ActionEntry[] = [];
|
|
|
|
for (const page of context.pages)
|
|
|
|
actions.push(...page.actions);
|
|
|
|
return actions;
|
|
|
|
}, [context]);
|
|
|
|
|
2021-01-20 16:19:01 -08:00
|
|
|
const snapshotSize = context.created.viewportSize || { width: 1280, height: 720 };
|
2021-01-26 15:09:17 -08:00
|
|
|
const boundaries = { minimum: context.startTime, maximum: context.endTime };
|
2021-02-17 17:51:57 -08:00
|
|
|
const snapshotSelection = context.pages.length && selectedTime !== undefined ? { pageId: context.pages[0].created.pageId, time: selectedTime } : undefined;
|
2021-01-07 16:15:34 -08:00
|
|
|
|
|
|
|
return <div className='vbox workbench'>
|
|
|
|
<div className='hbox header'>
|
|
|
|
<div className='logo'>🎭</div>
|
|
|
|
<div className='product'>Playwright</div>
|
|
|
|
<div className='spacer'></div>
|
|
|
|
<ContextSelector
|
|
|
|
contexts={traceModel.contexts}
|
|
|
|
context={context}
|
|
|
|
onChange={context => {
|
|
|
|
setContext(context);
|
2021-01-14 20:16:02 -08:00
|
|
|
setSelectedAction(undefined);
|
2021-01-26 15:09:17 -08:00
|
|
|
setSelectedTime(undefined);
|
2021-01-07 16:15:34 -08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div style={{ background: 'white', paddingLeft: '20px', flex: 'none' }}>
|
|
|
|
<Timeline
|
|
|
|
context={context}
|
2021-01-26 15:09:17 -08:00
|
|
|
boundaries={boundaries}
|
2021-01-14 20:16:02 -08:00
|
|
|
selectedAction={selectedAction}
|
|
|
|
highlightedAction={highlightedAction}
|
2021-01-27 19:42:51 -08:00
|
|
|
onSelected={action => setSelectedAction(action)}
|
2021-01-26 15:09:17 -08:00
|
|
|
onTimeSelected={time => setSelectedTime(time)}
|
2021-01-21 08:29:01 -08:00
|
|
|
/>
|
2021-01-07 16:15:34 -08:00
|
|
|
</div>
|
|
|
|
<div className='hbox'>
|
2021-01-21 08:29:01 -08:00
|
|
|
<div style={{ display: 'flex', flex: 'none', overflow: 'auto' }}>
|
2021-01-14 20:16:02 -08:00
|
|
|
<ActionList
|
|
|
|
actions={actions}
|
|
|
|
selectedAction={selectedAction}
|
|
|
|
highlightedAction={highlightedAction}
|
2021-01-26 15:09:17 -08:00
|
|
|
onSelected={action => {
|
|
|
|
setSelectedAction(action);
|
|
|
|
setSelectedTime(undefined);
|
|
|
|
}}
|
2021-01-14 20:16:02 -08:00
|
|
|
onHighlighted={action => setHighlightedAction(action)}
|
|
|
|
/>
|
2021-01-07 16:15:34 -08:00
|
|
|
</div>
|
2021-02-17 17:51:57 -08:00
|
|
|
<TabbedPane tabs={[
|
|
|
|
{ id: 'snapshot', title: 'Snapshot', render: () => <SnapshotTab actionEntry={selectedAction} snapshotSize={snapshotSize} selection={snapshotSelection} boundaries={boundaries} /> },
|
|
|
|
{ id: 'source', title: 'Source', render: () => <SourceTab actionEntry={selectedAction} /> },
|
|
|
|
{ id: 'network', title: 'Network', render: () => <NetworkTab actionEntry={selectedAction} /> },
|
|
|
|
{ id: 'logs', title: 'Logs', render: () => <LogsTab actionEntry={selectedAction} /> },
|
|
|
|
]}/>
|
2021-01-07 16:15:34 -08:00
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
};
|