Skip to content

Commit 2f39369

Browse files
Fix homepage template kind chip (#2110)
* fix(homepage): inconsistent usage of resource kind chip on template section on homepage * add category tag to the templates * remove template tag * remove template tag
1 parent 1b2f9a7 commit 2f39369

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed
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-dynamic-home-page': patch
3+
---
4+
5+
Fix inconsistent usage of resource kind chip on template homepage

workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateCard.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('TemplateCard', () => {
2424
title: 'Sample Template',
2525
description:
2626
'This is a description of the sample template used for testing.',
27-
kind: 'Template',
27+
type: 'website',
2828
};
2929

3030
const renderComponent = () =>
@@ -52,8 +52,8 @@ describe('TemplateCard', () => {
5252
expect(screen.getByText(/this is a description/i)).toBeInTheDocument();
5353
});
5454

55-
it('should display the correct kind in the Chip', () => {
55+
it('should display the correct type in the Chip', () => {
5656
renderComponent();
57-
expect(screen.getByText(props.kind)).toBeInTheDocument();
57+
expect(screen.getByText(props.type)).toBeInTheDocument();
5858
});
5959
});

workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateCard.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ interface TemplateCardProps {
2828
link: string;
2929
title: string;
3030
description: string;
31-
kind: string;
31+
type?: string;
3232
}
3333

3434
const TemplateCard: FC<TemplateCardProps> = ({
3535
link,
3636
title,
3737
description,
38-
kind,
38+
type,
3939
}) => {
4040
return (
4141
<Card
@@ -55,17 +55,6 @@ const TemplateCard: FC<TemplateCardProps> = ({
5555
backgroundColor: 'transparent',
5656
}}
5757
>
58-
<Box sx={{ padding: '8px 0' }}>
59-
<Chip
60-
label={
61-
<Typography sx={{ fontSize: '0.8rem', fontWeight: 400 }}>
62-
{kind}
63-
</Typography>
64-
}
65-
key={kind}
66-
size="small"
67-
/>
68-
</Box>
6958
<Box sx={{ margin: '8px 0', height: '21px', overflow: 'hidden' }}>
7059
<Link
7160
to={link}
@@ -107,6 +96,19 @@ const TemplateCard: FC<TemplateCardProps> = ({
10796
<MarkdownContent content={description} />
10897
</Typography>
10998
</Box>
99+
<Box sx={{ pt: 2 }}>
100+
{type && (
101+
<Chip
102+
label={
103+
<Typography sx={{ fontSize: '0.8rem', fontWeight: 400 }}>
104+
{type}
105+
</Typography>
106+
}
107+
key={type}
108+
size="small"
109+
/>
110+
)}
111+
</Box>
110112
</CardContent>
111113
</Card>
112114
);

workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const TemplateSection = () => {
9595
link={`/create/templates/${item.metadata.namespace}/${item.metadata.name}`}
9696
title={item.metadata.title}
9797
description={item.metadata.description}
98-
kind="Template"
98+
type={item.spec.type}
9999
/>
100100
</Grid>
101101
))}

0 commit comments

Comments
 (0)