-
Notifications
You must be signed in to change notification settings - Fork 17
feat: 2dc #2699
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
feat: 2dc #2699
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,15 @@ | |
|
|
||
| margin-left: 5px; | ||
| } | ||
|
|
||
| &__details-layout { | ||
|
||
| align-items: flex-start; | ||
| gap: var(--g-spacing-6); | ||
| } | ||
|
|
||
| &__bridge-table { | ||
| flex: 0 0 360px; // do not shrink, fixed basis so stats don't take all space | ||
|
|
||
| min-width: 360px; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,10 @@ import {InfoViewerSkeleton} from '../../../components/InfoViewerSkeleton/InfoVie | |
| import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon'; | ||
| import type {ClusterGroupsStats} from '../../../store/reducers/cluster/types'; | ||
| import type {AdditionalClusterProps} from '../../../types/additionalProps'; | ||
| import type {TClusterInfo} from '../../../types/api/cluster'; | ||
| import type {TBridgePile, TClusterInfo} from '../../../types/api/cluster'; | ||
| import type {IResponseError} from '../../../types/api/error'; | ||
| import {formatNumber} from '../../../utils/dataFormatters/dataFormatters'; | ||
| import {BridgeInfoTable} from '../ClusterOverview/components/BridgeInfoTable'; | ||
| import i18n from '../i18n'; | ||
| import {getTotalStorageGroupsUsed} from '../utils'; | ||
|
|
||
|
|
@@ -19,12 +20,15 @@ import {getInfo, getStorageGroupStats} from './utils/utils'; | |
|
|
||
| import './ClusterInfo.scss'; | ||
|
|
||
| const GROUPS_SECTION_GAP = 10; | ||
|
|
||
| interface ClusterInfoProps { | ||
| cluster?: TClusterInfo; | ||
| loading?: boolean; | ||
| error?: IResponseError | string; | ||
| additionalClusterProps?: AdditionalClusterProps; | ||
| groupStats?: ClusterGroupsStats; | ||
| bridgePiles?: TBridgePile[]; | ||
| } | ||
|
|
||
| export const ClusterInfo = ({ | ||
|
|
@@ -33,6 +37,7 @@ export const ClusterInfo = ({ | |
| error, | ||
| additionalClusterProps = {}, | ||
| groupStats = {}, | ||
| bridgePiles, | ||
| }: ClusterInfoProps) => { | ||
| const {info = [], links = []} = additionalClusterProps; | ||
|
|
||
|
|
@@ -96,13 +101,25 @@ export const ClusterInfo = ({ | |
| } | ||
| return ( | ||
| <InfoSection> | ||
| <Text as="div" variant="subheader-2" className={b('section-title')}> | ||
| {i18n('title_storage-groups')}{' '} | ||
| <Text variant="subheader-2" color="secondary"> | ||
| {formatNumber(total)} | ||
| </Text> | ||
| </Text> | ||
| <Flex gap={2}>{stats}</Flex> | ||
| <Flex gap={GROUPS_SECTION_GAP} width="full"> | ||
|
||
| <Flex direction="column" gap={2}> | ||
| <Text as="div" variant="subheader-2" className={b('section-title')}> | ||
| {i18n('title_storage-groups')}{' '} | ||
| <Text variant="subheader-2" color="secondary"> | ||
| {formatNumber(total)} | ||
| </Text> | ||
| </Text> | ||
| <Flex gap={2}>{stats}</Flex> | ||
| </Flex> | ||
| {bridgePiles?.length ? ( | ||
| <Flex direction="column" gap={2} className={b('bridge-table')}> | ||
| <Text as="div" variant="subheader-2" className={b('section-title')}> | ||
| {i18n('title_bridge')} | ||
| </Text> | ||
| <BridgeInfoTable piles={bridgePiles} /> | ||
| </Flex> | ||
| ) : null} | ||
| </Flex> | ||
| </InfoSection> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import React from 'react'; | ||
|
|
||
| import type {Column} from '@gravity-ui/react-data-table'; | ||
| import DataTable from '@gravity-ui/react-data-table'; | ||
|
|
||
| import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable'; | ||
| import type {TBridgePile} from '../../../../types/api/cluster'; | ||
| import {DEFAULT_TABLE_SETTINGS, EMPTY_DATA_PLACEHOLDER} from '../../../../utils/constants'; | ||
| import {formatNumber} from '../../../../utils/dataFormatters/dataFormatters'; | ||
| import i18n from '../../i18n'; | ||
|
|
||
| interface BridgeInfoTableProps { | ||
| piles: TBridgePile[]; | ||
| collapsed?: boolean; | ||
| } | ||
|
|
||
| export function BridgeInfoTable({piles}: BridgeInfoTableProps) { | ||
| const columns = React.useMemo<Column<TBridgePile>[]>( | ||
| () => [ | ||
| { | ||
| name: 'Name', | ||
| header: i18n('label_name'), | ||
| width: 160, | ||
| align: DataTable.LEFT, | ||
| }, | ||
| { | ||
| name: 'IsPrimary', | ||
| header: i18n('label_primary'), | ||
| width: 110, | ||
| align: DataTable.LEFT, | ||
| render: ({row}) => (row.IsPrimary ? i18n('value_yes') : i18n('value_no')), | ||
| }, | ||
| { | ||
| name: 'State', | ||
| header: i18n('label_state'), | ||
| width: 160, | ||
| align: DataTable.LEFT, | ||
| }, | ||
| { | ||
| name: 'Nodes', | ||
| header: i18n('label_nodes'), | ||
| width: 100, | ||
| align: DataTable.RIGHT, | ||
| render: ({row}) => | ||
| row.Nodes === undefined ? EMPTY_DATA_PLACEHOLDER : formatNumber(row.Nodes), | ||
| }, | ||
| ], | ||
| [], | ||
| ); | ||
|
|
||
| return ( | ||
| <ResizeableDataTable<TBridgePile> | ||
| columnsWidthLSKey="bridge-columns-width" | ||
| data={piles} | ||
| columns={columns} | ||
| settings={{...DEFAULT_TABLE_SETTINGS, sortable: false}} | ||
| rowKey={(row) => `${row.PileId ?? ''}|${row.Name ?? ''}`} | ||
astandrik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /> | ||
astandrik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.