Admin library

Contents

This API provides admin-related functions.

Usage

Add the following to your build.gradle file:

dependencies {
  include xplibs.admin
}

Add the import statement to your code:

import adminLib from '/lib/xp/admin';

You are now ready to use the API.

Functions

getInstallation

Returns the installation name.

Parameters

None

Returns

string : The installation name.

Example

import {getInstallation} from '/lib/xp/admin';

const name = getInstallation();

getVersion

Returns the version of the XP installation.

Parameters

None

Returns

string : The version number of the XP runtime.

Example

import {getVersion} from '/lib/xp/admin';

const version = getVersion();

getToolUrl

Returns the URL for an admin tool of a specific application.

Parameters

Name Type Description

application

string

Full application name (f.ex, com.enonic.app.main).

tool

string

Name of the tool inside an app (f.ex, main).

Returns

string : URL of the requested admin tool.

Example

import {getToolUrl} from '/lib/xp/admin';

const url = getToolUrl('com.enonic.app.main', 'main');

getHomeToolUrl

Returns the URL for the Home admin tool.

Parameters

Name Type Description

params

object

Parameter object. Optional.

Properties
Name Type Attributes Default Description

type

string

<optional>

server

URL type. Either server (server-relative URL) or absolute.

Returns

string : The URL pointing to the Home admin tool.

Example

import {getHomeToolUrl} from '/lib/xp/admin';

const url = getHomeToolUrl({type: 'absolute'});

extensionUrl

Returns the URL for an admin extension.

Parameters

Name Type Description

params

object

Parameter object.

Properties
Name Type Attributes Default Description

application

string

Application key that provides the extension.

extension

string

Name of the extension.

type

string

<optional>

server

URL type. Either server (server-relative URL) or absolute.

params

object

<optional>

Custom query parameters to append to the URL.

Returns

string : URL of the requested extension.

Example

import {extensionUrl} from '/lib/xp/admin';

const url = extensionUrl({
    application: 'com.enonic.app.main',
    extension: 'launcher',
    type: 'absolute',
    params: {
        id: '42'
    }
});

widgetUrl

Deprecated — use extensionUrl instead. This function will be removed in future versions.

Returns the URL for a widget. Equivalent to calling extensionUrl with extension set to the widget name.

Parameters

Name Type Description

params

object

Parameter object.

Properties
Name Type Attributes Default Description

application

string

Application key that provides the widget.

widget

string

Name of the widget.

type

string

<optional>

server

URL type. Either server (server-relative URL) or absolute.

params

object

<optional>

Custom query parameters to append to the URL.

Returns

string : URL of the requested widget.


Contents

Contents