import { type FC, useEffect, useRef } from 'react'; import { ContentGridContainer, FlagGrid, ListItemBox, SpacedGridItem, StyledCardTitle, StyledList, listItemStyle, } from './SharedComponents'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { getFeatureTypeIcons } from 'utils/getFeatureTypeIcons'; import { Alert, IconButton, Link, ListItem, ListItemButton, Typography, styled, } from '@mui/material'; import LinkIcon from '@mui/icons-material/ArrowForward'; import React from 'react'; import type { PersonalDashboardSchemaFlagsItem } from 'openapi'; const NoActiveFlagsInfo = styled('div')(({ theme }) => ({ display: 'flex', flexFlow: 'column', gap: theme.spacing(2), })); const FlagListItem: FC<{ flag: { name: string; project: string; type: string }; selected: boolean; onClick: () => void; }> = ({ flag, selected, onClick }) => { const activeFlagRef = useRef(null); const { trackEvent } = usePlausibleTracker(); useEffect(() => { if (activeFlagRef.current) { activeFlagRef.current.scrollIntoView({ block: 'start', inline: 'start', }); window.scrollTo({ top: 0 }); } }, []); const IconComponent = getFeatureTypeIcons(flag.type); const flagLink = `projects/${flag.project}/features/${flag.name}`; return ( {flag.name} { trackEvent('personal-dashboard', { props: { eventType: `Go to flag from list`, }, }); }} size='small' sx={{ ml: 'auto' }} > ); }; type FlagData = | { state: 'flags'; flags: PersonalDashboardSchemaFlagsItem[]; activeFlag?: PersonalDashboardSchemaFlagsItem; } | { state: 'no flags'; }; type Props = { hasProjects: boolean; flagData: FlagData; setActiveFlag: (flag: PersonalDashboardSchemaFlagsItem) => void; refetchDashboard: () => void; }; export const MyFlags: FC = ({ hasProjects, flagData, setActiveFlag, refetchDashboard, }) => { return ( {flagData.state === 'flags' ? ( {flagData.flags.map((flag) => ( setActiveFlag(flag)} /> ))} ) : hasProjects ? ( You have not created or favorited any feature flags. Once you do, they will show up here. To create a new flag, go to one of your projects. ) : ( You need to create or join a project to be able to add a flag, or you must be given the rights by your admin to add feature flags. )} {flagData.state === 'flags' && flagData.activeFlag ? ( ) : ( )} ); }; const FlagMetricsChart = React.lazy(() => import('./FlagMetricsChart').then((module) => ({ default: module.FlagMetricsChart, })), ); const PlaceholderFlagMetricsChart = React.lazy(() => import('./FlagMetricsChart').then((module) => ({ default: module.PlaceholderFlagMetricsChartWithWrapper, })), );