How to use the @jupyterlab/apputils.Dialog.warnButton function in @jupyterlab/apputils

To help you get started, we’ve selected a few @jupyterlab/apputils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / notebook / src / actions.tsx View on Github external
// Do nothing if already trusted.

    const cells = toArray(notebook.model.cells);
    const trusted = cells.every(cell => cell.trusted);

    if (trusted) {
      return showDialog({
        body: 'Notebook is already trusted',
        buttons: [Dialog.okButton()]
      }).then(() => undefined);
    }

    return showDialog({
      body: TRUST_MESSAGE,
      title: 'Trust this notebook?',
      buttons: [Dialog.cancelButton(), Dialog.warnButton()]
    }).then(result => {
      if (result.button.accept) {
        cells.forEach(cell => {
          cell.trusted = true;
        });
      }
    });
  }
}
github jupyterlab / jupyterlab-data-explorer / packages / docmanager / src / widgetmanager.ts View on Github external
return factory.readOnly === false;
      })
    );
    let factory = Private.factoryProperty.get(widget);
    if (!factory) {
      return Promise.resolve(true);
    }
    let model = context.model;
    if (!model.dirty || widgets.length > 1 || factory.readOnly) {
      return Promise.resolve(true);
    }
    let fileName = widget.title.label;
    return showDialog({
      title: 'Close without saving?',
      body: `File "${fileName}" has unsaved changes, close without saving?`,
      buttons: [Dialog.cancelButton(), Dialog.warnButton()]
    }).then(result => {
      return result.button.accept;
    });
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / notebook-extension / src / index.ts View on Github external
closeAndCleanup: (current: NotebookPanel) => {
      const fileName = current.title.label;
      return showDialog({
        title: 'Shutdown the notebook?',
        body: `Are you sure you want to close "${fileName}"?`,
        buttons: [Dialog.cancelButton(), Dialog.warnButton()]
      }).then(result => {
        if (result.button.accept) {
          return current.context.session.shutdown().then(() => {
            current.dispose();
          });
        }
      });
    }
  } as IFileMenu.ICloseAndCleaner);
github jupyterlab / jupyterlab / packages / apputils-extension / src / index.ts View on Github external
function recover(fn: () => void): void {
    if (dialog) {
      return;
    }

    dialog = new Dialog({
      title: 'Loading...',
      body: `The loading screen is taking a long time.
        Would you like to clear the workspace or keep waiting?`,
      buttons: [
        Dialog.cancelButton({ label: 'Keep Waiting' }),
        Dialog.warnButton({ label: 'Clear Workspace' })
      ]
    });

    dialog
      .launch()
      .then(result => {
        if (result.button.accept) {
          return fn();
        }

        dialog.dispose();
        dialog = null;

        debouncer = window.setTimeout(() => {
          recover(fn);
        }, SPLASH_RECOVER_TIMEOUT);
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / filebrowser / src / model.ts View on Github external
private async _shouldUploadLarge(file: File): Promise {
    const { button } = await showDialog({
      title: 'Large file size warning',
      body: `The file size is ${Math.round(
        file.size / (1024 * 1024)
      )} MB. Do you still want to upload it?`,
      buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'UPLOAD' })]
    });
    return button.accept;
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / filebrowser / src / listing.ts View on Github external
each(this._sortedItems, item => {
      if (this._selection[item.name]) {
        names.push(item.name);
      }
    });
    let message = `Are you sure you want to permanently delete the ${
      names.length
    } files/folders selected?`;
    if (names.length === 1) {
      message = `Are you sure you want to permanently delete: ${names[0]}?`;
    }
    if (names.length) {
      return showDialog({
        title: 'Delete',
        body: message,
        buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'DELETE' })]
      }).then(result => {
        if (!this.isDisposed && result.button.accept) {
          return this._delete(names);
        }
      });
    }
    return Promise.resolve(void 0);
  }
github legion-platform / legion / legion / jupyterlab-plugin / src / components / dialogs / cloud.tsx View on Github external
<h3>Results</h3>
            <ul>{result}</ul>
          
        )}

        {training.status.message != null &amp;&amp; training.status.message !== '' &amp;&amp; (
          <div>
            <h3>Message state</h3>
            <p>{training.status.message}</p>
          </div>
        )}
      
    ),
    buttons: [
      Dialog.okButton({ label: LOGS_LABEL }),
      Dialog.warnButton({ label: REMOVE_TRAINING_LABEL }),
      Dialog.cancelButton({ label: 'Close window' })
    ]
  });
}
github jupyterlab / jupyterlab / packages / application-extension / src / index.tsx View on Github external
.then(() => {
          return showDialog({
            title: 'Build Complete',
            body: 'Build successfully completed, reload page?',
            buttons: [
              Dialog.cancelButton(),
              Dialog.warnButton({ label: 'RELOAD' })
            ]
          });
        })
        .then(result => {
github legion-platform / legion / legion / jupyterlab-plugin / src / components / dialogs / cloud.tsx View on Github external
<div>
            <h3>Results</h3>
            <ul>{result}</ul>
          </div>
        )}
        {mp.status.message != null &amp;&amp; mp.status.message !== '' &amp;&amp; (
          <div>
            <h3>Message state</h3>
            <p>{mp.status.message}</p>
          </div>
        )}
      
    ),
    buttons: [
      Dialog.okButton({ label: LOGS_LABEL }),
      Dialog.warnButton({ label: REMOVE_MODEL_PACKING_LABEL }),
      Dialog.cancelButton({ label: 'Close window' })
    ]
  });
}
github jupyterlab / jupyterlab / packages / docregistry / src / context.ts View on Github external
private _maybeOverWrite(path: string): Promise {
    let body = `"${path}" already exists. Do you want to replace it?`;
    let overwriteBtn = Dialog.warnButton({ label: 'Overwrite' });
    return showDialog({
      title: 'File Overwrite?',
      body,
      buttons: [Dialog.cancelButton(), overwriteBtn]
    }).then(result =&gt; {
      if (this.isDisposed) {
        return Promise.reject(new Error('Disposed'));
      }
      if (result.button.label === 'Overwrite') {
        return this._manager.contents.delete(path).then(() =&gt; {
          return this._finishSaveAs(path);
        });
      }
    });
  }