feat: New confirmation modal when deleting library components (#1906)

* feat: New units message on delete confirm modal when deleting components
* test: Tests for new delete confirmation messages
* refactor: useComponentsFromSearchIndex added
* refactor: Move fetch units to ComponentDeleter
* style: Delete unnecessary code
This commit is contained in:
Chris Chávez
2025-05-21 12:04:19 -05:00
committed by GitHub
parent e212e1a1ef
commit 0e40aa295d
8 changed files with 146 additions and 24 deletions

View File

@@ -12,6 +12,7 @@ import { useCallback } from 'react';
import { getLibraryId } from '../../generic/key-utils';
import * as api from './api';
import { VersionSpec } from '../LibraryBlock';
import { useContentSearchConnection, useContentSearchResults } from '../../search-manager';
export const libraryQueryPredicate = (query: Query, libraryId: string): boolean => {
// Invalidate all content queries related to this library.
@@ -802,3 +803,19 @@ export const usePublishContainer = (containerId: string) => {
},
});
};
/**
* Use this mutations to get a list of components from the search index
*/
export const useComponentsFromSearchIndex = (componentIds: string[]) => {
const { client, indexName } = useContentSearchConnection();
return useContentSearchResults({
client,
indexName,
searchKeywords: '',
extraFilter: [`usage_key IN ["${componentIds.join('","')}"]`],
limit: componentIds.length,
enabled: !!componentIds.length,
skipBlockTypeFetch: true,
});
};