# `Alternera.Resource.UI.Context`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_resource_ui/lib/alternera/resource/ui/context.ex#L1)

What every component of a resource package's UI is given, as its `ctx`
assign: who is looking, in which tenant, at what, and where.

  * `tenant_id`: the tenant.
  * `actor`: who is looking. **Opaque**: pass it to Ash as `actor:`
    (`Alternera.Resource.UI.opts/1`) and never match on it; it is the
    proxy's user, an API key's owner, or a test's stand-in.
  * `can_write?`: whether the viewer may change records here. It hides
    write controls; the resource's policies still decide at the write.
  * `available?`: whether the host serves resources now. The host
    mounts nothing without it, so a component sees `true`.
  * `package_id`: the package the component belongs to.
  * `resource`: `%{name, module, label, lookup_key}` of the resource the
    component belongs to; nil on a package's page or Workbench item.
  * `timezone`: the viewer's time zone, for showing times.
  * `path`: the page's own path, for links back to it.
  * `place`: where the component is mounted: `:page` (the Resources page
    or a package page), `:workbench` (a Workbench tab) or `:test` (the
    contract kit's harness).
  * `key`: the host's name for this mount. The functions in
    `Alternera.Resource.UI` put it on what they ask the host, so the
    host knows which component asked; a component never reads it.

The host builds it from the session; nothing in it comes from a client's
parameters.

# `resource`

```elixir
@type resource() :: %{
  name: String.t(),
  module: module(),
  label: String.t(),
  lookup_key: atom() | nil
}
```

# `t`

```elixir
@type t() :: %Alternera.Resource.UI.Context{
  actor: term(),
  available?: boolean(),
  can_write?: boolean(),
  key: term(),
  package_id: String.t(),
  path: String.t() | nil,
  place: :page | :workbench | :test,
  resource: resource() | nil,
  tenant_id: String.t(),
  timezone: String.t() | nil
}
```

# `fields`

```elixir
@spec fields() :: [atom()]
```

The fields every host passes, in order; a test keeps the host's in step.

# `resource`

```elixir
@spec resource(module()) :: resource()
```

The `resource` field for a resource module.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
