-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: application usage frontend #4561
Conversation
sjaanus
commented
Aug 24, 2023
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
not connected | ||
</Typography> | ||
</TextCell> | ||
Cell: ({ row: { original } }: any) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we write explicit type here to avoid guessing/runtime inspection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type
const theme = useTheme(); | ||
const formattedProjects: (React.JSX.Element | string)[] = []; | ||
|
||
usage.forEach((p, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forEach is usually map/flatMap/filter in disguise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sth like this
const formatProject = (projectInfo, index) => {
const separator = index !== 0 ? ', ' : '';
const projectElement = projectInfo.project !== '*'
? <StyledLink to={`/projects/${projectInfo.project}`}>{projectInfo.project}</StyledLink>
: projectInfo.project;
const environments = ` (${projectInfo.environments.join(', ')})`;
return [separator, projectElement, environments];
};
export const ApplicationUsageCell = ({ usage }: IApplicationUsageCellProps) => {
const theme = useTheme();
// Using map to generate the formattedProjects array
const formattedProjects = usage.flatMap((p, index) => formatProject(p, index));
return (
<TextCell>
{usage.length > 0 ? (
<Typography variant="body2">{formattedProjects}</Typography>
) : (
<Typography variant="body2" color={theme.palette.text.secondary}>
not connected
</Typography>
)}
</TextCell>
);
};