• EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

nerdlet

A set of methods to modify the nerdlet state.

Use NerdletStateContext to read the nerdlet state.

Usage

import { nerdlet } from 'nr1'

Methods

nerdlet.getSetUrlStateLocation

function (
urlState: Object

New nerdlet URL state.

) => undefined
nerdlet.getSetUrlStateLocation({
foo: 'bar',
});

nerdlet.setConfig

function (
config: NerdletConfig

New nerdlet config

) => undefined
nerdlet.setConfig({
accountPicker: true,
});
nerdlet.setConfig({
accountPicker: true,
accountPickerValues: [
nerdlet.ACCOUNT_PICKER_VALUE.CROSS_ACCOUNT,
...nerdlet.ACCOUNT_PICKER_DEFAULT_VALUES,
],
});
nerdlet.setConfig({
actionControls: true,
actionControlButtons: [
{
label: 'Favorite',
type: nerdlet.ACTION_CONTROL_BUTTON_TYPES.SECONDARY,
hint: 'Add entity to my favorites',
iconType: Icon.TYPE.PROFILES__EVENTS__FAVORITE,
onClick: () => this.onFavoriteEntity(),
},
],
});
nerdlet.setConfig({
filterBar: true,
});
nerdlet.setConfig({
timePicker: true,
timePickerRanges: nerdlet.TIME_PICKER_DEFAULT_RANGES,
});
nerdlet.setConfig({
timePicker: true,
timePickerRanges: [
nerdlet.TIME_PICKER_RANGE.NONE,
{
label: 'Last 15 days',
offset: 1000 * 60 * 60 * 24 * 15,
},
nerdlet.TIME_PICKER_RANGE.CUSTOM,
],
});
nerdlet.setConfig({
header: false,
});
nerdlet.setConfig({
headerType: nerdlet.HEADER_TYPE.CUSTOM,
headerTitle: 'My custom header title',
headerTitleMetadata: 'My custom header title metadata',
});
nerdlet.setConfig({
headerType: nerdlet.HEADER_TYPE.CUSTOM,
headerTitle: 'My custom header title',
headerParentTitle: 'Parent nerdlet I want to redirect to',
headerParentLocation: navigation.openNerdlet({
id: 'my-nerdlet-to-redirect-to',
}),
});

nerdlet.setUrlState

function (
urlState: Object,

New nerdlet URL state.

urlStateOptions: UrlStateOptions

Options for the URL state.

) => undefined
nerdlet.setUrlState({
foo: 'bar',
});

Type definitions

Location

{
pathname: string,

String representing the path to link to.

search: string,

String representing query parameters.

hash: string,

String to put in the URL as hash, e.g. #entities.

}

NerdletConfig

{
accountPicker: boolean,

Enable or disable the nerdlet's account picker.

accountPickerValues: any[],

Config the available accounts for the account picker. There are only two options: all authorized accounts (default) or all authorized accounts plus the 'All accounts' option (cross-account support). See examples for more details.

actionControls: boolean,

Enable or disable the nerdlet's action controls.

actionControlButtons: ActionControlButton[],

Config of your own custom action controls for the nerldet.

filterBar: boolean,

Enable or disable the nerdlet's filter bar.

header: boolean,

Enable or disable the nerdlet's header.

headerTitle: string,

Set the title of the nerdlet's header.

headerTitleMetadata: string,

Set the title metadata of the nerdlet's header.

headerType: string,

Set the header type of the nerdlet's header. Possible values are from nerdlet.HEADER_TYPE.

headerParentTitle: string,

Set the parent title of the nerdlet's header.

headerParentLocation: Location,

Set the parent location of the nerdlet's header.

timePicker: boolean,

Enable or disable the nerdlet's time picker.

timePickerRanges: TimePickerRange[],

Set of time ranges to display for this nerdlet.

timePickerDefaultOffset: number,

Time range offset to select by default.

}

ActionControlButton

{
label: string,

Label of the action control button.

type: Button.TYPE.PRIMARY | Button.TYPE.PLAIN,

Type of the action control button.

iconType: string,

Name of the icon to display.

hint: string,

Text used for the action control button's tooltip.

onClick: () => void,

Callback fired any time the user clicks on the action control button.

}

TimePickerRange

{
label: string,

Label for this time range.

offset: number,

Offset in ms.

}

UrlStateOptions

{
replaceHistory: boolean,

If true, the current entry in the browser history will be replaced with the new one.

}
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.