<commit_before>/**
 * This view shows a list of global navigation links that should be
 * displayed at all times.
 */
girder.views.LayoutGlobalNavView = girder.View.extend({
    events: {
        'click .g-nav-link': function (event) {
            var link = $(event.currentTarget);

            girder.router.navigate(link.attr('g-target'), {trigger: true});

            // Must call this after calling navigateTo, since that
            // deactivates all global nav links.
            link.parent().addClass('g-active');
        }
    },

    initialize: function (settings) {
        girder.events.on('g:highlightItem', this.selectForView, this);
        girder.events.on('g:login', this.render, this);

        settings = settings || {};
        var defaultNavItems = [{
            name: 'Collections',
            icon: 'icon-sitemap',
            target: 'collections'
        }, {
            name: 'Users',
            icon: 'icon-user',
            target: 'users'
        }, {
            name: 'Groups',
            icon: 'icon-users',
            target: 'groups'
        }];
        if (girder.currentUser && girder.currentUser.get('admin')) {
            defaultNavItems.push({
                name: 'Admin console',
                icon: 'icon-wrench',
                target: 'admin'
            });
        }
        this.navItems = settings.navItems || defaultNavItems;

     },

    render: function () {
        this.$el.html(girder.templates.layoutGlobalNav({
            navItems: this.navItems
        }));

        if (Backbone.history.fragment) {
            this.$('[g-target="' + Backbone.history.fragment + '"]')
                .parent().addClass('g-active');
        }

        return this;<commit_msg>updating navItems during render to observe admin status<commit_after>/**
 * This view shows a list of global navigation links that should be
 * displayed at all times.
 */
girder.views.LayoutGlobalNavView = girder.View.extend({
    events: {
        'click .g-nav-link': function (event) {
            var link = $(event.currentTarget);

            girder.router.navigate(link.attr('g-target'), {trigger: true});

            // Must call this after calling navigateTo, since that
            // deactivates all global nav links.
            link.parent().addClass('g-active');
        }
    },

    initialize: function (settings) {
        girder.events.on('g:highlightItem', this.selectForView, this);
        girder.events.on('g:login', this.render, this);

        settings = settings || {};
        if (settings.navItems) {
            this.navItems = settings.navItems;
        } else {
            this.defaultNavItems = [{
                name: 'Collections',
                icon: 'icon-sitemap',
                target: 'collections'
            }, {
                name: 'Users',
                icon: 'icon-user',
                target: 'users'
            }, {
                name: 'Groups',
                icon: 'icon-users',
                target: 'groups'
            }];
        }
    },

    render: function () {
        var navItems;
        if (this.navItems) {
            navItems = this.navItems;
        } else {
            navItems = this.defaultNavItems;
            if (girder.currentUser && girder.currentUser.get('admin')) {
                // copy navItems so that this.defaultNavItems is unchanged
                navItems = navItems.slice();
                navItems.push({
                    name: 'Admin console',
                    icon: 'icon-wrench',
                    target: 'admin'
                });
            }
        }
        this.$el.html(girder.templates.layoutGlobalNav({
            navItems: navItems
        }));

        if (Backbone.history.fragment) {
            this.$('[g-target="' + Backbone.history.fragment + '"]')
                .parent().addClass('g-active');
        }

        return this;
{'fraction_non_alphanumeric': 0.13034571062740077, 'fraction_numerical': 0.0, 'mean_word_length': 1.5765171503957784, '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': '7049857', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1030, 'n_words': 227}