package templates // ShareRow is a single share grant shown in the UI, for either a calendar // or an address book (Kind distinguishes them for form targets). type ShareRow struct { ResourceName string SharedWith string Permission string // "read" or "write" } // ResourceCard describes one of the user's own calendars/address books // plus who it's currently shared with. type ResourceCard struct { Kind string // "calendar" or "addressbook" Name string Shares []ShareRow } // SharedWithMeItem describes a resource another user has shared with the // current user. type SharedWithMeItem struct { Kind string Owner string Name string Permission string } templ Dashboard(username string, resources []ResourceCard, sharedWithMe []SharedWithMeItem) { @Layout("Dashboard", username) {

Your calendars & address books

for _, r := range resources { @ResourceCardView(r) }
if len(sharedWithMe) > 0 {

Shared with you

} } } templ ResourceCardView(r ResourceCard) {

{ r.Name } { r.Kind }

} func shareEndpoint(kind string) string { if kind == "calendar" { return "/web/shares/calendar" } return "/web/shares/addressbook" } func shareVals(resource, sharedWith string) string { return `{"resource": "` + resource + `", "shared_with": "` + sharedWith + `"}` }