import {Fragment} from 'react'; import type {RouteComponentProps} from 'react-router'; import styled from '@emotion/styled'; import * as Layout from 'sentry/components/layouts/thirds'; import LoadingError from 'sentry/components/loadingError'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import NoProjectMessage from 'sentry/components/noProjectMessage'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {t} from 'sentry/locale'; import type {TeamWithProjects} from 'sentry/types/project'; import localStorage from 'sentry/utils/localStorage'; import useRouteAnalyticsEventNames from 'sentry/utils/routeAnalytics/useRouteAnalyticsEventNames'; import useOrganization from 'sentry/utils/useOrganization'; import {useUserTeams} from 'sentry/utils/useUserTeams'; import Header from '../header'; import TeamStatsControls from './controls'; import DescriptionCard from './descriptionCard'; import TeamAlertsTriggered from './teamAlertsTriggered'; import TeamMisery from './teamMisery'; import TeamReleases from './teamReleases'; import TeamStability from './teamStability'; import {dataDatetime} from './utils'; type Props = RouteComponentProps<{}, {}>; function TeamStatsHealth({location, router}: Props) { const organization = useOrganization(); const {teams, isLoading, isError} = useUserTeams(); useRouteAnalyticsEventNames('team_insights.viewed', 'Team Insights: Viewed'); const query = location?.query ?? {}; const localStorageKey = `teamInsightsSelectedTeamId:${organization.slug}`; let localTeamId: string | null | undefined = query.team ?? localStorage.getItem(localStorageKey); if (localTeamId && !teams.find(team => team.id === localTeamId)) { localTeamId = null; } const currentTeamId = localTeamId ?? teams[0]?.id; const currentTeam = teams.find(team => team.id === currentTeamId) as | TeamWithProjects | undefined; const projects = currentTeam?.projects ?? []; const {period, start, end, utc} = dataDatetime(query); if (teams.length === 0) { return ( ); } if (isError) { return ; } return (
{isLoading && } {!isLoading && ( )} ); } export default TeamStatsHealth; const Body = styled(Layout.Body)` @media (min-width: ${p => p.theme.breakpoints.medium}) { display: block; } `;