Sha256: bb714d42c91d5bca07e9f7d3d62e1b243591887f66b86c0af77e8f736ea23fb8

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

/**
 * Copyright 2014 Red Hat, Inc.
 *
 * This software is licensed to you under the GNU General Public
 * License as published by the Free Software Foundation; either version
 * 2 of the License (GPLv2) or (at your option) any later version.
 * There is NO WARRANTY for this software, express or implied,
 * including the implied warranties of MERCHANTABILITY,
 * NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
 * have received a copy of GPLv2 along with this software; if not, see
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 **/


(function () {

    /**
     * @ngdoc run
     * @name Bastion.run:CheckCurrentOrganization
     *
     * @description
     *   Checks whether a page requires a current organization to be set and if it does
     *   redirects the user to the Katello 403 page to instruct them to select an organization to proceed.
     */
    function CheckCurrentOrganization($rootScope, $window, CurrentOrganization) {
        var fencedPages = [
            'products',
            'activation-keys',
            'environments',
            'subscriptions',
            'gpg-keys',
            'sync-plans',
            'content-views',
            'errata',
            'content-hosts',
            'host-collections'
        ];

        $rootScope.$on('$stateChangeStart', function (event, toState) {
            if (CurrentOrganization === "" && fencedPages.indexOf(toState.name.split('.')[0]) !== -1) {
                event.preventDefault();
                $rootScope.transitionTo('organizations.select', {toState: toState.url});
            }
        });

    }

    angular
        .module('Bastion.organizations')
        .run(CheckCurrentOrganization);

    CheckCurrentOrganization.$inject = ['$rootScope', '$window', 'CurrentOrganization'];

})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/check-current-organization.run.js