Introduction
Resource views are the table and details screens of Fleet-Ops, Storefront, Ledger, IAM and Developers. Your extension can add columns, actions, buttons and tabs to them without changing the engine that owns them.
Resource Views
A resource view is one of the screens Fleetbase uses to list and show records: the table of drivers, orders or invoices, and the details view that opens when you click one. Every engine that ships with Fleetbase (Fleet-Ops, Storefront, Ledger, IAM and Developers) builds its screens this way.
Each of those views has a set of registries: named places where an extension can add its own items. Your extension registers an item once, from its extension.js, and the view renders it next to its own, with no change to the engine that owns the view.
What You Can Add
To a Table View
| Element | What it is | Page | |
|---|---|---|---|
| 1 | Columns | A column in the table, with its own cell and, optionally, a filter | Columns |
| 2 | Row actions | An item in each row's "…" menu | Row Actions |
| 3 | Bulk actions | An item in the Bulk Actions menu, run on the selected rows | Bulk Actions |
| 4 | Toolbar buttons | A button in the table's header | Toolbar Buttons |
To a Details View
| Element | What it is | Page | |
|---|---|---|---|
| 1 | Header buttons | A button in the details header | Header Buttons |
| 2 | Menu items | An item in the header's "…" menu | Menu Items |
| 3 | Tabs | A tab that renders your own component | Tabs |
How It Works
Three pieces fit together:
-
A registry name says where the item goes. It reads like a path: the engine, the resource, the kind of view, and the slot.
fleet-ops : driver : table : columns ───┬───── ──┬─── ──┬── ───┬─── extension resource surface slotSee Registry Names.
-
A contract says what the item is. Each kind of item has its own class from
@fleetbase/ember-core/contracts:Contract Used for TableColumnColumns ResourceActionRow actions, bulk actions and details menu items ActionButtonToolbar buttons and details header buttons MenuItemDetails tabs -
The
resource-viewservice stores your item under that name. The view reads the registry when it renders and merges your items in with its own.
// addon/extension.js
import { TableColumn } from '@fleetbase/ember-core/contracts';
export default {
setupExtension(app, universe) {
const views = universe.getService('resource-view');
views.register(
'fleet-ops:driver:table:columns',
new TableColumn({ id: 'acme-safety-score', label: 'Safety Score', valuePath: 'meta.safety_score' })
);
},
};That is a complete registration: the drivers table now has a Safety Score column. Getting Started builds it up step by step, with a custom cell and a placement.
Where to Go Next
Requirements
Resource view registries need @fleetbase/ember-core 0.3.25 and @fleetbase/ember-ui 0.4.5 or later in the console, and these engine versions or later:
| Engine | Package | Version |
|---|---|---|
| Fleet-Ops | @fleetbase/fleetops-engine | 0.6.71 |
| Storefront | @fleetbase/storefront-engine | 0.4.24 |
| Ledger | @fleetbase/ledger-engine | 0.0.12 |
| IAM | @fleetbase/iam-engine | 0.1.13 |
| Developers | @fleetbase/dev-engine | 0.2.17 |
On an older console, registering does nothing and the views render as they always have, so your extension keeps working.