Documentation
¶
Overview ¶
Package viewsapi serves the portal's saved views (#2505) under /api/v1/portal/views: a person's views and the ones shared with them, each view's definition, its shares, and its run.
A run is the view's filters under the reach of the person opening it (internal/portal/reachstore), never its owner's, so a view shared with a persona shows each member what they can open and counts only that. The owner or an administrator changes a view's shares and deletes it; an editor share also changes its name, description, filters, sort and layout. A person of an external persona opens a view shared with their persona or address, as a viewer, and creates none.
Every route is mounted on the portal's authenticated mux (portal.Deps Mounts) and decides access with the portal's authorization core.
Index ¶
- func Mount(cfg Config) func(*http.ServeMux, *access.Checker)
- func Reach(ctx context.Context, user *access.User, checker *access.Checker) *portaldomain.Reach
- type API
- type Config
- type CreateRequest
- type RunResponse
- type ShareRequest
- type SharesResponse
- type Store
- type UpdateRequest
- type ViewsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API serves the view routes.
type Config ¶
type Config struct {
Store Store
Runner *views.Runner
// else an owned row is shared with).
Shares portaldomain.ShareStore
// Personas lists the persona names a share may be addressed to; nil
// refuses every persona share.
Personas func() []string
// lets everyone share.
MayShare func(user *access.User) bool
// Versions reads a published version's record for a row the person only
// reads (#2510).
Versions portaldomain.VersionReader
}
Config is what the routes read.
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name" example:"Deprecated finance reports"`
Description string `json:"description,omitempty" example:"Everything finance marked deprecated"`
Filters views.Filters `json:"filters"`
// Sort is column[:dir]: updated_at, created_at, name or size_bytes, asc
// or desc (default updated_at:desc).
Sort string `json:"sort,omitempty" example:"updated_at:desc"`
// Layout is grid (the default), table, board_status or board_tag.
Layout views.Layout `json:"layout,omitempty" example:"grid"`
}
CreateRequest is a new view's definition.
type RunResponse ¶
type RunResponse struct {
View views.View `json:"view"`
Data []portaldomain.Asset `json:"data"`
Total int `json:"total" example:"42"`
Limit int `json:"limit" example:"50"`
Offset int `json:"offset" example:"0"`
Groups portaldomain.AssetGroups `json:"groups"`
ShareSummaries map[string]portaldomain.ShareSummary `json:"share_summaries,omitempty"`
// Permissions is the caller's permission on each row they do not own.
Permissions map[string]portaldomain.SharePermission `json:"permissions,omitempty"`
}
RunResponse is one page of a view run for the caller: the same rows and row descriptions the asset listing returns, and the counts per status and per tag a board's columns read, all over what the caller can open.
type ShareRequest ¶
type ShareRequest struct {
Permission views.Permission `json:"permission,omitempty" example:"viewer"`
}
ShareRequest shares a view with one audience: a person (by user id or address), a persona, or everyone signed in whose persona is not external.
type Store ¶
type Store interface {
List(ctx context.Context, r *portaldomain.Reach) ([]views.View, error)
Get(ctx context.Context, r *portaldomain.Reach, id string) (*views.View, error)
GetAny(ctx context.Context, id string) (*views.View, error)
Create(ctx context.Context, v *views.View) error
Update(ctx context.Context, v *views.View) error
Delete(ctx context.Context, id string) error
}
Store is what the routes read and write views through (*views.Store).
type UpdateRequest ¶
type UpdateRequest struct {
Name *string `json:"name,omitempty" example:"Deprecated finance reports"`
Description *string `json:"description,omitempty"`
Filters *views.Filters `json:"filters,omitempty"`
Sort *string `json:"sort,omitempty" example:"name:asc"`
Layout *views.Layout `json:"layout,omitempty" example:"board_status"`
}
UpdateRequest changes a view's definition; an absent field is kept.
type ViewsResponse ¶
ViewsResponse is a list of views.