-export const ProjectDetailsCard = connect(mapStateToProps)(
- withStyles(styles)((props: DetailsCardProps & WithStyles<CssRules>) => {
- const { currentResource } = props;
- return (currentResource.kind as string) === ResourceKind.USER ? <UserCard props={props} /> : <ProjectCard props={props} />;
+type ProjectCardProps = WithStyles<CssRules> & {
+ currentResource: ProjectResource;
+ frozenByFullName: string | undefined;
+ isAdmin: boolean;
+ isSelected: boolean;
+ handleContextMenu: (event: React.MouseEvent<HTMLElement>, resource: ContextMenuResource, isAdmin: boolean) => void;
+ handleCardClick: (resource: any) => void;
+};
+
+export const ProjectDetailsCard = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(
+ withStyles(styles)((props: DetailsCardProps) => {
+ const { classes, currentResource, frozenByFullName, handleContextMenu, handleCardClick, isAdmin, isSelected } = props;
+ if (!currentResource) {
+ return null;
+ }
+ switch (currentResource.kind as string) {
+ case ResourceKind.USER:
+ return (
+ <UserCard
+ classes={classes}
+ currentResource={currentResource as UserResource}
+ isAdmin={isAdmin}
+ isSelected={isSelected}
+ handleContextMenu={(ev) => handleContextMenu(ev, currentResource as any, isAdmin)}
+ handleCardClick={handleCardClick}
+ />
+ );
+ case ResourceKind.PROJECT:
+ return (
+ <ProjectCard
+ classes={classes}
+ currentResource={currentResource as ProjectResource}
+ frozenByFullName={frozenByFullName}
+ isAdmin={isAdmin}
+ isSelected={isSelected}
+ handleContextMenu={(ev) => handleContextMenu(ev, currentResource as any, isAdmin)}
+ handleCardClick={handleCardClick}
+ />
+ );
+ default:
+ return null;
+ }