public/js/routers.js in conjur-asset-ui-1.3.0 vs public/js/routers.js in conjur-asset-ui-1.3.1

- old
+ new

@@ -1,16 +1,25 @@ /** @jsx React.DOM */ +/* global conjur, jQuery, _, Backbone, React */ -(function(conjur, $, _, Backbone, React, SearchResults) { + +(function(conjur, $, _, Backbone, React) { 'use strict'; - var GroupBox = conjur.views.GroupBox, + var Dashboard = conjur.views.Dashboard, + GroupBox = conjur.views.GroupBox, LayerBox = conjur.views.LayerBox, PolicyBox = conjur.views.PolicyBox, VariableBox = conjur.views.VariableBox, - HostBox = conjur.views.HostBox, - UserBox = conjur.views.UserBox; + UserBox = conjur.views.UserBox, + Group = conjur.views.Group, + Host = conjur.views.Host, + Layer = conjur.views.Layer, + Policy = conjur.views.Policy, + User = conjur.views.User, + Variable = conjur.views.Variable, + SearchResults = conjur.views.SearchResults; conjur.Workspace = Backbone.Router.extend({ routes: { '': 'dashboard', 'ui': 'dashboard', @@ -35,20 +44,24 @@ this.setActiveNav(conjur.app.kind); conjur.app.namespace.currentNamespace = ''; conjur.app.lists[conjur.app.kind].fetch(function(list) { var component = componentFunction(list); - // doesn't make much sense due to http://stackoverflow.com/questions/24889934/componentinstance-setstate-undefined-in-0-11-0 + // doesn't make much sense due to + // http://stackoverflow.com/questions/24889934/componentinstance-setstate-undefined-in-0-11-0 //components[kind] = component; React.renderComponent( component, document.getElementById('content') ); - // state reset won't work anymore in react v11, plus I am not sure how it is supposed to work, if namespace was just reset to zero - // component.setState({currentNamespace: namespace.currentNamespace, members: list.members(namespace.currentNamespace)}); + // state reset won't work anymore in react v11, + // plus I am not sure how it is supposed to work, + // if namespace was just reset to zero + // component.setState({currentNamespace: namespace.currentNamespace, + // members: list.members(namespace.currentNamespace)}); }); }, activateRecord: function(k, id, componentFunction) { /* console.log('Record', k, ' :', id); */ @@ -71,13 +84,15 @@ React.renderComponent( component, document.getElementById('content') ); - }, function(status, text, xhr) { - if (status == 403) { - conjur.app.flash = 'You are not authorized to view ' + conjur.app.kind + ':' + id + '.'; + }, function(status, text) { + if (status === 403) { + conjur.app.flash = 'You are not authorized to view ' + + conjur.app.kind + ':' + id + '.'; + window.history.back(); } else { console.error('HTTP error: ', status, text); } }); @@ -96,110 +111,141 @@ ); }, user: function(user) { this.activateRecord('user', user, function(record) { - return <User data={record}/>; + return ( + <User data={record}/> + ); }); }, users: function() { $('#inlineSearchContainer').show(); conjur.app.kind = 'users'; this.activateList(function(list) { - return <UserBox data={{namespaces: list.namespaces, members: list.members('')}} />; + return ( + <UserBox data={{namespaces: list.namespaces, members: list.members('')}} /> + ); }); }, group: function(group) { this.activateRecord('group', group, function(record) { - return <Group data={record} />; + return ( + <Group data={record} /> + ); }); }, groups: function() { $('#inlineSearchContainer').show(); conjur.app.kind = 'groups'; this.activateList(function(list) { - return <GroupBox data={{namespaces: list.namespaces, members: list.members('')}} />; + return ( + <GroupBox data={{namespaces: list.namespaces, members: list.members('')}} /> + ); }); }, - host: function(host){ + host: function(host) { this.activateRecord('host', host, function(record) { - return <Host data={record}/>; + return ( + <Host data={record}/> + ); }); }, hosts: function() { $('#inlineSearchContainer').show(); conjur.app.kind = 'hosts'; var HostBox = conjur.views.HostBox; this.activateList(function(list) { - return <HostBox data={{namespaces: list.namespaces, members: list.members('')}} />; + return ( + <HostBox data={{namespaces: list.namespaces, members: list.members('')}} /> + ); }); }, layer: function(layer) { this.activateRecord('layer', layer, function(record) { - return <Layer data={record} />; + return ( + <Layer data={record} /> + ); }); }, layers: function() { $('#inlineSearchContainer').show(); conjur.app.kind = 'layers'; this.activateList(function(list) { - return <LayerBox data={{namespaces: list.namespaces, members: list.members('')}} />; + return ( + <LayerBox data={{namespaces: list.namespaces, members: list.members('')}} /> + ); }); }, variable: function(variable) { this.activateRecord('variable', variable, function(record) { - return <Variable data={record} />; + return ( + <Variable data={record} /> + ); }); }, variables: function() { $('#inlineSearchContainer').show(); conjur.app.kind = 'variables'; this.activateList(function(list) { - return <VariableBox data={{namespaces: list.namespaces, members: list.members('')}} />; + return ( + <VariableBox data={{namespaces: list.namespaces, members: list.members('')}} /> + ); }); }, policies: function() { conjur.app.kind = 'policies'; this.activateList(function(list) { - return <PolicyBox data={{members: list.members('')}} />; + return ( + <PolicyBox data={{members: list.members('')}} /> + ); }); }, policy: function(policy) { this.activateRecord('policy', policy, function(record) { - return <Policy data={record} />; + return ( + <Policy data={record} /> + ); }); }, - audit: function(){ + audit: function() { $('#inlineSearchContainer').show(); this.setActiveNav('audit'); React.renderComponent( <GlobalAudit/>, document.getElementById('content') ); }, - search: function(search){ + search: function(search) { $('#inlineSearchContainer').show(); SearchResults.search(search); } }); -})(conjur, jQuery, _, Backbone, React, SearchResults); +}) +( + conjur, + jQuery, + _, + Backbone, + React +);