Skip to content

Commit

Permalink
Clear connectivity logs button
Browse files Browse the repository at this point in the history
Summary: Add the option to clear the connectivity logs.

Reviewed By: antonk52

Differential Revision: D47797301

fbshipit-source-id: ce9414f3057cab367d34524717c83bfbf0703c0c
  • Loading branch information
lblasa authored and facebook-github-bot committed Jul 26, 2023
1 parent fa1c2db commit c3a40ab
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion desktop/flipper-ui-core/src/chrome/ConnectivityHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
Tabs,
theme,
} from 'flipper-plugin';
import {CloseCircleFilled} from '@ant-design/icons';
import {CloseCircleFilled, DeleteOutlined} from '@ant-design/icons';
import {
CommandRecordEntry,
ConnectionRecordEntry,
Expand All @@ -28,6 +28,7 @@ import {
import SetupDoctorScreen from '../sandy-chrome/SetupDoctorScreen';
import {ConsoleLogs} from './ConsoleLogs';
import {FlipperMessages} from './FlipperMessages';
import {Button} from 'antd';

const rows = createDataSource<ConnectionRecordEntry>([], {
limit: 200000,
Expand Down Expand Up @@ -130,13 +131,27 @@ function getRowStyle(entry: ConnectionRecordEntry): CSSProperties | undefined {
return (logTypes[entry.type]?.style as any) ?? baseRowStyle;
}

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

export function ConnectivityHub() {
const columns = createColumnConfig();

const tableManagerRef = createRef<
undefined | DataTableManager<ConnectionRecordEntry>
>();

const clearButton = (
<Button
title="Clear logs"
onClick={() => {
clearMessages();
}}>
<DeleteOutlined />
</Button>
);

const LogView = () => (
<DataTable<ConnectionRecordEntry>
dataSource={rows}
Expand All @@ -146,6 +161,7 @@ export function ConnectivityHub() {
onRowStyle={getRowStyle}
enableHorizontalScroll={false}
tableManagerRef={tableManagerRef}
extraActions={clearButton}
/>
);

Expand Down

0 comments on commit c3a40ab

Please sign in to comment.