Skip to content

Commit

Permalink
Update collections deletion so that when deleting a collection entire…
Browse files Browse the repository at this point in the history
…ly, or just a single version, it navigates tot he collections list after deletion.
  • Loading branch information
AlexSCorey committed Aug 21, 2024
1 parent 2cf336f commit 7daa59f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
6 changes: 3 additions & 3 deletions frontend/hub/collections/hooks/useDeleteCollections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useHubBulkConfirmation } from '../../common/useHubBulkConfirmation';
import { PulpItemsResponse } from '../../common/useHubView';
import { CollectionVersionSearch } from '../Collection';
import { useCollectionColumns } from './useCollectionColumns';
import { navigateAfterDelete } from './useDeleteCollectionsFromRepository';
import { HubRoute } from '../../main/HubRoutes';

export function useDeleteCollections(
onComplete?: (collections: CollectionVersionSearch[]) => void,
Expand All @@ -33,7 +33,7 @@ export function useDeleteCollections(

confirmText +=
' ' +
t(`Note that if you selected one collection in multiple repositories, it will be
t(`Note that if you selected one collection in multiple repositories, it will be
deleted only once from all repositories.`);

const title = version
Expand Down Expand Up @@ -69,7 +69,7 @@ export function useDeleteCollections(
actionFn: (collection: CollectionVersionSearch, signal) => {
return deleteCollection(collection, version, signal).then(() => {
if (detail) {
return navigateAfterDelete(collection, version || false, navigate);
navigate(HubRoute.Collections);
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function useDeleteCollectionsFromRepository(
return deleteCollectionFromRepository(newRepository, [collection], version, t).then(
() => {
if (detail) {
return navigateAfterDelete(collection, version || false, navigate);
navigate(HubRoute.Collections);
}
}
);
Expand Down Expand Up @@ -174,22 +174,3 @@ export async function deleteCollectionFromRepository(
);
}
}

export function navigateAfterDelete(
collection: CollectionVersionSearch,
version: boolean,
navigate: ReturnType<typeof usePageNavigate>
) {
if (version) {
navigate(HubRoute.CollectionPage, {
query: {
repository: collection.repository?.name || '',
name: collection.collection_version?.name || '',
namespace: collection.collection_version?.namespace || '',
redirectIfEmpty: 'true',
},
});
} else {
navigate(HubRoute.Collections);
}
}

0 comments on commit 7daa59f

Please sign in to comment.