Skip to content

Enable cross-team views with shared team scopes - #607

Closed
thokra-nav wants to merge 1 commit into
mainfrom
team_filter
Closed

thokra-nav wants to merge 1 commit into
mainfrom
team_filter

Conversation

@thokra-nav

@thokra-nav thokra-nav commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Apply team selection before pagination so totals, facets, and vulnerability drill-downs stay consistent.

This supersede #594 in the case we choose to merge it

Apply team selection before pagination so totals, facets, and vulnerability drill-downs stay consistent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The activityLog filter type change breaks existing GraphQL operations, while environment-mapping and team-facet errors can reject matching workloads or null the facets field.

3 open issues
9 files not reviewed
  • internal/activitylog/activitylogsql/activitylog.sql.go: Generated file
  • internal/graph/gengql/activitylog.generated.go: Generated file
  • internal/graph/gengql/complexity.go: Generated file
  • internal/graph/gengql/issues.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
  • internal/graph/gengql/search.generated.go: Generated file
  • internal/graph/gengql/teams.generated.go: Generated file
  • internal/graph/gengql/vulnerability.generated.go: Generated file
  • internal/issue/issuesql/issue.sql.go: Generated file
What changed in this PR

Introduces shared team selection across Nais API to support cross-team views, extending the membership-filtering approach described in #594. Selection is applied before pagination so totals, facets, and vulnerability drill-downs use consistent scopes.

Changes:

  • Adds TeamScopeInput with explicit-team and viewer-membership filters across teams, search, issues, activity logs, and vulnerabilities.
  • Adds tenant-wide issue queries, team facets, scoped vulnerability aggregates, and inherited CVE workload scopes.
  • Updates generated bindings and adds unit and integration coverage for intersections, empty selections, and pagination.
File Description
internal/​vulnerability/​queries.go Applies team and environment scopes to summaries and CVE workloads.
internal/​vulnerability/​queries_test.go Tests scoped summaries and CVE lists.
internal/​vulnerability/​models.go Adds scope fields and inherited CVE team selection.
internal/​vulnerability/​fake/​v13s.go Filters fake summaries by team and environment.
internal/​vulnerability/​fake/​v13s_test.go Tests fake summary scope consistency.
internal/​vulnerability/​cve_workloads_test.go Tests inherited and intersected workload scopes.
internal/​team/​teamscope/​scope.go Implements shared team-selection resolution.
internal/​team/​teamscope/​scope_test.go Tests membership, identity, and empty-selection behavior.
internal/​team/​queries.go Applies team selection before sorting and pagination.
internal/​team/​model.go Adds shared scope to team filters.
internal/​search/​models.go Adds shared scope to search filters.
internal/​search/​bleve.go Applies scope intersections before search pagination.
internal/​search/​bleve_test.go Tests scoped search results and totals.
internal/​issue/​queries/​issue.sql Supports tenant-wide issue selection and team facet grouping.
internal/​issue/​queries.go Adds tenant queries and empty-page total recovery.
internal/​issue/​model.go Adds tenant filters and team facet models.
internal/​issue/​issuesql/​issue.sql.go Updates generated issue SQL bindings.
internal/​issue/​facets.go Builds scoped, ranked team facets.
internal/​issue/​facets_test.go Tests team facet aggregation and limits.
internal/​graph/​vulnerability.resolvers.go Passes scopes through vulnerability resolvers.
internal/​graph/​vulnerability.resolvers_test.go Tests scope inheritance and count-only behavior.
internal/​graph/​schema/​vulnerability.graphqls Exposes scopes and deprecates legacy team filtering.
internal/​graph/​schema/​teams.graphqls Defines and documents shared team selection.
internal/​graph/​schema/​search.graphqls Exposes shared scope and deprecates legacy teams input.
internal/​graph/​schema/​issues.graphqls Adds tenant issue queries and team facets.
internal/​graph/​schema/​activitylog.graphqls Introduces the tenant activity-log filter type.
internal/​graph/​issues.resolvers.go Resolves tenant issues and facet teams.
internal/​graph/​gengql/​vulnerability.generated.go Updates vulnerability filter decoding.
internal/​graph/​gengql/​teams.generated.go Adds shared scope decoding.
internal/​graph/​gengql/​search.generated.go Updates search filter decoding.
internal/​graph/​gengql/​schema.generated.go Updates query interfaces and execution bindings.
internal/​graph/​gengql/​root_.generated.go Updates embedded schemas and resolver registration.
internal/​graph/​gengql/​issues.generated.go Adds tenant issue and team facet bindings.
internal/​graph/​gengql/​complexity.go Accounts for tenant issue query complexity.
internal/​graph/​gengql/​activitylog.generated.go Adds tenant activity-log filter decoding.
internal/​graph/​filter_scope_test.go Tests tenant and resource-scoped filter contracts.
internal/​graph/​activitylog.resolvers.go Accepts the tenant activity-log filter.
internal/​activitylog/​queries/​activitylog.sql Adds team selection and deterministic ordering.
internal/​activitylog/​queries.go Preserves scope and totals across tenant pages.
internal/​activitylog/​model.go Adds tenant filters and multi-team scope storage.
internal/​activitylog/​facets.go Applies team selection to tenant facets.
internal/​activitylog/​activitylogsql/​activitylog.sql.go Updates generated activity-log SQL bindings.
integration_tests/​cross_team_scope.lua Tests cross-team pagination, facets, and membership behavior.
.configs/​gqlgen.yaml Registers shared scope models for GraphQL generation.

Review effort: Balanced

Filter items.
"""
filter: ActivityLogFilter
filter: TenantActivityLogFilter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we accept this

}

func (r *issueTeamFacetItemResolver) Team(ctx context.Context, obj *issue.IssueTeamFacetItem) (*team.Team, error) {
return team.Get(ctx, obj.TeamSlug)
Comment thread internal/vulnerability/fake/v13s.go Resolved
@thokra-nav
thokra-nav marked this pull request as ready for review November 4, 2026 14:43
@thokra-nav
thokra-nav requested a review from a team as a code owner November 4, 2026 14:43
@thokra-nav thokra-nav closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants