Skip to content

feat(dashboard): pick the hosting team when creating an event - #420

Closed
harshtandiya wants to merge 1 commit into
developfrom
feat/create-event-team-picker
Closed

feat(dashboard): pick the hosting team when creating an event#420
harshtandiya wants to merge 1 commit into
developfrom
feat/create-event-team-picker

Conversation

@harshtandiya

Copy link
Copy Markdown
Collaborator

What changed

The create form sent team: currentTeam?.name, which reads localStorage["buzz:current-team"] — a key nothing in the app has ever written. The only thing that sets it is the fallback inside get_my_teams's onSuccess, so a member of several teams got whichever team the query returned first and had no way to change it.

Adds a Hosted by picker between the banner and the title. It lists only teams whose team_role may create events, via a new hostableTeams() beside the existing canCreateEvents in utils/teamRoles.ts — same client-side mirror of permissions.py we already keep, no new endpoint. The selection is local to the form and is deliberately not written back to the stored team; nothing else in the app reads currentTeam, so a global switcher would be inventing a feature nobody asked for.

canCreate now means "a hostable team is selected" rather than "the stored team's role is high enough". The options are already filtered, so having one picked is the permission. A Viewer-only user gets an empty picker and the same amber alert as before.

Switching teams clears the venue. Buzz Event.validate_venue_team refuses a venue owned by another team, and EventLocation already refetches on :team but keeps the stale selection — so without the reset you can hand the server a venue it will reject.

No backend change. NewEvent.team was already required and create_event already validates it with has_team_access(new.team, "create", ...); host_for(team) mints the Event Host. The picker just stops guessing on the user's behalf.

Two frappe-ui gaps left alone, since fixing them here would make this one control inconsistent with every other: Button has no :active press feedback, and Combobox's popover scales from centre rather than from its trigger.

Demo

Testing

  • yarn typecheck, yarn lint, yarn fmt:check — clean; scoped pre-commit run --files on the four touched files passes
  • yarn test:unit — 126 pass, 0 fail (2 new cases for hostableTeams)
  • npx playwright test e2e/tests/create-event.spec.ts --project=chromium — 4 passed, against a local bench on localhost:8080
  • Driven by hand in that bench as a user in two teams: picking BWH clears an already-chosen Test Team venue (""), and the venue list refetches to BWH's, which offers only the Zoom option
  • Not run here: the rest of the e2e suite, and bench run-tests — no Python changed

The create form sent whatever team `localStorage["buzz:current-team"]` named, and
nothing in the app ever set that value. A member of several teams had no way to say
which one an event belonged to.

Add a "Hosted by" picker between the banner and the title, listing only the teams
whose role may create events. The choice is local to the form and is not written back
to the stored team. Switching teams clears the venue, since the server refuses a venue
that belongs to another team.

No backend change: `NewEvent.team` was already required and `create_event` already
validates it with `has_team_access`.
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

❌ UI Demo Check failed

This pull request changes the UI (3 file(s) under dashboard/src/),
but the description has no screenshot or demo. Reviewers should be able to see the
change without checking out the branch.

🛠️ How to fix

  • Edit the description and drag a screenshot or a short screen recording into it.
    Before/after images are ideal for visual tweaks. A Loom or Cap link works too.
  • Or apply the skip-demo label if a visual makes no sense here
    (pure refactor, copy change, dependency bump).

Either one re-runs this check automatically.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR lets event creators choose any team for which they have event-creation permission, uses that selection in the creation payload, and clears team-owned venue state when the host changes.

  • Adds a host-team Combobox with team branding to the event creation form.
  • Filters available hosts to Owner, Admin, and Manager memberships.
  • Adds unit coverage for hostable-team filtering.
  • Adds only visibility-level browser coverage for the new picker; its selection and venue-reset behavior remain untested.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking gap in browser coverage for the new host-selection workflow.

No concrete behavioral or security failure was established, but the end-to-end test does not protect the picker’s selection, venue-reset, or payload behavior from regression.

Files Needing Attention: e2e/tests/create-event.spec.ts

Important Files Changed

Filename Overview
dashboard/src/pages/manage/events/CreateEvent.vue Adds local host-team selection, permission-derived form gating, venue reset on host changes, and the selected team in the creation payload.
dashboard/src/utils/teamRoles.ts Adds a hostableTeams helper that filters memberships using the existing event-write role mapping.
dashboard/src/utils/teamRoles.test.ts Covers accepted and rejected hosting roles and the empty-team case.
e2e/tests/create-event.spec.ts Confirms the host picker is rendered but does not exercise team selection, venue reset, or submission.

Fix all with Greploop Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
### Issue 1
e2e/tests/create-event.spec.ts:14
**Host selection remains untested**

This test only confirms that the new “Hosted by” button is visible. It never selects another host, verifies that the venue is cleared and refetched, or confirms that the selected team reaches the creation request. These are the feature’s central state transitions and cross-team safeguard, so a regression in the Combobox binding or venue reset would pass this test. Extend the scenario with at least two hostable teams and assert the changed selection, cleared venue, and submitted event team.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(dashboard): pick the hosting team w..." | Re-trigger Greptile

await expect(page).toHaveURL(/\/b\/manage\/team\/events\/new$/, { timeout: 15000 })
await expect(page.getByRole("button", { name: "Add a banner" })).toBeVisible()
await expect(page.getByRole("textbox", { name: "Event title" })).toBeVisible()
await expect(page.getByRole("button", { name: "Hosted by" })).toBeVisible()

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.

P2 Host selection remains untested

This test only confirms that the new “Hosted by” button is visible. It never selects another host, verifies that the venue is cleared and refetched, or confirms that the selected team reaches the creation request. These are the feature’s central state transitions and cross-team safeguard, so a regression in the Combobox binding or venue reset would pass this test. Extend the scenario with at least two hostable teams and assert the changed selection, cleared venue, and submitted event team.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: e2e/tests/create-event.spec.ts
Line: 14

Comment:
**Host selection remains untested**

This test only confirms that the new “Hosted by” button is visible. It never selects another host, verifies that the venue is cleared and refetched, or confirms that the selected team reaches the creation request. These are the feature’s central state transitions and cross-team safeguard, so a regression in the Combobox binding or venue reset would pass this test. Extend the scenario with at least two hostable teams and assert the changed selection, cleared venue, and submitted event team.

**Knowledge Base Used:**
- [Dashboard event management](https://app.greptile.com/bwh-tech/-/custom-context/knowledge-base/bwhtech/buzz/-/docs/dashboard-event-management.md)
- [Quality automation](https://app.greptile.com/bwh-tech/-/custom-context/knowledge-base/bwhtech/buzz/-/docs/quality-automation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

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.

1 participant