Skip to content

Commit

Permalink
--wip--
Browse files Browse the repository at this point in the history
  • Loading branch information
e-for-eshaan committed May 20, 2024
1 parent e4a3f17 commit 17a3259
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions web-server/src/content/DoraMetrics/DoraMetricsBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Grid, Divider, Button } from '@mui/material';
import Link from 'next/link';
import { useEffect } from 'react';
import { useEffect, useMemo } from 'react';

import { DoraMetricsConfigurationSettings } from '@/components/DoraMetricsConfigurationSettings';
import { DoraScore } from '@/components/DoraScore';
Expand Down Expand Up @@ -89,7 +89,20 @@ export const DoraMetricsBody = () => {

const stats = useDoraStats();

const repoBookmarks = useSelector((s) => s.doraMetrics.repo_bookmarks);
const teamRepos = useSelector((s) => s.team.teamReposMaps[singleTeamId]);
const { isFreshOrg } = useFreshOrgCalculator();
const isSyncing = useMemo(() => {
if (isFreshOrg) return true;
const syncedRepos = repoBookmarks.map((item) => item.repo_id);
const teamRepoIds = teamRepos?.map((repo) => repo.id) || [];
console.log('Debugging', {
syncedRepos,
teamRepoIds
});
if (teamRepoIds.every((id) => syncedRepos.includes(id))) return false;
return true;
}, [isFreshOrg, repoBookmarks, teamRepos]);

if (isErrored)
return (
Expand All @@ -99,32 +112,31 @@ export const DoraMetricsBody = () => {
/>
);
if (!firstLoadDone) return <MiniLoader label={getRandomLoadMsg()} />;
if (isTeamInsightsEmpty)
if (isFreshOrg)
return (
<EmptyState
type="SYNC_IN_PROGRESS"
title="Sync in progress"
desc="Your data is syncing. Please reload in a few minutes."
>
<FixedContentRefreshLoader show={isLoading} />
</EmptyState>
);
else
return (
<EmptyState
type="NO_DATA_IN_DORA_METRICS"
title="Dora's not exploring today"
desc="We couldn't find any data to present. Perhaps you need to configure team repos."
>
<Link passHref href={ROUTES.TEAMS.PATH}>
<Button variant="contained" size="small">
Check Team Repos
</Button>
</Link>
<FixedContentRefreshLoader show={isLoading} />
</EmptyState>
);
if (isSyncing)
return (
<EmptyState
type="SYNC_IN_PROGRESS"
title="Sync in progress"
desc="Your data is syncing. Please reload in a few minutes."
>
<FixedContentRefreshLoader show={isLoading} />
</EmptyState>
);
else if (isTeamInsightsEmpty)
return (
<EmptyState
type="NO_DATA_IN_DORA_METRICS"
title="Dora's not exploring today"
desc="We couldn't find any data to present. Perhaps you need to configure team repos."
>
<Link passHref href={ROUTES.TEAMS.PATH}>
<Button variant="contained" size="small">
Check Team Repos
</Button>
</Link>
<FixedContentRefreshLoader show={isLoading} />
</EmptyState>
);

return (
<FlexBox col gap2>
Expand Down

0 comments on commit 17a3259

Please sign in to comment.