Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Make a refresh button for the toolbar.
toolbar.addItem(
'refresh',
new ToolbarButton({
iconClassName: 'jp-RefreshIcon jp-Icon jp-Icon-16',
onClick: () => {
this._updateClusterList();
},
tooltip: 'Refresh Cluster List'
})
);
// Make a new cluster button for the toolbar.
toolbar.addItem(
this._launchClusterId,
new CommandToolbarButton({
commands: this._registry,
id: this._launchClusterId
})
);
layout.addWidget(toolbar);
layout.addWidget(this._clusterListing);
// Do an initial refresh of the cluster list.
this._updateClusterList();
// Also refresh periodically.
this._poll = new Poll({
factory: async () => {
await this._updateClusterList();
},
frequency: { interval: REFRESH_INTERVAL, backoff: true, max: 60 * 1000 },
it('should add main class', async () => {
const button = new CommandToolbarButton({
commands,
id: testLogCommandId
});
await render(button);
const buttonNode = button.node.firstChild as HTMLButtonElement;
expect(buttonNode.classList.contains('test-log-class')).to.equal(true);
button.dispose();
});
it('should add an icon with icon class and label', async () => {
const button = new CommandToolbarButton({
commands,
id: testLogCommandId
});
await render(button);
const buttonNode = button.node.firstChild as HTMLButtonElement;
expect(buttonNode.title).to.equal('Test log command caption');
const wrapperNode = buttonNode.firstChild as HTMLElement;
const iconNode = wrapperNode.firstChild as HTMLElement;
expect(iconNode.classList.contains('test-icon-class')).to.equal(true);
button.dispose();
});
it('should use the command label if no icon class/label', async () => {
const id = 'to-be-removed';
const cmd = commands.addCommand(id, {
execute: () => {
return;
},
label: 'Label-only button'
});
const button = new CommandToolbarButton({
commands,
id
});
await render(button);
const buttonNode = button.node.firstChild as HTMLButtonElement;
expect(buttonNode.textContent).to.equal('Label-only button');
cmd.dispose();
});
it('should create a button', () => {
const button = new CommandToolbarButton({
commands,
id: testLogCommandId
});
expect(button).to.be.an.instanceof(CommandToolbarButton);
button.dispose();
});
[revert, save].forEach(name => {
const item = new CommandToolbarButton({ commands: registry, id: name });
toolbar.addItem(name, item);
});
}
: nbtracker.currentWidget
? nbtracker.currentWidget.context.path
: null;
logConsoleWidget = new MainAreaWidget({ content: logConsolePanel });
logConsoleWidget.addClass('jp-LogConsole');
logConsoleWidget.title.closable = true;
logConsoleWidget.title.label = 'Log Console';
logConsoleWidget.title.iconClass = 'jp-ListIcon';
const addCheckpointButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.addCheckpoint
});
const clearButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.clear
});
logConsoleWidget.toolbar.addItem(
'lab-log-console-add-checkpoint',
addCheckpointButton
);
logConsoleWidget.toolbar.addItem('lab-log-console-clear', clearButton);
logConsoleWidget.toolbar.addItem(
'level',
new LogLevelSwitcher(logConsoleWidget.content)
);
logConsolePanel.sourceChanged.connect(() => {
: nbtracker.currentWidget
? nbtracker.currentWidget.context.path
: null;
logConsoleWidget = new MainAreaWidget({ content: logConsolePanel });
logConsoleWidget.addClass('jp-LogConsole');
logConsoleWidget.title.closable = true;
logConsoleWidget.title.label = 'Log Console';
logConsoleWidget.title.iconClass = 'jp-LogConsoleIcon';
const addCheckpointButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.addCheckpoint
});
const clearButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.clear
});
logConsoleWidget.toolbar.addItem(
'lab-log-console-add-checkpoint',
addCheckpointButton
);
logConsoleWidget.toolbar.addItem('lab-log-console-clear', clearButton);
logConsoleWidget.toolbar.addItem(
'level',
new LogLevelSwitcher(logConsoleWidget.content)
);
logConsolePanel.sourceChanged.connect(() => {
logConsolePanel = new LogConsolePanel(loggerRegistry);
logConsolePanel.source =
options.source !== undefined
? options.source
: nbtracker.currentWidget
? nbtracker.currentWidget.context.path
: null;
logConsoleWidget = new MainAreaWidget({ content: logConsolePanel });
logConsoleWidget.addClass('jp-LogConsole');
logConsoleWidget.title.closable = true;
logConsoleWidget.title.label = 'Log Console';
logConsoleWidget.title.iconClass = 'jp-LogConsoleIcon';
const addCheckpointButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.addCheckpoint
});
const clearButton = new CommandToolbarButton({
commands: app.commands,
id: CommandIDs.clear
});
logConsoleWidget.toolbar.addItem(
'lab-log-console-add-checkpoint',
addCheckpointButton
);
logConsoleWidget.toolbar.addItem('lab-log-console-clear', clearButton);
logConsoleWidget.toolbar.addItem(
public createNew(
nb: NotebookPanel,
context: DocumentRegistry.IContext
): IDisposable {
const btn = new CommandToolbarButton({
commands: this.app.commands,
id: Constants.FORMAT_ALL_COMMAND
});
nb.toolbar.insertAfter(
'cellType',
this.app.commands.label(Constants.FORMAT_ALL_COMMAND),
btn
);
return new DisposableDelegate(() => {
btn.dispose();
});
}