<commit_before>var settings_users = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

function get_user_info_row(user_id) {
    return $("tr.user_row[data-user-id='" + user_id + "']");
}

function update_view_on_deactivate(row) {
    var button = row.find("button.deactivate");
    row.find('button.open-user-form').hide();
    button.addClass("btn-warning");
    button.removeClass("btn-danger");
    button.addClass("reactivate");
    button.removeClass("deactivate");
    button.text(i18n.t("Reactivate"));
    row.addClass("deactivated_user");
}

function update_view_on_reactivate(row) {
    row.find(".user-admin-settings").show();
    var button = row.find("button.reactivate");
    row.find("button.open-user-form").show();
    button.addClass("btn-danger");
    button.removeClass("btn-warning");
    button.addClass("deactivate");
    button.removeClass("reactivate");
    button.text(i18n.t("Deactivate"));
    row.removeClass("deactivated_user");
}

exports.update_user_data = function (user_id, new_data) {
    if (!meta.loaded) {
        return;
    }

    var user_row = get_user_info_row(user_id);

    if (new_data.full_name !== undefined) {
        // Update the full name in the table
        user_row.find(".user_name").text(new_data.full_name);
    }

    if (new_data.owner !== undefined) {
        // Update the bot owner in the table
        user_row.find(".owner").text(new_data.owner);
    }

    if (new_data.is_active !== undefined) {
        if (new_data.is_active === false) {
            // Deactivate the bot in the table
            update_view_on_deactivate(user_row);
        } else {
            // Reactivate the bot in the table
            update_view_on_reactivate(user_row);
        }
    }

    if (new_data.is_admin !== undefined) {
        if (new_data.is_admin) {
            user_row.find('#admin_icon').show();
        } else {
            user_row.find('#admin_icon').hide();
        }
    }
};

function failed_listing_users(xhr) {
    loading.destroy_indicator($('#subs_page_loading_indicator'));
    ui_report.error(i18n.t("Error listing users or bots"), xhr, $("#organization-status"));<commit_msg>settings_users: Change "role" column text on updation.<commit_after>var settings_users = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

function get_user_info_row(user_id) {
    return $("tr.user_row[data-user-id='" + user_id + "']");
}

function update_view_on_deactivate(row) {
    var button = row.find("button.deactivate");
    row.find('button.open-user-form').hide();
    button.addClass("btn-warning");
    button.removeClass("btn-danger");
    button.addClass("reactivate");
    button.removeClass("deactivate");
    button.text(i18n.t("Reactivate"));
    row.addClass("deactivated_user");
}

function update_view_on_reactivate(row) {
    row.find(".user-admin-settings").show();
    var button = row.find("button.reactivate");
    row.find("button.open-user-form").show();
    button.addClass("btn-danger");
    button.removeClass("btn-warning");
    button.addClass("deactivate");
    button.removeClass("reactivate");
    button.text(i18n.t("Deactivate"));
    row.removeClass("deactivated_user");
}

exports.update_user_data = function (user_id, new_data) {
    if (!meta.loaded) {
        return;
    }

    var user_row = get_user_info_row(user_id);

    if (new_data.full_name !== undefined) {
        // Update the full name in the table
        user_row.find(".user_name").text(new_data.full_name);
    }

    if (new_data.owner !== undefined) {
        // Update the bot owner in the table
        user_row.find(".owner").text(new_data.owner);
    }

    if (new_data.is_active !== undefined) {
        if (new_data.is_active === false) {
            // Deactivate the bot in the table
            update_view_on_deactivate(user_row);
        } else {
            // Reactivate the bot in the table
            update_view_on_reactivate(user_row);
        }
    }

    if (new_data.is_admin !== undefined) {
        if (new_data.is_admin) {
            user_row.find(".user_role").text(i18n.t("Administrator"));
        } else {
            user_row.find(".user_role").text(i18n.t("Member"));
        }
    }
};

function failed_listing_users(xhr) {
    loading.destroy_indicator($('#subs_page_loading_indicator'));
    ui_report.error(i18n.t("Error listing users or bots"), xhr, $("#organization-status"));
{'fraction_non_alphanumeric': 0.15601586602027326, 'fraction_numerical': 0.0035257822829440283, 'mean_word_length': 3.0965703971119134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7220195', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1455, 'n_words': 233}