Skip to content

Commit

Permalink
feat: prevent revive feature to archived project
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Aug 20, 2024
1 parent 0d97f8b commit e467fbe
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formatUnknownError } from 'utils/formatUnknownError';
import useToast from 'hooks/useToast';
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useProjectOverview from '../../../../../hooks/api/getters/useProjectOverview/useProjectOverview';

interface IArchivedFeatureReviveConfirmProps {
revivedFeatures: string[];
Expand All @@ -27,6 +28,7 @@ export const ArchivedFeatureReviveConfirm = ({
}: IArchivedFeatureReviveConfirmProps) => {
const { setToastData, setToastApiError } = useToast();
const { reviveFeatures } = useProjectApi();
const { project, loading } = useProjectOverview(projectId);

const onReviveFeatureToggle = async () => {
try {
Expand Down Expand Up @@ -67,11 +69,23 @@ export const ArchivedFeatureReviveConfirm = ({
secondaryButtonText='Cancel'
onClick={onReviveFeatureToggle}
onClose={clearModal}
disabledPrimaryButton={loading || Boolean(project.archivedAt)}
>
<Alert severity='info'>
Revived feature flags will be automatically disabled in all
environments
</Alert>
<ConditionallyRender
condition={Boolean(project.archivedAt)}
show={
<Alert severity='warning'>
Cannot revive feature flag in archived project (Project
ID: {projectId})
</Alert>
}
elseShow={
<Alert severity='info'>
Revived feature flags will be automatically disabled in
all environments
</Alert>
}
/>

<ConditionallyRender
condition={revivedFeatures.length > 1}
Expand Down

0 comments on commit e467fbe

Please sign in to comment.