UNPKG

@openshift-console/dynamic-plugin-sdk

Version:

Provides core APIs, types and utilities used by dynamic plugins at runtime.

69 lines (68 loc) 2.98 kB
import * as React from 'react'; import { JSONSchema7Type } from 'json-schema'; import { Extension, ExtensionDeclaration, CodeRef } from '../types'; export declare enum UserPreferenceFieldType { dropdown = "dropdown", checkbox = "checkbox", custom = "custom" } export type UserPreferenceDropdownField = { type: UserPreferenceFieldType.dropdown; userSettingsKey: string; defaultValue?: string; description?: string; options: { value: string; label: string; description?: string; }[]; }; export type UserPreferenceCheckboxFieldValue = string | number | boolean; export type UserPreferenceCheckboxField = { type: UserPreferenceFieldType.checkbox; userSettingsKey: string; label: string; trueValue: UserPreferenceCheckboxFieldValue; falseValue: UserPreferenceCheckboxFieldValue; defaultValue?: UserPreferenceCheckboxFieldValue; description?: string; }; export type UserPreferenceCustomField = { type: UserPreferenceFieldType.custom; component: CodeRef<React.ComponentType>; props?: { [key: string]: JSONSchema7Type; }; }; export type UserPreferenceField = UserPreferenceDropdownField | UserPreferenceCheckboxField | UserPreferenceCustomField; /** This extension can be used to add a group on the console user-preferences page. It will appear as a vertical tab option on the console user-preferences page. */ export type UserPreferenceGroup = ExtensionDeclaration<'console.user-preference/group', { /** ID used to identify the user preference group. */ id: string; /** The label of the user preference group. */ label: string; /** ID of user preference group before which this group should be placed. */ insertBefore?: string; /** ID of user preference group after which this group should be placed. */ insertAfter?: string; }>; /** This extension can be used to add an item to the user preferences group on the console user preferences page. */ export type UserPreferenceItem = ExtensionDeclaration<'console.user-preference/item', { /** ID used to identify the user preference item and referenced in insertAfter and insertBefore to define the item order. */ id: string; /** IDs used to identify the user preference groups the item would belong to. */ groupId: string; /** The label of the user preference. */ label: string; /** The description of the user preference. */ description: string; /** The input field options used to render the values to set the user preference. */ field: UserPreferenceField; /** ID of user preference item before which this item should be placed. */ insertBefore?: string; /** ID of user preference item after which this item should be placed. */ insertAfter?: string; }>; export declare const isUserPreferenceGroup: (e: Extension) => e is UserPreferenceGroup; export declare const isUserPreferenceItem: (e: Extension) => e is UserPreferenceItem;