mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
90 lines
3.1 KiB
TypeScript
90 lines
3.1 KiB
TypeScript
/*
|
|
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.
|
|
*/
|
|
|
|
import { ActionEntry, TraceModel } from '../../../cli/traceViewer/traceModel';
|
|
import { ActionList } from './actionList';
|
|
import { PropertiesTabbedPane } from './propertiesTabbedPane';
|
|
import { Timeline } from './timeline';
|
|
import './workbench.css';
|
|
import * as React from 'react';
|
|
import { ContextSelector } from './contextSelector';
|
|
|
|
export const Workbench: React.FunctionComponent<{
|
|
traceModel: TraceModel,
|
|
}> = ({ traceModel }) => {
|
|
const [context, setContext] = React.useState(traceModel.contexts[0]);
|
|
const [selectedAction, setSelectedAction] = React.useState<ActionEntry | undefined>();
|
|
const [highlightedAction, setHighlightedAction] = React.useState<ActionEntry | undefined>();
|
|
const [selectedTime, setSelectedTime] = React.useState<number | undefined>();
|
|
|
|
const actions = React.useMemo(() => {
|
|
const actions: ActionEntry[] = [];
|
|
for (const page of context.pages)
|
|
actions.push(...page.actions);
|
|
return actions;
|
|
}, [context]);
|
|
|
|
const snapshotSize = context.created.viewportSize || { width: 1280, height: 720 };
|
|
const boundaries = { minimum: context.startTime, maximum: context.endTime };
|
|
|
|
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);
|
|
setSelectedAction(undefined);
|
|
setSelectedTime(undefined);
|
|
}}
|
|
/>
|
|
</div>
|
|
<div style={{ background: 'white', paddingLeft: '20px', flex: 'none' }}>
|
|
<Timeline
|
|
context={context}
|
|
boundaries={boundaries}
|
|
selectedAction={selectedAction}
|
|
highlightedAction={highlightedAction}
|
|
onSelected={action => setSelectedAction(action)}
|
|
onTimeSelected={time => setSelectedTime(time)}
|
|
/>
|
|
</div>
|
|
<div className='hbox'>
|
|
<div style={{ display: 'flex', flex: 'none', overflow: 'auto' }}>
|
|
<ActionList
|
|
actions={actions}
|
|
selectedAction={selectedAction}
|
|
highlightedAction={highlightedAction}
|
|
onSelected={action => {
|
|
setSelectedAction(action);
|
|
setSelectedTime(undefined);
|
|
}}
|
|
onHighlighted={action => setHighlightedAction(action)}
|
|
/>
|
|
</div>
|
|
<PropertiesTabbedPane
|
|
actionEntry={selectedAction}
|
|
snapshotSize={snapshotSize}
|
|
selectedTime={selectedTime}
|
|
boundaries={boundaries}
|
|
/>
|
|
</div>
|
|
</div>;
|
|
};
|