-
Notifications
You must be signed in to change notification settings - Fork 49
feat(dashboard): team overview at /manage/<team>/overview #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from frappe import _lt | ||
|
|
||
| from buzz.api.exceptions import NotPermitted | ||
|
|
||
|
|
||
| class NotATeamMember(NotPermitted): | ||
| message = _lt("You are not a member of this team.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import frappe | ||
|
|
||
| from buzz.api.teams.exceptions import NotATeamMember | ||
| from buzz.api.teams.schemas import TeamMember, TeamOverview | ||
| from buzz.permissions import team_role_of | ||
|
|
||
| TEAM_FIELDS = ("name", "team_name", "slug", "logo") | ||
|
|
||
|
|
||
| def team_overview(team: str) -> TeamOverview: | ||
| """Everything the team dashboard shows about one team. | ||
|
|
||
| Reads past permissions like `get_my_teams`: Buzz Team is readable by Event Manager | ||
| only, while a Frontdesk or Viewer member still works inside the team. Membership is | ||
| the authorization. | ||
| """ | ||
| role = team_role_of(frappe.session.user, team) | ||
| if not role: | ||
| NotATeamMember.throw() | ||
|
|
||
| details = frappe.db.get_value("Buzz Team", team, TEAM_FIELDS, as_dict=True) | ||
| if not details: | ||
| NotATeamMember.throw() | ||
|
|
||
| return TeamOverview( | ||
| **details, | ||
| my_role=role, | ||
| members=members_of(team), | ||
| ) | ||
|
|
||
|
|
||
| def members_of(team: str) -> list[TeamMember]: | ||
| membership = frappe.qb.DocType("Buzz Team Membership") | ||
| user = frappe.qb.DocType("User") | ||
|
|
||
| rows = ( | ||
| frappe.qb.from_(membership) | ||
| .inner_join(user) | ||
| .on(user.name == membership.user) | ||
| .select(membership.user, membership.team_role, user.full_name, user.user_image) | ||
| .where((membership.team == team) & (membership.enabled == 1)) | ||
| .orderby(user.full_name) | ||
| ).run(as_dict=True) | ||
|
|
||
| return [TeamMember(**row) for row in rows] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <script setup lang="ts"> | ||
| import type { TeamOverview } from "@/types"; | ||
| import { Avatar } from "frappe-ui"; | ||
|
|
||
| defineProps<{ team: TeamOverview }>(); | ||
| </script> | ||
|
|
||
| <template> | ||
| <header class="flex items-center gap-4"> | ||
| <Avatar | ||
| :image="team.logo ?? undefined" | ||
| :label="team.team_name" | ||
| shape="square" | ||
| class="size-20 outline outline-1 -outline-offset-1 outline-black/10 dark:outline-white/10" | ||
| /> | ||
| <div class="flex flex-col gap-2"> | ||
| <h1 class="text-xl font-semibold text-ink-gray-9">{{ team.team_name }}</h1> | ||
| <p v-if="team.slug" class="text-sm text-ink-gray-5">/{{ team.slug }}</p> | ||
| </div> | ||
| </header> | ||
| </template> |
20 changes: 20 additions & 0 deletions
20
dashboard/src/components/dashboard/teams/TeamPageHeader.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <script setup lang="ts"> | ||
| import { currentTeam } from "@/data/teams"; | ||
| import { Breadcrumbs, Button, PageHeader } from "frappe-ui"; | ||
| import { computed } from "vue"; | ||
|
|
||
| const props = defineProps<{ title: string }>(); | ||
|
|
||
| const items = computed(() => { | ||
| const team = currentTeam.value; | ||
| if (!team) return [{ label: props.title }]; | ||
| return [{ label: team.team_name, route: "/manage/team/overview" }, { label: props.title }]; | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <PageHeader class="border-none pt-2"> | ||
| <Breadcrumbs :items="items" /> | ||
| <Button variant="solid" icon-left="plus" label="Create Event" /> | ||
| </PageHeader> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { MyEvents } from "@/types" | ||
| import { useCall } from "frappe-ui" | ||
|
|
||
| // v2 path: useCall reads the payload from `data`, which /api/method names `message`. | ||
| // Uncached: cacheKey would persist this user's feed to IndexedDB past a logout. | ||
| export function useMyEvents() { | ||
| return useCall<MyEvents>({ | ||
| url: "/api/v2/method/buzz.api.events.get_my_events", | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a team member clicks the visible Create Event action, the button has neither a route nor a click handler, so the click has no effect.
Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in later stacked PRs