FleetbaseFleetbase
Resource ViewsDetails Views

Tabs

Add a tab to another engine's details view with MenuItem — a component from your engine, rendered with the record, the routes it uses, the arguments it receives, and the details tabs alias.

Tabs

A tab adds a page of your own to a record's details view, next to tabs such as Overview and Activity. It renders a component from your engine, with the record.

import { MenuItem, ExtensionComponent } from '@fleetbase/ember-core/contracts';

universe.getService('resource-view').register(
    'fleet-ops:driver:details:tabs',
    new MenuItem({
        title: 'Safety',
        slug: 'acme-safety',
        icon: 'shield-halved',
        route: 'management.drivers.index.details.virtual',
        component: new ExtensionComponent('@acme/safety-engine', 'driver-safety-tab'),
    })
);
Slot<extension>:<resource>:details:tabs
ContractMenuItem, from @fleetbase/ember-core/contracts
Keyed byslug
Default spotAfter the view's own tabs

Options

Prop

Type

MenuItem has more options, used by menus elsewhere in the console; see Menu Service.

The Route

In a routed details page, a tab is a link to the engine's virtual route for that view, which renders your component with the slug in the URL. These details views have one:

Details viewroute
Fleet-Ops ordersoperations.orders.index.details.virtual
Fleet-Ops driversmanagement.drivers.index.details.virtual
Fleet-Ops vehiclesmanagement.vehicles.index.details.virtual
Fleet-Ops fleetsmanagement.fleets.index.details.virtual
Fleet-Ops placesmanagement.places.index.details.virtual
Fleet-Ops devicesconnectivity.devices.index.details.virtual
Fleet-Ops sensorsconnectivity.sensors.index.details.virtual
Storefront ordersorders.index.view.virtual

Your Tab's Component

{{! addon/components/driver-safety-tab.hbs }}
<div class="p-4 space-y-4">
    <h3 class="text-lg font-semibold">Safety score: {{this.score}}</h3>
    <Table @rows={{this.incidents}} @columns={{this.columns}} />
</div>
ArgumentValue
@resourceThe record
@paramsThe tab's componentParams

The record is also passed under the resource's own name, such as @driver or @order. Prefer @resource, so one component can serve several views.

The Alias

Tabs existed before resource view registries, under the name <extension>:component:<resource>:details, registered through the Menu Service. The details:tabs name is an alias for it:

// These two register into the same place
views.register('fleet-ops:driver:details:tabs', tab);
universe.getService('menu').registerMenuItem('fleet-ops:component:driver:details', tab);

// The shortcut
views.registerDetailsTab('fleet-ops', 'driver', tab);

Tabs registered either way appear together, and views.get('fleet-ops:driver:details:tabs') lists all of them. To remove one, unregister its slug:

views.unregister('fleet-ops:driver:details:tabs', 'acme-safety');
Tabs | Fleetbase