• /
  • Log in

nerdlet

A set of methods to interact with the platform.

Usage

import { nerdlet } from 'nr1'

API methods

nerdlet.getSetUrlStateLocation

Returns a location object. Location objects can be passed into <Link to={location} /> component to navigate inside the platform. When navigated to that location, properties from urlState argument will be able to be read from NerdletStateContext.Consumer.

This method behaves like React’s setState(), meaning that it performs a shallow merge between the current URL state and the provided value in the urlState parameter.

function (
urlState: Object //

New nerdlet URL state.

) => {Object

nerdlet.setConfig

Updates the current nerdlet's configuration.

This method behaves like React’s setState(), meaning that it performs a shallow merge between the current config state and the provided config.

function (
config: {Object //

New nerdlet config

) => undefined

nerdlet.setUrlState

Updates the current nerdlet's URL state that can be read from NerdletStateContext.Consumer.

If you wish to update nerdlet's state without persisting its value in the url, use React's built-in setState().

This method behaves like React’s setState(), meaning that it performs a shallow merge between the current URL state and the provided state in the urlState parameter.

If you wish to navigate without adding an entry to the browser history, set urlStateOptions.replaceHistory to true.

function (
urlState: Object, //

New nerdlet URL state.

urlStateOptions: {Object //

Options for the URL state.

) => void

Constants

nerdlet.ACCOUNT_PICKER_DEFAULT_VALUES

[
{ id: "authorized-accounts" }
]

nerdlet.ACCOUNT_PICKER_VALUE

{
CROSS_ACCOUNT: { id: "cross-account" }
}

nerdlet.ACTION_CONTROL_BUTTON_TYPES

{
PRIMARY: "primary",
SECONDARY: "secondary",
TERTIARY: "tertiary"
}

nerdlet.HEADER_TYPE

{
CUSTOM: "custom",
ENTITY: "entity"
}

nerdlet.TIME_PICKER_DEFAULT_RANGES

[
{ label: "30 minutes", offset: 1800000 },
{ label: "60 minutes", offset: 3600000 },
{ label: "3 hours", offset: 10800000 },
{ label: "6 hours", offset: 21600000 },
{ label: "12 hours", offset: 43200000 },
{ label: "24 hours", offset: 86400000 },
{ label: "3 days", offset: 259200000 },
{ label: "7 days", offset: 604800000 },
{ label: "Set custom", offset: "Custom" }
]

nerdlet.TIME_PICKER_RANGE

{
CUSTOM: { label: "Set custom", offset: "Custom" },
NONE: { label: "Default", offset: null }
}
Create issueEdit page
Copyright © 2021 New Relic Inc.