Skip to content

Commit 7963e47

Browse files
committed
chore: CHART_CARD_MAX_LENGTH integration
1 parent 593dcc3 commit 7963e47

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/components/charts/ChartGroupCard.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import ChartIcon from './ChartIcon'
2424
import { getChartGroupURL } from './charts.helper'
2525
import { ChartGroupCardProps } from './charts.types'
2626
import { getChartGroupSubgroup, getDescriptionTruncate } from './charts.util'
27+
import { CHART_CARD_MAX_LENGTH } from './constants'
2728

2829
export const ChartGroupCard = ({ chartGroup }: ChartGroupCardProps) => {
2930
const chartGroupEntries = getChartGroupSubgroup(chartGroup.chartGroupEntries)
@@ -77,9 +78,18 @@ export const ChartGroupCard = ({ chartGroup }: ChartGroupCardProps) => {
7778
<div className="flexbox-col h-166 dc__gap-12 px-20 pt-20 pb-16">
7879
<div className="flexbox">
7980
{chartGroupEntries?.length ? (
80-
chartGroupEntries.map((chart) => (
81-
<ChartIcon icon={chart.chartMetaData.icon} key={chart.id} isChartGroupCard />
82-
))
81+
<>
82+
{chartGroupEntries.map((chart) => (
83+
<ChartIcon icon={chart.chartMetaData.icon} key={chart.id} isChartGroupCard />
84+
))}
85+
{chartGroup.chartGroupEntries.length > CHART_CARD_MAX_LENGTH && (
86+
<div className="chart-group-card__icon-wrapper border__secondary-translucent bg__secondary br-8 p-8 dc__w-fit-content h-50">
87+
<span className="fs-20 lh-1-5 cn-8">
88+
+{chartGroup.chartGroupEntries.length - CHART_CARD_MAX_LENGTH}
89+
</span>
90+
</div>
91+
)}
92+
</>
8393
) : (
8494
<div className="dc__border-dashed bg__secondary br-8 p-8 dc__w-fit-content h-50">
8595
<Icon name="ic-folder-color" size={32} color={null} />

src/components/charts/charts.util.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Icon } from '@devtron-labs/devtron-fe-common-lib'
1818
import { ChartDescriptionTypes, ChartGroupEntry } from './charts.types'
19+
import { CHART_CARD_MAX_LENGTH } from './constants'
1920

2021
export const PaginationParams = {
2122
pageOffset: 0,
@@ -50,7 +51,7 @@ export const renderDeprecatedWarning = () => {
5051

5152
export const getChartGroupSubgroup = (chartGroupEntries): ChartGroupEntry[] => {
5253
let len = chartGroupEntries.length
53-
len = len < 4 ? len : 4
54+
len = len < CHART_CARD_MAX_LENGTH ? len : CHART_CARD_MAX_LENGTH
5455
return chartGroupEntries.slice(0, len)
5556
}
5657

src/components/charts/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ export const QueryParams = {
4747
SearchKey: 'searchKey',
4848
ChartCategoryId: 'chartCategoryId',
4949
}
50+
51+
export const CHART_CARD_MAX_LENGTH = 4

0 commit comments

Comments
 (0)