<commit_before>import {
    Dialog, showDialog, ToolbarButton
} from "@jupyterlab/apputils";

import {
    Widget
} from "@phosphor/widgets";

import {
    FileBrowser,
    IFileBrowserFactory
} from '@jupyterlab/filebrowser'

import {
    style
} from 'typestyle';

import {
    Git
} from './git';

/**
 * The widget encapsulating the Git Clone UI:
 * 1. Includes the Git Clone button in the File Browser toolbar.
 * 2. Includes the modal (UI + callbacks) which invoked to enable Git Clone functionality.
 */
export class GitClone extends Widget {
    file_browser: FileBrowser;

    /**
     * Creates the Widget instance by attaching the clone button to the File Browser toolbar and Git Clone modal.
     * @param factory
     */
    constructor(factory: IFileBrowserFactory) {
        super();
        this.id = 'git-clone-button'
        this.file_browser = factory.defaultBrowser;

        const gitClone = new ToolbarButton({
            iconClassName: `${this.gitTabStyle} jp-Icon jp-Icon-16`,
            onClick: () => {
                this.doGitClone();
            },
            tooltip: 'Git Clone'
        });
        this.file_browser.toolbar.addItem('gitClone', gitClone);
    }

    /**
     * Makes the API call to the server.
     *
     * @param cloneUrl
     */
    private makeApiCall(cloneUrl: string) {
        new Git().clone(this.file_browser.model.path, cloneUrl)
            .then(response => {
                // TODO: Implement error handling with error message when the backend API is fleshed out.
            })
            .catch(() => this.showErrorDialog())
    }

    /**
     * Displays the error dialog when the Git Clone operation fails.
     * @param body the message to be shown in the body of the modal.
     */
    private showErrorDialog(body: string = '') {
        return showDialog({
            title: 'Clone failed',
            body: body,
            buttons: [Dialog.warnButton({label: 'DISMISS'})]
        }).then(() => {
            // NO-OP<commit_msg>Make fileBrowser camel case<commit_after>import {
    Dialog, showDialog, ToolbarButton
} from "@jupyterlab/apputils";

import {
    Widget
} from "@phosphor/widgets";

import {
    FileBrowser,
    IFileBrowserFactory
} from '@jupyterlab/filebrowser'

import {
    style
} from 'typestyle';

import {
    Git
} from './git';

/**
 * The widget encapsulating the Git Clone UI:
 * 1. Includes the Git Clone button in the File Browser toolbar.
 * 2. Includes the modal (UI + callbacks) which invoked to enable Git Clone functionality.
 */
export class GitClone extends Widget {
    fileBrowser: FileBrowser;

    /**
     * Creates the Widget instance by attaching the clone button to the File Browser toolbar and Git Clone modal.
     * @param factory
     */
    constructor(factory: IFileBrowserFactory) {
        super();
        this.id = 'git-clone-button'
        this.fileBrowser = factory.defaultBrowser;

        const gitClone = new ToolbarButton({
            iconClassName: `${this.gitTabStyle} jp-Icon jp-Icon-16`,
            onClick: () => {
                this.doGitClone();
            },
            tooltip: 'Git Clone'
        });
        this.fileBrowser.toolbar.addItem('gitClone', gitClone);
    }

    /**
     * Makes the API call to the server.
     *
     * @param cloneUrl
     */
    private makeApiCall(cloneUrl: string) {
        new Git().clone(this.fileBrowser.model.path, cloneUrl)
            .then(response => {
                // TODO: Implement error handling with error message when the backend API is fleshed out.
            })
            .catch(() => this.showErrorDialog())
    }

    /**
     * Displays the error dialog when the Git Clone operation fails.
     * @param body the message to be shown in the body of the modal.
     */
    private showErrorDialog(body: string = '') {
        return showDialog({
            title: 'Clone failed',
            body: body,
            buttons: [Dialog.warnButton({label: 'DISMISS'})]
        }).then(() => {
            // NO-OP
{'fraction_non_alphanumeric': 0.10818858560794045, 'fraction_numerical': 0.0019851116625310174, 'mean_word_length': 2.174015748031496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1949173', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1126, 'n_words': 348}