Skip to content

Commit 0dd7b78

Browse files
fix(adoption-insights): align legends, show trends, and remove empty space (#1320)
* fix(adoption-insights): align legends, show trends, and remove empty space * add changeset
1 parent 219c891 commit 0dd7b78

10 files changed

Lines changed: 28 additions & 32 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-adoption-insights': patch
3+
---
4+
5+
Align legends in Active users card, display trends on initial load, and remove empty space in no results card

workspaces/adoption-insights/plugins/adoption-insights/src/components/ActiveUsers/ActiveUsers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const ActiveUsers = () => {
6363
display="flex"
6464
justifyContent="center"
6565
alignItems="center"
66-
height={200}
66+
minHeight={80}
6767
>
6868
<EmptyChartState />
6969
</Box>

workspaces/adoption-insights/plugins/adoption-insights/src/components/ActiveUsers/CustomLegend.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const CustomLegend = (props: any) => {
3939
<div
4040
style={{
4141
width: 20,
42-
height: 3,
42+
height: 4,
4343
backgroundColor: entry.color,
4444
}}
4545
/>

workspaces/adoption-insights/plugins/adoption-insights/src/components/CatalogEntities/CatalogEntities.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const CatalogEntities = () => {
115115
display="flex"
116116
justifyContent="center"
117117
alignItems="center"
118-
height={200}
118+
minHeight={80}
119119
>
120120
<EmptyChartState />
121121
</Box>

workspaces/adoption-insights/plugins/adoption-insights/src/components/Plugins/Plugins.tsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ import { usePlugins } from '../../hooks/usePlugins';
3535
import TableFooterPagination from '../CardFooter';
3636
import { Line, LineChart, ResponsiveContainer } from 'recharts';
3737
import EmptyChartState from '../Common/EmptyChartState';
38-
import { useDateRange } from '../Header/DateRangeContext';
3938

4039
const Plugins = () => {
4140
const [page, setPage] = useState(0);
4241
const [limit] = useState(20);
4342
const [rowsPerPage, setRowsPerPage] = useState(3);
4443

45-
const { isDefaultDateRange } = useDateRange();
4644
const { plugins, loading, error } = usePlugins({ limit });
4745

4846
const handleChangePage = useCallback((_event: unknown, newPage: number) => {
@@ -79,7 +77,7 @@ const Plugins = () => {
7977
display="flex"
8078
justifyContent="center"
8179
alignItems="center"
82-
height={200}
80+
minHeight={80}
8381
>
8482
<EmptyChartState />
8583
</Box>
@@ -93,7 +91,6 @@ const Plugins = () => {
9391
<TableHead>
9492
<TableRow>
9593
{PLUGINS_TABLE_HEADERS.map(header => {
96-
if (isDefaultDateRange && header.id === 'percent') return null;
9794
return (
9895
<TableCell
9996
key={header.id}
@@ -125,11 +122,11 @@ const Plugins = () => {
125122
borderBottom: theme => `1px solid ${theme.palette.grey[300]}`,
126123
}}
127124
>
128-
<TableCell sx={isDefaultDateRange ? {} : { width: '20%' }}>
125+
<TableCell sx={{ width: '20%' }}>
129126
{plugin.plugin_id ?? '--'}
130127
</TableCell>
131128
<TableCell sx={{ width: '40%' }}>
132-
{plugin.trend?.length > 0 ? (
129+
{plugin.trend?.length > 1 ? (
133130
<ResponsiveContainer width={250} height={50}>
134131
<LineChart data={plugin.trend}>
135132
<Line
@@ -145,21 +142,19 @@ const Plugins = () => {
145142
'--'
146143
)}
147144
</TableCell>
148-
{!isDefaultDateRange && (
149-
<TableCell sx={isDefaultDateRange ? {} : { width: '20%' }}>
150-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
151-
{Math.round(Number(plugin.trend_percentage)) < 0 ? (
152-
<TrendingDownIcon sx={{ color: 'red' }} />
153-
) : (
154-
<TrendingUpIcon sx={{ color: 'green' }} />
155-
)}
156-
<Typography variant="body2">
157-
{Math.abs(Math.round(Number(plugin.trend_percentage)))}%
158-
</Typography>
159-
</Box>
160-
</TableCell>
161-
)}
162-
<TableCell sx={isDefaultDateRange ? {} : { width: '20%' }}>
145+
<TableCell sx={{ width: '20%' }}>
146+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
147+
{Math.round(Number(plugin.trend_percentage)) < 0 ? (
148+
<TrendingDownIcon sx={{ color: 'red' }} />
149+
) : (
150+
<TrendingUpIcon sx={{ color: 'green' }} />
151+
)}
152+
<Typography variant="body2">
153+
{Math.abs(Math.round(Number(plugin.trend_percentage)))}%
154+
</Typography>
155+
</Box>
156+
</TableCell>
157+
<TableCell sx={{ width: '20%' }}>
163158
{Number(plugin.visit_count).toLocaleString('en-US') ?? '--'}
164159
</TableCell>
165160
</TableRow>

workspaces/adoption-insights/plugins/adoption-insights/src/components/Plugins/__tests__/Plugins.test.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ jest.mock('../../../hooks/usePlugins', () => ({
3232
usePlugins: jest.fn(),
3333
}));
3434

35-
jest.mock('../../Header/DateRangeContext', () => ({
36-
useDateRange: jest.fn(() => ({ isDefaultDateRange: true })),
37-
}));
38-
3935
jest.mock('../../CardFooter', () => () => <div data-testid="pagination" />);
4036

4137
jest.mock('recharts', () => {

workspaces/adoption-insights/plugins/adoption-insights/src/components/Searches/Searches.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const Searches = () => {
6262
display="flex"
6363
justifyContent="center"
6464
alignItems="center"
65-
height={200}
65+
minHeight={80}
6666
>
6767
<EmptyChartState />
6868
</Box>

workspaces/adoption-insights/plugins/adoption-insights/src/components/Techdocs/Techdocs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const Techdocs = () => {
7575
display="flex"
7676
justifyContent="center"
7777
alignItems="center"
78-
height={200}
78+
minHeight={80}
7979
>
8080
<EmptyChartState />
8181
</Box>

workspaces/adoption-insights/plugins/adoption-insights/src/components/Templates/Templates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const Templates = () => {
7575
display="flex"
7676
justifyContent="center"
7777
alignItems="center"
78-
height={200}
78+
minHeight={80}
7979
>
8080
<EmptyChartState />
8181
</Box>

workspaces/adoption-insights/plugins/adoption-insights/src/components/Users/Users.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Users = () => {
6060
display="flex"
6161
justifyContent="center"
6262
alignItems="center"
63-
height={200}
63+
minHeight={80}
6464
>
6565
<EmptyChartState />
6666
</Box>

0 commit comments

Comments
 (0)