viewsapi

package
v1.172.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(cfg Config) func(*http.ServeMux, *access.Checker)

Mount returns the hook that registers the view routes on the portal's authenticated mux with its authorization core.

func Reach

func Reach(ctx context.Context, user *access.User, checker *access.Checker) *portaldomain.Reach

Reach is the person a view is listed and run for: everything they can open, marked external when their persona is (#2092), which keeps a view shared with everyone signed in from them.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API serves the view routes.

func New

func New(cfg Config, checker *access.Checker) *API

New builds the routes' handler; Mount registers it.

type Config

type Config struct {
	Store  Store
	Runner *views.Runner
	// Shares is the asset share store a run's rows are described from (who
	// 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
	// MayShare reports whether the caller's persona shares (#2241); nil
	// 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 describe the rows the caller owns.
	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 {
	SharedWithUserID  string `json:"shared_with_user_id,omitempty"`
	SharedWithEmail   string `json:"shared_with_email,omitempty" example:"bob@example.com"`
	SharedWithPersona string `json:"shared_with_persona,omitempty" example:"finance"`
	Everyone          bool   `json:"everyone,omitempty"`
	// Permission is viewer (the default) or editor.
	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 SharesResponse

type SharesResponse struct {
	Shares []views.Share `json:"shares"`
}

SharesResponse is a view's active shares.

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
	Shares(ctx context.Context, viewID string) ([]views.Share, error)
	AddShare(ctx context.Context, sh *views.Share) error
	RevokeShare(ctx context.Context, viewID, shareID 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

type ViewsResponse struct {
	Views []views.View `json:"views"`
}

ViewsResponse is a list of views.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL