Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log(`Requesting tools for toolbar ${toolBarId}`);
if ("[ViewsFrontstage]ToolWidget-horizontal" === toolBarId) {
const simpleActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "simple-test-action-tool",
execute: (): void => {
// tslint:disable-next-line: no-console
console.log("Got Here!");
},
icon: "icon-developer",
label: "simple-test-action-tool",
};
const childActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "child-test-action-tool",
condition: {
type: ConditionalDisplayType.Visibility,
testFunc: (): boolean => SampleAppIModelApp.getTestProperty() !== "HIDE",
syncEventIds: [SampleAppUiActionId.setTestProperty],
},
execute: (): void => {
// tslint:disable-next-line: no-console
console.log("Got Here!");
},
icon: "icon-developer",
label: "child-test-action-tool",
};
const nestedActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
} 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!");
},
icon: "icon-developer",
label: "test action tool (navH)",
};
return [navHorizontalSpec];
} else if ("[ViewsFrontstage]NavigationWidget-vertical" === toolBarId) {
const navVerticalSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "nav2-test-action-tool",
execute: (): void => {
// tslint:disable-next-line: no-console
console.log("Got Here!");
},
icon: "icon-developer",
label: "test action tool (navV)",
};
return [navVerticalSpec];
}
return [];
}
}
public provideToolbarItems(toolBarId: string, _itemIds: UiItemNode): ToolbarItemInsertSpec[] {
// For 9-zone apps the toolbarId will be in form -[stageName]ToolWidget|NavigationWidget-horizontal|vertical
// examples:"[ViewsFrontstage]ToolWidget-horizontal" "[ViewsFrontstage]NavigationWidget-vertical"
if (toolBarId.includes("ToolWidget-horizontal")) {
const lastActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "iotPlugin:openDialog",
execute: this.showIotDialog,
icon: `svg:${iotButtonSvg}`,
label: "Show IoT Dialog",
};
return [lastActionSpec];
}
return [];
}
public provideToolbarItems(toolBarId: string, _itemIds: UiItemNode): ToolbarItemInsertSpec[] {
// For 9-zone apps the toolbarId will be in form -[stageName]ToolWidget|NavigationWidget-horizontal|vertical
// examples:"[ViewsFrontstage]ToolWidget-horizontal" "[ViewsFrontstage]NavigationWidget-vertical"
if (toolBarId.includes("ToolWidget-horizontal")) {
const lastActionSpec: ActionItemInsertSpec = {
itemType: ToolbarItemType.ActionButton,
itemId: "geoPhotoPlugin:openDialog",
execute: this.showGeoPhotoDialog,
icon: `svg:${geoPhotoButtonSvg}`,
label: "Show GeoPhoto Markers",
};
return [lastActionSpec];
}
return [];
}
}
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);
});