Skip to content

Commit

Permalink
Add sidebar to visualise entry details
Browse files Browse the repository at this point in the history
Summary: Follow-up from previous diff. Details can be visualised.

Reviewed By: antonk52

Differential Revision: D47797513

fbshipit-source-id: 9a560e3c7da1c9ceffd421ac2670559fdb255204
  • Loading branch information
lblasa authored and facebook-github-bot committed Jul 26, 2023
1 parent 8fc5692 commit 9a2ff5d
Showing 1 changed file with 46 additions and 14 deletions.
60 changes: 46 additions & 14 deletions desktop/flipper-ui-core/src/chrome/ConnectivityHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import React, {createRef, CSSProperties, useState} from 'react';
import {
createDataSource,
DataFormatter,
DataInspector,
DataTable,
DataTableColumn,
DataTableManager,
Tab,
Tabs,
theme,
styled,
} from 'flipper-plugin';
import {CloseCircleFilled, DeleteOutlined} from '@ant-design/icons';
import {
Expand Down Expand Up @@ -131,13 +133,40 @@ function getRowStyle(entry: ConnectionRecordEntry): CSSProperties | undefined {
return (logTypes[entry.type]?.style as any) ?? baseRowStyle;
}

const Placeholder = styled(Layout.Container)({
center: true,
color: theme.textColorPlaceholder,
fontSize: 18,
});

function Sidebar({selection}: {selection: undefined | ConnectionRecordEntry}) {
const renderExtra = (extra: any) => (
<>
<p>Details</p>
<DataInspector data={extra} expandRoot />
</>
);

return (
<Layout.ScrollContainer pad>
{selection != null ? (
renderExtra(selection)
) : (
<Placeholder grow pad="large">
Select an entry to visualize details
</Placeholder>
)}
</Layout.ScrollContainer>
);
}

function clearMessages() {
rows.clear();
}

export function ConnectivityHub() {
const columns = createColumnConfig();
const [_selection, setSelection] = useState<
const [selection, setSelection] = useState<
ConnectionRecordEntry | undefined
>();
const tableManagerRef = createRef<
Expand All @@ -155,19 +184,22 @@ export function ConnectivityHub() {
</Button>
);

const LogView = () => (
<DataTable<ConnectionRecordEntry>
dataSource={rows}
columns={columns}
enableAutoScroll
enableMultiPanels
onSelect={setSelection}
onRowStyle={getRowStyle}
enableHorizontalScroll={false}
tableManagerRef={tableManagerRef}
extraActions={clearButton}
/>
);
const LogView = () => {
return (
<Layout.Right resizable width={400}>
<DataTable<ConnectionRecordEntry>
dataSource={rows}
columns={columns}
enableAutoScroll
onRowStyle={getRowStyle}
onSelect={setSelection}
tableManagerRef={tableManagerRef}
extraActions={clearButton}
/>
<Sidebar selection={selection} />
</Layout.Right>
);
};

return (
<Layout.Container grow>
Expand Down

0 comments on commit 9a2ff5d

Please sign in to comment.