feat: add overrideable FavoriteToggle to core-components

Signed-off-by: Carl-Erik Bergström <cbergstrom@spotify.com>
This commit is contained in:
Carl-Erik Bergström
2024-09-05 15:28:56 +02:00
parent 50bedf65d1
commit c891b694c4
12 changed files with 289 additions and 56 deletions
@@ -17,15 +17,7 @@
import React from 'react';
import ShareIcon from '@material-ui/icons/Share';
import { DocsTableRow } from './types';
import { withStyles } from '@material-ui/core/styles';
import Star from '@material-ui/icons/Star';
import StarBorder from '@material-ui/icons/StarBorder';
const YellowStar = withStyles({
root: {
color: '#f3ba37',
},
})(Star);
import { FavoriteToggleIcon } from '@backstage/core-components';
/**
* Not directly exported, but through DocsTable.actions and EntityListDocsTable.actions
@@ -52,7 +44,7 @@ export const actionFactories = {
const isStarred = isStarredEntity(entity);
return {
cellStyle: { paddingLeft: '1em' },
icon: () => (isStarred ? <YellowStar /> : <StarBorder />),
icon: () => <FavoriteToggleIcon isFavorite={isStarred} />,
tooltip: isStarred ? 'Remove from favorites' : 'Add to favorites',
onClick: () => toggleStarredEntity(entity),
};