diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 92bfc4de96..9d30d84bb2 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -254,6 +254,17 @@ export class EntityOwnerFilter implements EntityFilter { // @public (undocumented) export const EntityOwnerPicker: () => JSX.Element | null; +// @public +export const EntityPeekAheadPopover: ({ + entityRef, + children, +}: EntityPeekAheadPopoverProps) => JSX.Element; + +// @public +export type EntityPeekAheadPopoverProps = PropsWithChildren<{ + entityRef: CompoundEntityRef; +}>; + // @public (undocumented) export const EntityProcessingStatusPicker: () => JSX.Element; diff --git a/plugins/catalog-react/src/components/EntityPeekAheadPopover/EntityPeekAheadPopover.tsx b/plugins/catalog-react/src/components/EntityPeekAheadPopover/EntityPeekAheadPopover.tsx index d50525151e..bd41dd5b92 100644 --- a/plugins/catalog-react/src/components/EntityPeekAheadPopover/EntityPeekAheadPopover.tsx +++ b/plugins/catalog-react/src/components/EntityPeekAheadPopover/EntityPeekAheadPopover.tsx @@ -42,12 +42,20 @@ import { CompoundEntityRef, isUserEntity, isGroupEntity, + UserEntity, + GroupEntity, + Entity, } from '@backstage/catalog-model'; import { Link, Progress } from '@backstage/core-components'; -export type EntityPeekAheadPopoverProps = { +/** + * Properties for an entity popover on hover of a component. + * + * @public + */ +export type EntityPeekAheadPopoverProps = PropsWithChildren<{ entityRef: CompoundEntityRef; -}; +}>; const useStyles = makeStyles(() => { return { @@ -66,11 +74,71 @@ const useStyles = makeStyles(() => { const maxTagChips = 4; +const EmailCardAction = ({ email }: { email: string }) => { + return ( + + + + ); +}; + +const UserCardActions = ({ entity }: { entity: UserEntity }) => { + return ( + <> + {entity.spec.profile?.email && ( + + )} + + ); +}; + +const GroupCardActions = ({ entity }: { entity: GroupEntity }) => { + return ( + <> + {entity.spec.profile?.email && ( + + )} + + ); +}; + +/** + * Shows an entity popover on hover of a component. + * + * @public + */ +const EntityCardActions = ({ entity }: { entity: Entity }) => { + const entityRoute = useRouteRef(entityRouteRef); + + return ( + <> + + + + + + + ); +}; + +/** + * Shows an entity popover on hover of a component. + * + * @public + */ export const EntityPeekAheadPopover = ({ entityRef, children, -}: PropsWithChildren) => { - const entityRoute = useRouteRef(entityRouteRef); +}: EntityPeekAheadPopoverProps) => { const classes = useStyles(); const apiHolder = useApiHolder(); const popupState = usePopupState({ @@ -154,24 +222,13 @@ export const EntityPeekAheadPopover = ({ )} - {entity && - (isUserEntity(entity) || isGroupEntity(entity)) && - entity.spec.profile?.email && ( - - - - )} - - - - - + {entity && ( + <> + {isUserEntity(entity) && } + {isGroupEntity(entity) && } + + + )} diff --git a/plugins/catalog-react/src/components/EntityPeekAheadPopover/index.ts b/plugins/catalog-react/src/components/EntityPeekAheadPopover/index.ts index 476767931f..6630f6f555 100644 --- a/plugins/catalog-react/src/components/EntityPeekAheadPopover/index.ts +++ b/plugins/catalog-react/src/components/EntityPeekAheadPopover/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { EntityPeekAheadPopover } from './EntityPeekAheadPopover'; +export * from './EntityPeekAheadPopover';