Create two UI elements (preferably radio buttons) which allow to select between “by query” and “by instance”.
Display a Tooltip, which describes the difference between both selection types, when hovering over the elements.
Select the “by instance” option, by default, to prevent the user from performing the batch operation on all instances that match the query.
Change the instance table view, depending on the selected mode:
By query:
No instance checkboxes are shown.
By instance:
Instance checkboxes are shown.
Unselect all instances displayed in the table, by default.
Disable the button to get to the next step by default.
Enable button if at least one instance is selected.
If the “select all” checkbox is checked, show an info (blue color) notification displaying the amount of the selected instances on the current page and a link to select all instances that match the query, independent of the current page.
Show the info notification only if pages are > 1.
If this link is clicked, change the selection type to “by query”.
Display an info notification with a warning that continuing leads to creating a batch operation that affects all instances and a link to unselect all again.
Show this info notification when selecting "by query" and regardless of whether "select all" is checked.
If this link is clicked, change the selection type back to “by instance”.