feat(dashboard): pick the hosting team when creating an event - #420
feat(dashboard): pick the hosting team when creating an event#420harshtandiya wants to merge 1 commit into
Conversation
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`.
❌ UI Demo Check failedThis pull request changes the UI (3 file(s) under 🛠️ How to fix
Either one re-runs this check automatically. |
Greptile SummaryThis 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.
Confidence Score: 4/5The 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
|
| 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. |
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() |
There was a problem hiding this 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:
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!
What changed
The create form sent
team: currentTeam?.name, which readslocalStorage["buzz:current-team"]— a key nothing in the app has ever written. The only thing that sets it is the fallback insideget_my_teams'sonSuccess, 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_rolemay create events, via a newhostableTeams()beside the existingcanCreateEventsinutils/teamRoles.ts— same client-side mirror ofpermissions.pywe 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 readscurrentTeam, so a global switcher would be inventing a feature nobody asked for.canCreatenow 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_teamrefuses a venue owned by another team, andEventLocationalready refetches on:teambut keeps the stale selection — so without the reset you can hand the server a venue it will reject.No backend change.
NewEvent.teamwas already required andcreate_eventalready validates it withhas_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:
Buttonhas no:activepress feedback, andCombobox's popover scales from centre rather than from its trigger.Demo
Testing
yarn typecheck,yarn lint,yarn fmt:check— clean; scopedpre-commit run --fileson the four touched files passesyarn test:unit— 126 pass, 0 fail (2 new cases forhostableTeams)npx playwright test e2e/tests/create-event.spec.ts --project=chromium— 4 passed, against a local bench onlocalhost:8080""), and the venue list refetches to BWH's, which offers only the Zoom optionbench run-tests— no Python changed