feat: add ifNotHaveType option to hide products when a type exists
Summary
Fixes #12692
Adds ifNotHaveType product configuration option - the inverse of ifHaveType. This allows products to be hidden when a specific type IS found, enabling products to be shown only on downstream clusters by specifying a local-cluster-only type.
Occurred changes and/or fixed issues
- Added
ifNotHaveTypeto DSL product function with regex conversion support - Added filtering logic in
activeProductsgetter to hide products when matching type exists - Added TypeScript type definition for the new option
Technical notes summary
-
ifNotHaveTypeuses the same string/regex pattern matching asifHaveType - Evaluated after
ifHaveTypein theactiveProductsfilter chain - Uses the product's
inStoreto determine which store to check for the type
Example usage:
product({
name: 'downstream-only-product',
ifNotHaveType: 'management.cattle.io.some-local-type',
// Shows only when the specified type is NOT present
});
Areas or cases that should be tested
- Product visibility with
ifNotHaveTypeset to existing type (should hide) - Product visibility with
ifNotHaveTypeset to non-existing type (should show) - Regex patterns in
ifNotHaveType - Combined
ifHaveTypeandifNotHaveTypeusage - Browser: Chrome
Areas which could experience regressions
- Product filtering in navigation
- Any existing products using type-based visibility conditions
Screenshot/Video
N/A - No UI changes, backend configuration option only
Checklist
- [x] The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
- [x] The PR has a Milestone
- [x] The PR template has been filled out
- [x] The PR has been self reviewed
- [x] The PR has a reviewer assigned
- [x] The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
- [x] The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
- [x] The PR has been reviewed in terms of Accessibility
- [x] The PR has considered, and if applicable tested with, the three Global Roles
Admin,Standard UserandUser Base
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
download.cypress.io
- Triggering command:
/usr/local/bin/node /usr/local/bin/node index.js --exec install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Add a way to hide products in the local cluster</issue_title> <issue_description>Is your feature request related to a problem? Please describe. Product config can specify that a product should be shown only if the current cluster is the local cluster (usually that means the product is in the local cluster's cluster explorer but not necessarily). We also need to be able to do the opposite and only show products in downstream clusters.
Describe the solution you'd like Currently products can use
ifHaveTypemechanism to specify that a product should be hidden if a certain type is not found. We should also support the opposite of this: product configuration should be able to specify that the product should be hidden if a certain type is found.Describe alternatives you've considered
Additional context Needed for https://github.com/rancher/virtual-clusters-ui/issues/55</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes rancher/dashboard#15842
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.