Skip to content
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: hook up project resources API to resources widget #8657

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { Link } from 'react-router-dom';
import ApiKeyIcon from '@mui/icons-material/Key';
import SegmentsIcon from '@mui/icons-material/DonutLarge';
import ConnectedIcon from '@mui/icons-material/Cable';
import { useProjectStatus } from 'hooks/api/getters/useProjectStatus/useProjectStatus';
import useLoading from 'hooks/useLoading';

const Wrapper = styled('article')(({ theme }) => ({
backgroundColor: theme.palette.envAccordion.expanded,
Expand Down Expand Up @@ -88,18 +90,19 @@ const ListItem: FC<
<ListItemRow>
<ItemContent>
{icon}
<span>{children}</span>
<span data-loading-resources>{children}</span>
</ItemContent>
<Link to={linkUrl}>{linkText}</Link>
</ListItemRow>
);

export const ProjectResources = () => {
const projectId = useRequiredPathParam('projectId');
const { project, loading: loadingProject } = useProjectOverview(projectId);
const { tokens, loading: loadingTokens } = useProjectApiTokens(projectId);
const { segments, loading: loadingSegments } = useSegments();
// todo: add sdk connections
const { project } = useProjectOverview(projectId);
const { tokens } = useProjectApiTokens(projectId);
const { segments } = useSegments();
const { data: projectStatus, loading: loadingResources } =
useProjectStatus(projectId);

const segmentCount = useMemo(
() =>
Expand All @@ -108,8 +111,10 @@ export const ProjectResources = () => {
[segments, projectId],
);

const loadingStatusRef = useLoading(true, '[data-loading-resources=true]');

return (
<Wrapper>
<Wrapper ref={loadingStatusRef}>
<ProjectResourcesInner>
<Typography variant='h3' sx={{ margin: 0 }}>
Project Resources
Expand All @@ -136,7 +141,8 @@ export const ProjectResources = () => {
linkText='View connections'
icon={<ConnectedIcon />}
>
1 connected environment(s)
{projectStatus?.resources?.connectedEnvironments}{' '}
connected environment(s)
</ListItem>

<ListItem
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/openapi/models/projectStatusSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ import type { ProjectActivitySchema } from './projectActivitySchema';
export interface ProjectStatusSchema {
/** Array of activity records with date and count, representing the project’s daily activity statistics. */
activityCountByDate: ProjectActivitySchema;

/** Key resources within the project */
resources: {
/** Handwritten placeholder */
connectedEnvironments: number;
};
}
1 change: 1 addition & 0 deletions src/lib/openapi/spec/project-status-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const projectStatusSchema = {
properties: {
connectedEnvironments: {
type: 'number',
minimum: 0,
description:
'The number of environments that have received SDK traffic in this project.',
},
Expand Down
Loading