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:
@@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user