Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Item Usage Check Before Deletion in Item Management System #679

Conversation

bartlomiejmarszal
Copy link
Contributor

PR Description

Overview

This pull request introduces enhancements to the item management functionality by integrating a new service to check item usage before deletion. The changes ensure that items currently in use within tests cannot be deleted, thereby preventing potential disruptions in test configurations.

Key Changes

  1. Item Usage Check in Deletion Process:

    • Updated actions/class.Items.php to include a check using ItemUsageService before allowing an item to be deleted. If an item is in use, an error is thrown, and the deletion is halted.
  2. Introduction of ItemUsageService:

    • Added a new class ItemUsageService in models/classes/search/ItemUsageService.php. This service utilizes SearchProxy to determine if an item is currently used in any tests and retrieves associated test labels.
  3. Service Provider for Item Usage:

    • Created SearchServiceProvider in models/classes/search/SearchServiceProvider.php to register ItemUsageService with the dependency injection container, ensuring it is available for use across the application.
  4. Manifest Update:

    • Updated manifest.php to include the new SearchServiceProvider, ensuring the new service is properly registered and available.
  5. Integration in Item Service:

    • Modified models/classes/class.ItemsService.php to incorporate the usage check within the item deletion logic, enhancing the robustness of the item management process.

Benefits

  • Prevents Unintended Deletions: By checking item usage before deletion, the system prevents accidental removal of items that are integral to active tests.
  • Improved System Integrity: Ensures that test configurations remain intact and reliable by safeguarding against the deletion of in-use items.
  • Enhanced Maintainability: The introduction of ItemUsageService centralizes the logic for checking item usage, making it easier to maintain and extend in the future.

Conclusion

These changes significantly enhance the reliability and integrity of the item management system by ensuring that items cannot be deleted if they are currently in use within tests. This update is crucial for maintaining consistent and error-free test environments.

…gister SearchServiceProvider for dependency injection.
Copy link

github-actions bot commented Jan 29, 2025

Front-end summary Node 18

💯 Total ✅ Passed ⏭️ Skipped ❌ Failed
29 29 0 0

*/
public function isItemUsed(array $itemUris): bool
{
return $this->searchProxy->searchBoolQuery('item_uris', $itemUris, 1)->getTotalCount() > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to use one of existing searchProxy methods?

Copy link

Version

Target Version 12.7.0
Last version 12.6.3

There are 0 BREAKING CHANGE, 1 feature, 2 fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants