Skip to content

feat: team param for query LiveView#3469

Merged
Ziinc merged 6 commits into
Logflare:mainfrom
msmithstubbs:feat/default-team-param-query
Jun 5, 2026
Merged

feat: team param for query LiveView#3469
Ziinc merged 6 commits into
Logflare:mainfrom
msmithstubbs:feat/default-team-param-query

Conversation

@msmithstubbs

@msmithstubbs msmithstubbs commented May 14, 2026

Copy link
Copy Markdown
Contributor

Follows #3454

Closes O11Y-1754

@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch from 6503c14 to 5b7bd0a Compare May 14, 2026 01:54
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch from 5b7bd0a to a2ed66c Compare May 14, 2026 03:44
@msmithstubbs msmithstubbs marked this pull request as ready for review May 14, 2026 03:44
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch 3 times, most recently from 3d01fd8 to 401940c Compare May 15, 2026 04:01
Comment thread test/logflare_web/live_views/query_live_test.exs Outdated
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch 4 times, most recently from 576e885 to 779cfd3 Compare May 18, 2026 03:37
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch from 779cfd3 to 821af82 Compare May 18, 2026 23:22
@msmithstubbs msmithstubbs requested a review from Ziinc May 19, 2026 05:48
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch 3 times, most recently from 9a50d59 to ad6f70a Compare May 26, 2026 01:26
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch 2 times, most recently from 7caec45 to 4f8f2ae Compare May 29, 2026 05:18
Comment thread lib/logflare/teams/team_context.ex Outdated
|> select([resource_team: team], team.id)
end

def resource_team_id_query(LogflareWeb.QueryLive, %{"q" => query}, user)

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.

Suggested change
def resource_team_id_query(LogflareWeb.QueryLive, %{"q" => query}, user)
def resource_team_id_query(LogflareWeb.QueryLive, %{"q" => query}, user_or_team_user)

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.

Also updated these in #3479 for consistency.

team_owner = insert(:user)
other_team = insert(:team, user: team_owner)
insert(:team_user, email: user.email, team: other_team)
insert(:source, user: team_owner, name: "canonical_source")

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.

What if both teams that the effective user is a team_user of has a source with the same name? Basing it on source name should only be a fallback if there's no team param provided

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.

Good point. The requirement to override an existing team context when a resource is specified falls down when the resource is ambiguous.

This was also an issue when running a query, when the LiveView attempts to set a team context based on the submitted query.

Updated AuthLive to only override team context when the team param is missing.
TeamContext will only change the team context when the query suggests a single team.

If a user has the same-named source in multiple teams, they will have to switch to the appropriate team before querying.

@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch 2 times, most recently from 1a6d2d7 to 1590911 Compare June 2, 2026 23:11
@msmithstubbs msmithstubbs force-pushed the feat/default-team-param-query branch from 639b897 to 688b4e1 Compare June 4, 2026 23:58
@Ziinc Ziinc merged commit 96a2e4e into Logflare:main Jun 5, 2026
13 checks passed
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.

2 participants