Skip to content

Commit

Permalink
chore: optimize sidebar content
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoushaw committed Jul 28, 2024
1 parent 47e9d6d commit f1adf58
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
5 changes: 1 addition & 4 deletions packages/visualizer-report/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { BrowserRouter, Link, Route, Routes } from '@modern-js/runtime/router';
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
import { Report } from './pages/Report';
import { Home } from './pages/Home';

export default () => {
return (
<BrowserRouter>
<ul>
<Link to="/">Back to Home</Link>
</ul>
<Routes>
<Route index element={<Home />} />
<Route path="report" element={<Report />} />
Expand Down
13 changes: 12 additions & 1 deletion packages/visualizer-report/src/pages/Report.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Visualizer } from '@midscene/visualizer';
import React, { useEffect, useState } from 'react';
import { useNavigate } from '@modern-js/runtime/router';

declare module '@midscene/visualizer' {
export function Visualizer(dumpInfo: any): any;
}

export function Report() {
const navigation = useNavigate();
const [dumpJson, setDumpJson] = useState<any>(null);
const [isLoading, setLoading] = useState<any>(true);
// eslint-disable-next-line node/prefer-global/url-search-params
Expand All @@ -32,7 +34,16 @@ export function Report() {
return (
<div className="container-box">
<div>
<main>{!isLoading && <Visualizer dump={dumpJson} />}</main>
<main>
{!isLoading && (
<Visualizer
dump={dumpJson}
logoAction={() => {
navigation('/');
}}
/>
)}
</main>
<div></div>
</div>
</div>
Expand Down
12 changes: 8 additions & 4 deletions packages/visualizer/src/component/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const SideItem = (props: {
);
};

const Sidebar = (props: { hideLogo?: boolean }): JSX.Element => {
const Sidebar = (props: { hideLogo?: boolean; logoAction?: () => void }): JSX.Element => {
const groupedDumps = useExecutionDump((store) => store.dump);
const setActiveTask = useExecutionDump((store) => store.setActiveTask);
const activeTask = useExecutionDump((store) => store.activeTask);
Expand Down Expand Up @@ -189,9 +189,13 @@ const Sidebar = (props: { hideLogo?: boolean }): JSX.Element => {
<div className="brand" onClick={reset} style={{ display: props?.hideLogo ? 'none' : 'flex' }}>
<Logo
style={{ width: 70, height: 70, margin: 'auto' }}
// onClick={() => {
// location.reload();
// }}
onClick={() => {
if (props.logoAction) {
props.logoAction();
} else {
location.reload();
}
}}
/>
</div>
<div className="task-list">{sideList}</div>
Expand Down
8 changes: 6 additions & 2 deletions packages/visualizer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import Sidebar from '@/component/sidebar';

const { Dragger } = Upload;

export function Visualizer(props: { hideLogo?: boolean; dump?: GroupedActionDump[] }): JSX.Element {
export function Visualizer(props: {
hideLogo?: boolean;
logoAction?: () => void;
dump?: GroupedActionDump[];
}): JSX.Element {
const { dump } = props;

const executionDump = useExecutionDump((store) => store.dump);
Expand Down Expand Up @@ -157,7 +161,7 @@ export function Visualizer(props: { hideLogo?: boolean; dump?: GroupedActionDump
}}
>
<Panel maxSize={95} defaultSize={20}>
<Sidebar hideLogo={props?.hideLogo} />
<Sidebar hideLogo={props?.hideLogo} logoAction={props?.logoAction} />
</Panel>
<PanelResizeHandle
onDragging={(isChanging) => {
Expand Down

0 comments on commit f1adf58

Please sign in to comment.