1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
unleash.unleash/frontend/src/component/feature/FeatureView/FeatureNotFound/FeatureNotFound.tsx
Nuno Góis 0429c1985a
refactor: remove deprecated get archive featured by project endpoint (#9938)
https://linear.app/unleash/issue/2-3367/remove-get-apiadminarchivefeaturesprojectid-deprecated-in-4110

Removes GET `/api/admin/archive/features/{projectId}` which was
deprecated in v4.11.
Also cleans up related code.

I leveraged our search features endpoint where needed, since that's what
we're using now in our UI (to see archived features you filter by
archived=true).

Builds on top of https://github.com/Unleash/unleash/pull/9924 — Since
they're both related.
2025-05-13 12:09:52 +01:00

52 lines
1.6 KiB
TypeScript

import { Link } from 'react-router-dom';
import { getCreateTogglePath } from 'utils/routePathHelpers';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { styled } from '@mui/material';
import { useFeatureSearch } from 'hooks/api/getters/useFeatureSearch/useFeatureSearch';
const StyledFeatureId = styled('strong')({
wordBreak: 'break-all',
});
export const FeatureNotFound = () => {
const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId');
const { features: archivedFeatures } = useFeatureSearch({
project: `IS:${projectId}`,
archived: 'IS:true',
});
const createFeatureTogglePath = getCreateTogglePath(projectId, {
name: featureId,
});
if (!archivedFeatures) {
return null;
}
const isArchived = archivedFeatures.some((archivedFeature) => {
return archivedFeature.name === featureId;
});
if (isArchived) {
return (
<p>
The feature <StyledFeatureId>{featureId}</StyledFeatureId> has
been archived. You can find it on the{' '}
<Link to={`/projects/${projectId}?archived=IS%3Atrue`}>
project overview with archived flags filter
</Link>
.
</p>
);
}
return (
<p>
The feature <StyledFeatureId>{featureId}</StyledFeatureId> does not
exist. Would you like to{' '}
<Link to={createFeatureTogglePath}>create it</Link>?
</p>
);
};