Skip to content

Commit

Permalink
chore: patch 4.22.7 (#3618)
Browse files Browse the repository at this point in the history
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
  • Loading branch information
andreas-unleash and Tymek committed Apr 25, 2023
1 parent 256f888 commit 90036a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -5,6 +5,7 @@ import Input from 'component/common/Input/Input';
import { formatUnknownError } from 'utils/formatUnknownError';
import useToast from 'hooks/useToast';
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

interface IArchivedFeatureDeleteConfirmProps {
deletedFeatures: string[];
Expand Down Expand Up @@ -34,14 +35,21 @@ export const ArchivedFeatureDeleteConfirm = ({
}: IArchivedFeatureDeleteConfirmProps) => {
const [confirmName, setConfirmName] = useState('');
const { setToastData, setToastApiError } = useToast();
const { deleteFeatures } = useProjectApi();
const { deleteFeature, deleteFeatures } = useProjectApi();
const { uiConfig } = useUiConfig();

const onDeleteFeatureToggle = async () => {
try {
if (deletedFeatures.length === 0) {
return;
}
await deleteFeatures(projectId, deletedFeatures);

if (uiConfig?.flags?.bulkOperations) {
await deleteFeatures(projectId, deletedFeatures);
} else {
await deleteFeature(deletedFeatures[0]);
}

await refetch();
setToastData({
type: 'success',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/hooks/api/actions/useProjectApi/useProjectApi.ts
Expand Up @@ -223,6 +223,15 @@ const useProjectApi = () => {
return makeRequest(req.caller, req.id);
};

const deleteFeature = async (featureId: string) => {
const path = `api/admin/archive/${featureId}`;
const req = createRequest(path, {
method: 'DELETE',
});

return makeRequest(req.caller, req.id);
};

const deleteFeatures = async (projectId: string, featureIds: string[]) => {
const path = `api/admin/projects/${projectId}/delete`;
const req = createRequest(path, {
Expand Down Expand Up @@ -267,6 +276,7 @@ const useProjectApi = () => {
archiveFeatures,
reviveFeatures,
staleFeatures,
deleteFeature,
deleteFeatures,
searchProjectUser,
errors,
Expand Down

0 comments on commit 90036a4

Please sign in to comment.