-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: flag exposure in personal dashboard (#8247)
- Loading branch information
Showing
5 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FlagExposure.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { type FC, useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; | ||
import type { ILastSeenEnvironments } from 'interfaces/featureToggle'; | ||
import { Box } from '@mui/material'; | ||
import { FeatureEnvironmentSeen } from '../../FeatureEnvironmentSeen/FeatureEnvironmentSeen'; | ||
import { FeatureLifecycle } from './FeatureLifecycle'; | ||
import { FeatureArchiveNotAllowedDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveNotAllowedDialog'; | ||
import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveDialog'; | ||
import { MarkCompletedDialogue } from './MarkCompletedDialogue'; | ||
|
||
export const FlagExposure: FC<{ | ||
project: string; | ||
flagName: string; | ||
onArchive: () => void; | ||
}> = ({ project, flagName, onArchive }) => { | ||
const navigate = useNavigate(); | ||
const { feature, refetchFeature } = useFeature(project, flagName); | ||
const lastSeenEnvironments: ILastSeenEnvironments[] = | ||
feature.environments?.map((env) => ({ | ||
name: env.name, | ||
lastSeenAt: env.lastSeenAt, | ||
enabled: env.enabled, | ||
yes: env.yes, | ||
no: env.no, | ||
})); | ||
const [showDelDialog, setShowDelDialog] = useState(false); | ||
const [showMarkCompletedDialogue, setShowMarkCompletedDialogue] = | ||
useState(false); | ||
|
||
return ( | ||
<Box sx={{ display: 'flex' }}> | ||
<FeatureEnvironmentSeen | ||
featureLastSeen={feature.lastSeenAt} | ||
environments={lastSeenEnvironments} | ||
/> | ||
<FeatureLifecycle | ||
feature={feature} | ||
onArchive={() => setShowDelDialog(true)} | ||
onComplete={() => setShowMarkCompletedDialogue(true)} | ||
onUncomplete={refetchFeature} | ||
/> | ||
|
||
{feature.children.length > 0 ? ( | ||
<FeatureArchiveNotAllowedDialog | ||
features={feature.children} | ||
project={project} | ||
isOpen={showDelDialog} | ||
onClose={() => setShowDelDialog(false)} | ||
/> | ||
) : ( | ||
<FeatureArchiveDialog | ||
isOpen={showDelDialog} | ||
onConfirm={onArchive} | ||
onClose={() => setShowDelDialog(false)} | ||
projectId={project} | ||
featureIds={[flagName]} | ||
/> | ||
)} | ||
|
||
{feature.project ? ( | ||
<MarkCompletedDialogue | ||
isOpen={showMarkCompletedDialogue} | ||
setIsOpen={setShowMarkCompletedDialogue} | ||
projectId={feature.project} | ||
featureId={feature.name} | ||
onComplete={refetchFeature} | ||
/> | ||
) : null} | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters