public/js/routers.js in conjur-asset-ui-1.3.1 vs public/js/routers.js in conjur-asset-ui-1.3.2
- old
+ new
@@ -1,25 +1,16 @@
/** @jsx React.DOM */
-/* global conjur, jQuery, _, Backbone, React */
-
-(function(conjur, $, _, Backbone, React) {
+(function(conjur, $, _, Backbone, React, SearchResults) {
'use strict';
- var Dashboard = conjur.views.Dashboard,
- GroupBox = conjur.views.GroupBox,
+ var GroupBox = conjur.views.GroupBox,
LayerBox = conjur.views.LayerBox,
PolicyBox = conjur.views.PolicyBox,
VariableBox = conjur.views.VariableBox,
- 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;
+ HostBox = conjur.views.HostBox,
+ UserBox = conjur.views.UserBox;
conjur.Workspace = Backbone.Router.extend({
routes: {
'': 'dashboard',
'ui': 'dashboard',
@@ -44,24 +35,20 @@
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); */
@@ -84,15 +71,13 @@
React.renderComponent(
component,
document.getElementById('content')
);
- }, function(status, text) {
- if (status === 403) {
- conjur.app.flash = 'You are not authorized to view ' +
- conjur.app.kind + ':' + id + '.';
-
+ }, function(status, text, xhr) {
+ 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);
}
});
@@ -111,141 +96,110 @@
);
},
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
-);
+})(conjur, jQuery, _, Backbone, React, SearchResults);