-
Notifications
You must be signed in to change notification settings - Fork 15
fix(ClusterInfo): update links view #1746
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
Changes from all 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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import {DefinitionList, Flex} from '@gravity-ui/uikit'; | ||
|
||
import {ResponseError} from '../../../components/Errors/ResponseError'; | ||
import {InfoViewer} from '../../../components/InfoViewer/InfoViewer'; | ||
import {InfoViewerSkeleton} from '../../../components/InfoViewerSkeleton/InfoViewerSkeleton'; | ||
import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon'; | ||
import type {AdditionalClusterProps} from '../../../types/additionalProps'; | ||
import type {TClusterInfo} from '../../../types/api/cluster'; | ||
import type {IResponseError} from '../../../types/api/error'; | ||
import type {VersionToColorMap} from '../../../types/versions'; | ||
import i18n from '../i18n'; | ||
|
||
import {b} from './shared'; | ||
import {getInfo, useClusterLinks} from './utils'; | ||
|
@@ -28,25 +31,65 @@ export const ClusterInfo = ({ | |
const {info = [], links = []} = additionalClusterProps; | ||
|
||
const clusterLinks = useClusterLinks(); | ||
const linksList = links.concat(clusterLinks); | ||
|
||
const clusterInfo = getInfo(cluster ?? {}, info, [...links, ...clusterLinks]); | ||
|
||
const getContent = () => { | ||
if (loading) { | ||
return <InfoViewerSkeleton className={b('skeleton')} rows={9} />; | ||
} | ||
const clusterInfo = getInfo(cluster ?? {}, info); | ||
|
||
const renderInfo = () => { | ||
if (error && !cluster) { | ||
return null; | ||
} | ||
|
||
return <InfoViewer dots={true} info={clusterInfo} />; | ||
return ( | ||
<div> | ||
<div className={b('section-title')}>{i18n('title_info')}</div> | ||
<DefinitionList nameMaxWidth={200}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 200 max width is names width of |
||
{clusterInfo.map(({label, value}) => { | ||
return ( | ||
<DefinitionList.Item key={label} name={label}> | ||
{value} | ||
</DefinitionList.Item> | ||
); | ||
})} | ||
</DefinitionList> | ||
</div> | ||
); | ||
}; | ||
|
||
const renderLinks = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (linksList.length) { | ||
return ( | ||
<div> | ||
<div className={b('section-title')}>{i18n('title_links')}</div> | ||
<Flex direction="column" gap={4}> | ||
{linksList.map(({title, url}) => { | ||
return <LinkWithIcon key={title} title={title} url={url} />; | ||
})} | ||
</Flex> | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
const renderContent = () => { | ||
if (loading) { | ||
return <InfoViewerSkeleton className={b('skeleton')} rows={4} />; | ||
} | ||
|
||
return ( | ||
<Flex gap={10} wrap="nowrap"> | ||
{renderInfo()} | ||
{renderLinks()} | ||
</Flex> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className={b()}> | ||
{error ? <ResponseError error={error} className={b('error')} /> : null} | ||
<div className={b('info')}>{getContent()}</div> | ||
{renderContent()} | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,14 @@ import React from 'react'; | |
|
||
import {Flex} from '@gravity-ui/uikit'; | ||
|
||
import type {InfoViewerItem} from '../../../components/InfoViewer/InfoViewer'; | ||
import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon'; | ||
import {ProgressViewer} from '../../../components/ProgressViewer/ProgressViewer'; | ||
import {Tags} from '../../../components/Tags'; | ||
import {useClusterBaseInfo} from '../../../store/reducers/cluster/cluster'; | ||
import type {ClusterLink} from '../../../types/additionalProps'; | ||
import {isClusterInfoV2} from '../../../types/api/cluster'; | ||
import type {TClusterInfo} from '../../../types/api/cluster'; | ||
import type {EFlag} from '../../../types/api/enums'; | ||
import type {TTabletStateInfo} from '../../../types/api/tablet'; | ||
import {EType} from '../../../types/api/tablet'; | ||
import type {InfoItem} from '../../../types/components'; | ||
import {formatNumber} from '../../../utils/dataFormatters/dataFormatters'; | ||
import {parseJson} from '../../../utils/utils'; | ||
import i18n from '../i18n'; | ||
|
@@ -29,18 +26,6 @@ const COLORS_PRIORITY: Record<EFlag, number> = { | |
Grey: 0, | ||
}; | ||
|
||
export const compareTablets = (tablet1: TTabletStateInfo, tablet2: TTabletStateInfo) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unneeded function |
||
if (tablet1.Type === EType.TxAllocator) { | ||
return 1; | ||
} | ||
|
||
if (tablet2.Type === EType.TxAllocator) { | ||
return -1; | ||
} | ||
|
||
return 0; | ||
}; | ||
|
||
const getDCInfo = (cluster: TClusterInfo) => { | ||
if (isClusterInfoV2(cluster) && cluster.MapDataCenters) { | ||
return Object.entries(cluster.MapDataCenters).map(([dc, count]) => ( | ||
|
@@ -52,12 +37,8 @@ const getDCInfo = (cluster: TClusterInfo) => { | |
return undefined; | ||
}; | ||
|
||
export const getInfo = ( | ||
cluster: TClusterInfo, | ||
additionalInfo: InfoViewerItem[], | ||
links: ClusterLink[], | ||
) => { | ||
const info: InfoViewerItem[] = []; | ||
export const getInfo = (cluster: TClusterInfo, additionalInfo: InfoItem[]) => { | ||
const info: InfoItem[] = []; | ||
|
||
if (isClusterInfoV2(cluster) && cluster.MapNodeStates) { | ||
const arrayNodesStates = Object.entries(cluster.MapNodeStates) as [EFlag, number][]; | ||
|
@@ -80,7 +61,7 @@ export const getInfo = ( | |
if (dataCenters?.length) { | ||
info.push({ | ||
label: i18n('label_dc'), | ||
value: <Tags tags={dataCenters} gap={2} />, | ||
value: <Tags tags={dataCenters} gap={2} className={b('dc')} />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set element height, so info and links sections rows have the same height |
||
}); | ||
} | ||
|
||
|
@@ -91,19 +72,6 @@ export const getInfo = ( | |
|
||
info.push(...additionalInfo); | ||
|
||
if (links.length) { | ||
info.push({ | ||
label: i18n('links'), | ||
value: ( | ||
<div className={b('links')}> | ||
{links.map(({title, url}) => ( | ||
<LinkWithIcon key={title} title={title} url={url} /> | ||
))} | ||
</div> | ||
), | ||
}); | ||
} | ||
|
||
return info; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type React from 'react'; | ||
|
||
export interface InfoItem { | ||
label: string; | ||
value: React.ReactNode; | ||
} |
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.
I didn't find usages of these classes, so I deleted them