Component usage details in catalog resource view
### Summary A detailed view of a single CI component that shows exactly which projects use which versions, so you can target upgrades and notify the right maintainers when deprecating or fixing issues. ## Implementation Add a GraphQL API (`CiCatalogResource.componentUsages`) that shows which projects use components from a CI Catalog resource, including version and last used date information. This enables the Component Usage Details page in the catalog resource view. ### Scope - GraphQL `componentUsages` connection field on `CiCatalogResourceType` (EE) - `ProjectUsageType` and `ComponentUsageDetailType` GraphQL types - Resolver with authorization (maintainer+ on catalog resource project), license check, and `ci_component_analytics` feature flag - `outdated` field indicating if a project uses a version older than the latest - Model scope for fetching usages with eager-loaded associations ### Authorization - Only catalog resource project maintainers+ can access this data - Only projects visible to the current user are returned - Gated behind `ci_component_analytics` feature flag and Ultimate license ### Merge Requests - !222665 — Add semver fields to `CiCatalogResourceVersion` (merged) - !224045 — Add `for_catalog_resource_with_component_versions` scope (merged) - !226460 — Add `componentUsages` GraphQL types, feature flag, and connection type (in review) - !222663 — Add `componentUsages` resolver, integration spec, and N+1 test (in progress, depends on !226460) ### Note on version tracking The `last_usages` table stores a `component_id` which points to a component record tied to a specific version via `version_id`. Each published version creates new component records, so `usage.component.version` correctly returns the version that was actually used, not the latest version. <details> <summary>Original issue description</summary> Provide a detailed view on the components and components projects usage For each component projects (Catalog item) users can see 1. Used version per each component 2. Projects URL 3. The view will be organized by version, where the older version at the top 4. Separation between projects that are using latest versions vs older versions 5. Notify project maintainer is the ability to ping project maintainers to make sure they are aware when a new verison is available (could be out of scope for this MVC) ### **Implementation Details** #### **Version Tracking in LastUsage Table** - 5+ Version tracking - `30 are on v1.0.2, 15 on v1.5.1, 5 on v2.0`.0 **Note:** The `last_usages table` doesn't store which version was used and the gql version field currently resolves from the component's CURRENT version_id, not the version that was actually included. Additional notes: - Add `version_id` column to `catalog_resource_component_last_usages table` - Update `Ci::Components::Usages::CreateService` with this :question: **QUESTION -** are we going to backfill? I assume so #### **Query for projects using component - 4 (performance)** Usage tracking - like `Component X is used by these 50 projects` Currently we have `Project.componentUsages` but NOT `Component.usedByProjects` or `CatalogResource.projectUsages` _\<- made these up as a suggestion_ - Add new field to `ComponentType` or `CatalogResourceType` and create new resolver - Permissions: I think we can reuse existing logic from `ProjectUsageResolver` here #### **Projects with outdated versions - 2** Figure out which projects are using outdated versions - `These 30 projects need to upgrade` - We probably need some work to separate "up-to-date" projects from "outdated" projects :thinking: but we already have a boolean **Authorization restrictions** Persons - * Who can view this project? only components project maintainer+ (in this view, only `components/docker` maintainer+) * This view should not be accessible for developer- * The maintainer can only see the projects that are visible for their role (e.g. if I am a component project maintainer but a private project is using my components I wont be able to see it in this view ![image](/uploads/f84c8a3523344dc4a12c54f3e4e99c66/image.png){width="631" height="687"} Open question? Can we make sure this view works across all deployment types (Self managed, Dedicated, .com) </details>
issue