Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
const nestedActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
parentToolGroupId: "tool-formatting-setting",
itemId: "nested-test-action-tool",
execute: (): void => {
// tslint:disable-next-line: no-console
console.log("Got Here!");
},
icon: "icon-developer",
label: "test action tool (nested)",
};
const groupSpec: GroupItemInsertSpec = {
itemType: ToolbarItemType.GroupButton,
itemId: "test-tool-group",
badge: BadgeType.TechnicalPreview,
icon: "icon-developer",
label: "test group",
items: [childActionSpec, simpleActionSpec],
};
return [simpleActionSpec, nestedActionSpec, groupSpec];
} else if ("[ViewsFrontstage]NavigationWidget-horizontal" === toolBarId) {
const navHorizontalSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "nav1-test-action-tool",
execute: (): void => {
// tslint:disable-next-line: no-console
console.log("Got Here!");
private createItemDefFromInsertSpec(spec: ToolbarItemInsertSpec): ItemDefBase | undefined {
let itemDef: ItemDefBase | undefined;
// istanbul ignore else
if (ToolbarItemType.ActionButton === spec.itemType) {
const actionSpec = spec as ActionItemInsertSpec;
itemDef = new CommandItemDef({
commandId: actionSpec.itemId,
iconSpec: actionSpec.icon,
label: actionSpec.label,
execute: actionSpec.execute,
badgeType: actionSpec.badge,
});
} else if (ToolbarItemType.GroupButton === spec.itemType) {
const groupSpec = spec as GroupItemInsertSpec;
const childItems: AnyItemDef[] = [];
groupSpec.items.forEach((childSpec: ToolbarItemInsertSpec) => {
const childItem = this.createItemDefFromInsertSpec(childSpec) as AnyItemDef;
if (childItem)
childItems.push(childItem);
});
itemDef = new GroupItemDef({
groupId: groupSpec.itemId,
iconSpec: groupSpec.icon,
label: groupSpec.label,
badgeType: groupSpec.badge,
items: childItems,
});
}