-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add network tab to node page with peer connectivity visualization #2826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+662
−8
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9a61fde
Initial plan
Copilot e96a344
feat: add network peer information to node page
Copilot d420599
feat: add network tab to node page with peer connectivity visualization
Copilot bac3c4a
Fix merge
DaryaVorontsova 4789b5a
feat: add network tab to node page with peer connectivity visualization
DaryaVorontsova 931dbd3
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova 3ea01db
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova aed1a96
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova 6e0088e
Implement new visual
DaryaVorontsova 2d87248
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova c62468c
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova 088c9f3
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova 2177317
Fix bugs
DaryaVorontsova 2b622a1
Fix bugs
DaryaVorontsova 8bfe94a
Fix bugs
DaryaVorontsova f777ecc
Fix bugs
DaryaVorontsova 560f47e
Fix bugs
DaryaVorontsova e22d053
Merge branch 'main' into copilot/fix-2428
DaryaVorontsova 12effdb
Fix
DaryaVorontsova 68ae8dd
Fix i18n
DaryaVorontsova 8dd9921
Fix bugs
DaryaVorontsova b8e7302
Fix
DaryaVorontsova b606d54
Fix bugs
DaryaVorontsova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {PaginatedTableWithLayout} from '../../../components/PaginatedTable/PaginatedTableWithLayout'; | ||
| import {TableColumnSetup} from '../../../components/TableColumnSetup/TableColumnSetup'; | ||
| import {useBridgeModeEnabled} from '../../../store/reducers/capabilities/hooks'; | ||
| import {useDatabaseFromQuery} from '../../../utils/hooks/useDatabaseFromQuery'; | ||
| import {useSelectedColumns} from '../../../utils/hooks/useSelectedColumns'; | ||
| import {useNodesPageQueryParams} from '../../Nodes/useNodesPageQueryParams'; | ||
|
|
||
| import {NodeNetworkControlsWithTableState} from './NodeNetworkControls/NodeNetworkControlsWithTableState'; | ||
| import {NodeNetworkTable} from './NodeNetworkTable'; | ||
| import {getNodeNetworkColumns} from './columns'; | ||
| import { | ||
| NODE_NETWORK_COLUMNS_IDS, | ||
| NODE_NETWORK_COLUMNS_TITLES, | ||
| NODE_NETWORK_DEFAULT_COLUMNS, | ||
| NODE_NETWORK_REQUIRED_COLUMNS, | ||
| NODE_NETWORK_TABLE_SELECTED_COLUMNS_KEY, | ||
| } from './constants'; | ||
|
|
||
| interface NodeNetworkProps { | ||
| nodeId: string; | ||
| scrollContainerRef: React.RefObject<HTMLDivElement>; | ||
| } | ||
|
|
||
| export function NodeNetwork({nodeId, scrollContainerRef}: NodeNetworkProps) { | ||
| const database = useDatabaseFromQuery(); | ||
| const isBridgeModeEnabled = useBridgeModeEnabled(); | ||
|
|
||
| const {searchValue, handleSearchQueryChange} = useNodesPageQueryParams( | ||
| undefined, // We don't need use groupByParams yet | ||
| false, // withPeerRoleFilter = false for this tab | ||
| ); | ||
|
|
||
| const allColumns = React.useMemo(() => { | ||
| const columns = getNodeNetworkColumns({database}); | ||
|
|
||
| if (!isBridgeModeEnabled) { | ||
| return columns.filter((column) => column.name !== NODE_NETWORK_COLUMNS_IDS.PileName); | ||
| } | ||
|
|
||
| return columns; | ||
| }, [database, isBridgeModeEnabled]); | ||
|
|
||
| const {columnsToShow, columnsToSelect, setColumns} = useSelectedColumns( | ||
| allColumns, | ||
| NODE_NETWORK_TABLE_SELECTED_COLUMNS_KEY, | ||
| NODE_NETWORK_COLUMNS_TITLES, | ||
| NODE_NETWORK_DEFAULT_COLUMNS, | ||
| NODE_NETWORK_REQUIRED_COLUMNS, | ||
| ); | ||
|
|
||
| return ( | ||
| <PaginatedTableWithLayout | ||
| controls={ | ||
| <NodeNetworkControlsWithTableState | ||
| searchValue={searchValue} | ||
| onSearchChange={handleSearchQueryChange} | ||
| /> | ||
| } | ||
| extraControls={ | ||
| <TableColumnSetup | ||
| popupWidth={200} | ||
| items={columnsToSelect} | ||
| showStatus | ||
| onUpdate={setColumns} | ||
| /> | ||
| } | ||
| table={ | ||
| <NodeNetworkTable | ||
| nodeId={nodeId} | ||
| searchValue={searchValue} | ||
| columns={columnsToShow} | ||
| scrollContainerRef={scrollContainerRef} | ||
| /> | ||
| } | ||
| tableWrapperProps={{ | ||
| scrollContainerRef, | ||
| scrollDependencies: [searchValue], | ||
| }} | ||
| fullHeight | ||
| /> | ||
| ); | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/containers/Node/NodeNetwork/NodeNetworkControls/NodeNetworkControls.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {EntitiesCount} from '../../../../components/EntitiesCount'; | ||
| import {Search} from '../../../../components/Search'; | ||
| import i18n from '../i18n'; | ||
|
|
||
| interface NodeNetworkControlsProps { | ||
| searchValue: string; | ||
| onSearchChange: (value: string) => void; | ||
|
|
||
| entitiesCountCurrent: number; | ||
| entitiesCountTotal: number; | ||
| entitiesLoading: boolean; | ||
| } | ||
|
|
||
| export function NodeNetworkControls({ | ||
| searchValue, | ||
| onSearchChange, | ||
| entitiesCountCurrent, | ||
| entitiesCountTotal, | ||
| entitiesLoading, | ||
| }: NodeNetworkControlsProps) { | ||
| return ( | ||
| <React.Fragment> | ||
| <Search | ||
| value={searchValue} | ||
| onChange={onSearchChange} | ||
| placeholder={i18n('search-placeholder')} | ||
| width={238} | ||
| /> | ||
| <EntitiesCount | ||
| current={entitiesCountCurrent} | ||
| total={entitiesCountTotal} | ||
| label={i18n('field_peers')} | ||
| loading={entitiesLoading} | ||
| /> | ||
| </React.Fragment> | ||
| ); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/containers/Node/NodeNetwork/NodeNetworkControls/NodeNetworkControlsWithTableState.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import {usePaginatedTableState} from '../../../../components/PaginatedTable/PaginatedTableContext'; | ||
|
|
||
| import {NodeNetworkControls} from './NodeNetworkControls'; | ||
|
|
||
| interface NodeNetworkControlsWithTableStateProps { | ||
| searchValue: string; | ||
| onSearchChange: (value: string) => void; | ||
| } | ||
|
|
||
| export function NodeNetworkControlsWithTableState({ | ||
| searchValue, | ||
| onSearchChange, | ||
| }: NodeNetworkControlsWithTableStateProps) { | ||
| const {tableState} = usePaginatedTableState(); | ||
| const {foundEntities, totalEntities, isInitialLoad} = tableState; | ||
|
|
||
| return ( | ||
| <NodeNetworkControls | ||
| searchValue={searchValue} | ||
| onSearchChange={onSearchChange} | ||
| entitiesCountCurrent={foundEntities} | ||
| entitiesCountTotal={totalEntities} | ||
| entitiesLoading={isInitialLoad} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {ResizeablePaginatedTable} from '../../../components/PaginatedTable'; | ||
| import type {PaginatedTableData} from '../../../components/PaginatedTable'; | ||
| import {renderPaginatedTableErrorMessage} from '../../../utils/renderPaginatedTableErrorMessage'; | ||
| import type {Column} from '../../../utils/tableUtils/types'; | ||
|
|
||
| import {NODE_NETWORK_COLUMNS_WIDTH_LS_KEY} from './constants'; | ||
| import {getNodePeers} from './helpers/getNodePeers'; | ||
| import type {NodePeerRow} from './helpers/nodeNetworkMapper'; | ||
| import i18n from './i18n'; | ||
|
|
||
| interface NodeNetworkTableProps { | ||
| nodeId: string; | ||
| searchValue: string; | ||
| columns: Column<NodePeerRow>[]; | ||
| scrollContainerRef: React.RefObject<HTMLElement>; | ||
| onDataFetched?: (data: PaginatedTableData<NodePeerRow>) => void; | ||
| } | ||
|
|
||
| export function NodeNetworkTable({ | ||
| nodeId, | ||
| searchValue, | ||
| columns, | ||
| scrollContainerRef, | ||
| onDataFetched, | ||
| }: NodeNetworkTableProps) { | ||
| const filters = React.useMemo( | ||
| () => ({ | ||
| nodeId, | ||
| searchValue: searchValue || undefined, | ||
| }), | ||
| [nodeId, searchValue], | ||
| ); | ||
|
|
||
| const renderEmptyDataMessage = React.useCallback(() => i18n('alert_no-network-data'), []); | ||
|
|
||
| return ( | ||
| <ResizeablePaginatedTable | ||
| columnsWidthLSKey={NODE_NETWORK_COLUMNS_WIDTH_LS_KEY} | ||
| scrollContainerRef={scrollContainerRef} | ||
| columns={columns} | ||
| fetchData={getNodePeers} | ||
| filters={filters} | ||
| tableName={i18n('table_node-peers')} | ||
| renderErrorMessage={renderPaginatedTableErrorMessage} | ||
| renderEmptyDataMessage={renderEmptyDataMessage} | ||
| onDataFetched={onDataFetched} | ||
| /> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not
isPeersHandlerAvailable, there shouldn't be such a tab at all. Also ifnetworkis in url, we should redirect user to default tab and change url as well.