Last active
February 10, 2025 14:56
-
-
Save brandonbryant12/443f51919d1ae640eb95a53cce7aebc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { | |
TemplateCard, | |
type TemplateCardProps, | |
} from '@backstage/plugin-scaffolder-react'; | |
import { Typography, makeStyles } from '@material-ui/core'; | |
const useStyles = makeStyles(theme => ({ | |
annotation: { | |
marginTop: theme.spacing(1), | |
color: theme.palette.text.secondary, | |
fontSize: '0.875rem', | |
}, | |
})); | |
export const CustomTemplateCard = (props: TemplateCardProps) => { | |
const { template } = props; | |
const classes = useStyles(); | |
const createdAt = template.metadata.annotations?.['backstage.io/created-at']; | |
const updatedAt = template.metadata.annotations?.['backstage.io/updated-at']; | |
return ( | |
<TemplateCard | |
{...props} | |
title={ | |
<> | |
{props.title} | |
{createdAt && ( | |
<Typography className={classes.annotation}> | |
Created: {new Date(createdAt).toLocaleDateString()} | |
</Typography> | |
)} | |
{updatedAt && ( | |
<Typography className={classes.annotation}> | |
Updated: {new Date(updatedAt).toLocaleDateString()} | |
</Typography> | |
)} | |
</> | |
} | |
/> | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ScaffolderPage } from '@backstage/plugin-scaffolder'; | |
import { CustomTemplateCard } from './components/scaffolder/CustomTemplateCard'; | |
// In your routes: | |
<Route path="/create" element={ | |
<ScaffolderPage | |
components={{ | |
TemplateCard: CustomTemplateCard | |
}} | |
/> | |
} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment