<commit_before>define([
    "require",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "dojo/dom",
    "dojo/dom-construct",
    "../_include/_PageMixin",
    "../_include/_NotificationMixin",
    "../_include/widget/NavigationWidget",
    "../_include/FormLayout",
    "../_include/widget/Button",
    "../../action/Index",
    "../../action/ExportXML",
    "../../action/ClearCaches",
    "../../locale/Dictionary",
    "dojo/text!./template/AdminPage.html"
], function (
    require,
    declare,
    lang,
    dom,
    domConstruct,
    _Page,
    _Notification,
    NavigationWidget,
    FormLayout,
    Button,
    Index,
    ExportXML,
    ClearCaches,
    Dict,
    template
) {
    return declare([_Page, _Notification], {

        templateString: lang.replace(template, Dict.tplTranslate),
        contextRequire: require,
        title: Dict.translate('Settings'),

        processes: {},

        _index: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();
            this.handleProcessBtnClick('index', this.indexBtn, Index,
                Dict.translate("The search index was successfully updated."));
        },

        _export: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();
            this.handleProcessBtnClick('export', this.exportBtn, ExportXML,
                Dict.translate("The content was successfully exported."));
        },

        _clearCaches: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();

            this.clearCachesBtn.setProcessing();<commit_msg>Allow to hide admin functions by permissions<commit_after>define([
    "require",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "dojo/promise/all",
    "dojo/dom",
    "dojo/dom-class",
    "dojo/dom-construct",
    "../_include/_PageMixin",
    "../_include/_NotificationMixin",
    "../_include/widget/NavigationWidget",
    "../_include/FormLayout",
    "../_include/widget/Button",
    "../../action/CheckPermissions",
    "../../action/Index",
    "../../action/ExportXML",
    "../../action/ClearCaches",
    "../../locale/Dictionary",
    "dojo/text!./template/AdminPage.html"
], function (
    require,
    declare,
    lang,
    all,
    dom,
    domClass,
    domConstruct,
    _Page,
    _Notification,
    NavigationWidget,
    FormLayout,
    Button,
    CheckPermissions,
    Index,
    ExportXML,
    ClearCaches,
    Dict,
    template
) {
    return declare([_Page, _Notification], {

        templateString: lang.replace(template, Dict.tplTranslate),
        contextRequire: require,
        title: Dict.translate('Settings'),

        processes: {},

        postCreate: function() {
            this.inherited(arguments);

            var deferredList = [];

            // check permissions
            var requiredPermissions = [
                '??index',
                '??exportXML',
                '??clearCache'
            ];
            deferredList.push(new CheckPermissions({
                operations: requiredPermissions
            }).execute());

            all(deferredList).then(lang.hitch(this, function(results) {
                this.permissions = results[0].result ? results[0].result : {};

                if (this.permissions['??index'] !== true) {
                    domClass.add(this.indexBtn.domNode, "hidden");
                }
                if (this.permissions['??exportXML'] !== true) {
                    domClass.add(this.exportBtn.domNode, "hidden");
                }
                if (this.permissions['??clearCache'] !== true) {
                    domClass.add(this.clearCachesBtn.domNode, "hidden");
                }
            }));
        },

        _index: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();
            this.handleProcessBtnClick('index', this.indexBtn, Index,
                Dict.translate("The search index was successfully updated."));
        },

        _export: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();
            this.handleProcessBtnClick('export', this.exportBtn, ExportXML,
                Dict.translate("The content was successfully exported."));
        },

        _clearCaches: function(e) {
            // prevent the page from navigating after submit
            e.preventDefault();

            this.clearCachesBtn.setProcessing();
{'fraction_non_alphanumeric': 0.136784140969163, 'fraction_numerical': 0.0004405286343612335, 'mean_word_length': 1.9202572347266882, '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': '5507026', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1207, 'n_words': 230}