Build a Custom Widget
Custom widgets are miniature application views that can you can embed in a YouTrack dashboard. You can build a widget that lets you view and interact with any application that is part of your software ecosystem, including custom views for YouTrack data and information that is stored in your built-in Hub service.
Widget Package
Widgets are built using HTML, CSS, and JavaScript. These are static web apps that run in a sandboxed iFrame.
The widget must have entry file that is named
index.html
.Your widget package can contain related source files.
There are a few resources that you can use to build your widgets.
Resource | Description |
---|---|
dashboard.css | This .css file contains the default text styles and layout definitions that are used for widgets in YouTrack. You can use this as the default stylesheet for your dashboard widgets or modify these style to change your widget layout. |
This script contains code that communicates with a dashboard through messages. It creates a Dashboard object in the global scope, where you can call the single method registerWidget . To use this script, choose one of the following implementations:
|
When you have assembled all of the content and source files for your widget, add a manifest to the top-most directory and create a ZIP archive. You can then import the ZIP archive into YouTrack and enable the widget for use on your dashboards.
Widget Manifest
Each widget should contain a manifest.json
file. This file defines the attributes for your custom widget.
For YouTrack to read and display the attributes in the widget manifest:
The file must be named
manifest.json
.The file must be stored in the top-most directory of the ZIP archive.
The following attributes are defined in the widget manifest:
Attribute | Type | Description | Condition |
---|---|---|---|
key | string | The internal ID that is used to identify the widget in YouTrack. This ID must be unique per server. | required |
version | string | The version number of the widget app. | required |
name | string | The name of the custom widget. This identifies the widget in the Custom Widgets list and is shown in the Add widget drop-down menu. | required |
description | string | The description that is displayed on the Custom Widgets list. | required |
author | string | The name and email address of the developer who created the widget. Specified in the same format that is used in an NPM package. For more information, refer to the npm package description. | required |
homeUrl | URL | The web address of the widget homepage or code repository. Shown in the Details sidebar in the widget list. | optional |
applicationName | string | The name of the application that the widget is designed to display content from. For example, | optional |
iconUrl | URL | The address of the image that is used as the widget icon. The location is relative to the widget root folder, without a leading slash. If empty, the icon of the application referenced in the | optional |
services | sequence | A list of services that are available to the widget. Specified as a sequence of key and value pairs.
| optional |
view | sequence | A list of visual attributes. The only visual attribute that is currently supported is | optional |
The following example shows how each of these attributes are defined in the JSON file. To build your own manifest, copy this example, paste it into your editor, and replace the sample attributes with your own.
{
"key": "some-widget",
"version": "1.0",
"name": "Display name",
"description": "A widget to do something",
"author": "Dee Veloper <dee.veloper@gmail.com>",
"homeUrl": "https://github.com/huston007/some-widget",
"applicationName": "YouTrack",
"iconUrl": "static/icon.svg",
"services": {
"YouTrack": ">2017.1",
"Hub": ">3.0"
},
"view": {
"fadeOut": true
}
}