<commit_before>PERT.Dashboard = class Dashboard
{
    static redrawProjectsSelector()
    {
        const select = PERT.ui('menu-contents-projects');
        select.innerHTML = '<option disabled selected>Load a project</option>';
        for (const project of PERT.config.keys()) {
            const option = document.createElement('option');
            option.innerText = project;
            option.value = project;
            select.appendChild(option);
        }
    }

    /**
     * @param {String} [action]
     * @param {Boolean} [returnMessage]
     * @returns {Boolean|String}
     */
    static shouldStayOnPage(action, returnMessage)
    {
        let message = 'The current project has unsaved changes which will be lost if you continue.';
        if (typeof action === 'string') {
            message += ` ${action}`;
        }
        if (PERT.config.changed()) {
            return returnMessage ? message : !confirm(message);
        }
        return false;
    }

    /**
     * @param {String} name
     */
    static createProject(name)
    {
        PERT.config.reset();
        PERT.config.set(name, {});
        PERT.config.commit();
        Dashboard.redrawProjectsSelector();
    }

    /**
     * @param {String} name
     */
    static loadProject(name)
    {
        if (PERT.ui('menu-contents-projects').value !== name) {
            PERT.ui('menu-contents-projects').value = name;
        }

        PERT.config.reset();
        PERT.currentProject = new PERT.Project(name, PERT.config.ns(name));
        PERT.currentProject.drawNodes(); // TODO: Find a better way to do this.
    }

    static deleteProject()
    {
        PERT.config.unset(PERT.currentProject.name);
        PERT.config.commit();
        window.location.reload();
    }

    /**
     * @param {Boolean} [rename=false]
     * @returns {String|null}
     */
    static getNewProjectName(rename)
    {
        if (Dashboard.shouldStayOnPage()) {
            return null;
        }

        let promptText = '';
        let newName = rename ? PERT.currentProject.name : PERT.config.findFreeKey('Untitled Project ');
        for (;;) {
            promptText += `Please enter a ${rename ? 'new name for the' : 'name for the new'} project:`;
            newName = prompt(promptText, newName);
            if (newName === null || (rename && newName === PERT.currentProject.name)) {
                return null;
            } else if (newName === '') {
                promptText = 'The project name cannot be empty.\n';
            } else if (PERT.config.has(newName)) {<commit_msg>Changed the dashboard method for deleting projects to accept a project name<commit_after>PERT.Dashboard = class Dashboard
{
    static redrawProjectsSelector()
    {
        const select = PERT.ui('menu-contents-projects');
        select.innerHTML = '<option disabled selected>Load a project</option>';
        for (const project of PERT.config.keys()) {
            const option = document.createElement('option');
            option.innerText = project;
            option.value = project;
            select.appendChild(option);
        }
    }

    /**
     * @param {String} [action]
     * @param {Boolean} [returnMessage]
     * @returns {Boolean|String}
     */
    static shouldStayOnPage(action, returnMessage)
    {
        let message = 'The current project has unsaved changes which will be lost if you continue.';
        if (typeof action === 'string') {
            message += ` ${action}`;
        }
        if (PERT.config.changed()) {
            return returnMessage ? message : !confirm(message);
        }
        return false;
    }

    /**
     * @param {String} name
     */
    static createProject(name)
    {
        PERT.config.reset();
        PERT.config.set(name, {});
        PERT.config.commit();
        Dashboard.redrawProjectsSelector();
    }

    /**
     * @param {String} name
     */
    static loadProject(name)
    {
        if (PERT.ui('menu-contents-projects').value !== name) {
            PERT.ui('menu-contents-projects').value = name;
        }

        PERT.config.reset();
        PERT.currentProject = new PERT.Project(name, PERT.config.ns(name));
        PERT.currentProject.drawNodes(); // TODO: Find a better way to do this.
    }

    /**
     * @param {String} name
     */
    static deleteProject(name)
    {
        PERT.config.unset(name);
        PERT.config.commit();
        window.location.reload();
    }

    /**
     * @param {Boolean} [rename=false]
     * @returns {String|null}
     */
    static getNewProjectName(rename)
    {
        if (Dashboard.shouldStayOnPage()) {
            return null;
        }

        let promptText = '';
        let newName = rename ? PERT.currentProject.name : PERT.config.findFreeKey('Untitled Project ');
        for (;;) {
            promptText += `Please enter a ${rename ? 'new name for the' : 'name for the new'} project:`;
            newName = prompt(promptText, newName);
            if (newName === null || (rename && newName === PERT.currentProject.name)) {
                return null;
            } else if (newName === '') {
                promptText = 'The project name cannot be empty.\n';
            } else if (PERT.config.has(newName)) {
{'fraction_non_alphanumeric': 0.13367658276125097, 'fraction_numerical': 0.0, 'mean_word_length': 2.0005720823798625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6367859', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1480, 'n_words': 342}