FleetbaseFleetbase
Resource Views

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

A Fleet-Ops drivers table with an added column, row action, bulk action and toolbar button, each outlined and numbered against its registry name

ElementWhat it isPage
1ColumnsA column in the table, with its own cell and, optionally, a filterColumns
2Row actionsAn item in each row's "…" menuRow Actions
3Bulk actionsAn item in the Bulk Actions menu, run on the selected rowsBulk Actions
4Toolbar buttonsA button in the table's headerToolbar Buttons

To a Details View

A Fleet-Ops driver details panel with an added header button, menu item and tab, each outlined and numbered against its registry name

ElementWhat it isPage
1Header buttonsA button in the details headerHeader Buttons
2Menu itemsAn item in the header's "…" menuMenu Items
3TabsA tab that renders your own componentTabs

How It Works

Three pieces fit together:

  1. 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   slot

    See Registry Names.

  2. A contract says what the item is. Each kind of item has its own class from @fleetbase/ember-core/contracts:

    ContractUsed for
    TableColumnColumns
    ResourceActionRow actions, bulk actions and details menu items
    ActionButtonToolbar buttons and details header buttons
    MenuItemDetails tabs
  3. The resource-view service 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

Getting Started
Add your first column, then a cell component and an action, step by step.
Registry Names
How the names are built, and how to find the one you need.
Registry Catalogue
Every registry the built-in engines declare, with their built-in ids.
Making Your Views Extensible
Let other extensions add to your own engine's tables and details views.

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:

EnginePackageVersion
Fleet-Ops@fleetbase/fleetops-engine0.6.71
Storefront@fleetbase/storefront-engine0.4.24
Ledger@fleetbase/ledger-engine0.0.12
IAM@fleetbase/iam-engine0.1.13
Developers@fleetbase/dev-engine0.2.17

On an older console, registering does nothing and the views render as they always have, so your extension keeps working.

Introduction | Fleetbase