conjur-asset-ui 1.4.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -3
- data/CHANGELOG.md +10 -0
- data/Makefile +19 -0
- data/README.md +0 -3
- data/Rakefile +22 -17
- data/TODO.md +0 -23
- data/app/.csscomb.json +304 -0
- data/app/.eslintignore +3 -0
- data/app/.eslintrc +265 -0
- data/app/config/preprocessor.js +19 -0
- data/app/config/webpack.js +124 -0
- data/app/gulpfile.js +96 -0
- data/app/package.json +86 -0
- data/app/src/actions.js +550 -0
- data/app/src/app.js +83 -0
- data/app/src/clients/audit.js +34 -0
- data/app/src/clients/auth.js +24 -0
- data/app/src/clients/generic.js +52 -0
- data/app/src/clients/graph.js +7 -0
- data/app/src/clients/layer_members.js +18 -0
- data/app/src/clients/list.js +31 -0
- data/app/src/clients/members.js +20 -0
- data/app/src/clients/request.js +531 -0
- data/app/src/clients/search.js +5 -0
- data/app/src/components/app/__tests__/app-test.js +22 -0
- data/app/src/components/app/app.js +36 -0
- data/app/src/components/app/wrapper.js +17 -0
- data/app/src/components/audit/__tests__/table_header-test.js +22 -0
- data/app/src/components/audit/box.js +9 -0
- data/app/src/components/audit/constants.js +5 -0
- data/app/src/components/audit/entry.js +105 -0
- data/app/src/components/audit/fields_mixin.js +11 -0
- data/app/src/components/audit/humanize_event.js +213 -0
- data/app/src/components/audit/table.js +64 -0
- data/app/src/components/audit/table_header.js +37 -0
- data/app/src/components/audit/timestamp.js +28 -0
- data/app/src/components/auth/login.js +177 -0
- data/app/src/components/auth/login.less +71 -0
- data/app/src/components/auth/logout.js +42 -0
- data/app/src/components/auth/logout.less +21 -0
- data/app/src/components/chart/chart.js +540 -0
- data/app/src/components/chart/chart_helper_mixin.js +78 -0
- data/app/src/components/custom/list.js +3 -0
- data/app/src/components/custom/view.js +81 -0
- data/app/src/components/dashboard/activity.js +144 -0
- data/app/src/components/dashboard/dashboard.js +46 -0
- data/app/src/components/flash/flash.js +98 -0
- data/app/src/components/flash/flash.less +3 -0
- data/app/src/components/generic/__tests__/time-test.js +42 -0
- data/app/src/components/generic/annotations.js +39 -0
- data/app/src/components/generic/breadcrumbs.js +57 -0
- data/app/src/components/generic/foldable_audit_section.js +204 -0
- data/app/src/components/generic/list.js +141 -0
- data/app/src/components/generic/list_factory.js +41 -0
- data/app/src/components/generic/resource_link.js +64 -0
- data/app/src/components/generic/role_link.js +66 -0
- data/app/src/components/generic/tab_mixin.js +146 -0
- data/app/src/components/generic/time.js +32 -0
- data/app/src/components/graph/__tests__/collapse-test.js +133 -0
- data/app/src/components/graph/__tests__/edges-from-vertices-test.js +48 -0
- data/app/src/components/graph/__tests__/new-vertex-set-test.js +16 -0
- data/app/src/components/graph/__tests__/next-id-test.js +27 -0
- data/app/src/components/graph/__tests__/role-kind-from-id-test.js +24 -0
- data/app/src/components/graph/__tests__/vertices-from-edges-test.js +72 -0
- data/app/src/components/graph/graph.js +449 -0
- data/app/src/components/graph/graph.less +39 -0
- data/app/src/components/graph/helpers.js +368 -0
- data/app/src/components/group/list.js +3 -0
- data/app/src/components/group/view.js +153 -0
- data/app/src/components/host/activity.js +111 -0
- data/app/src/components/host/details.js +28 -0
- data/app/src/components/host/executors.js +77 -0
- data/app/src/components/host/host_link.js +18 -0
- data/app/src/components/host/list.js +3 -0
- data/app/src/components/host/updaters.js +77 -0
- data/app/src/components/host/view.js +145 -0
- data/app/src/components/layer/list.js +3 -0
- data/app/src/components/layer/view.js +197 -0
- data/app/src/components/navbar/__tests__/navbar-test.js +21 -0
- data/app/src/components/navbar/nav_search_form.js +40 -0
- data/app/src/components/navbar/navbar.js +96 -0
- data/app/src/components/notfound/notfound.js +35 -0
- data/app/src/components/notfound/notfound.less +21 -0
- data/app/src/components/owned_resources/owned_resources.js +84 -0
- data/app/src/components/owned_resources/owned_resources_box.js +101 -0
- data/app/src/components/permissions/permissions.js +138 -0
- data/app/src/components/permissions/permissions_table.js +101 -0
- data/app/src/components/policy/list.js +3 -0
- data/app/src/components/policy/view.js +107 -0
- data/app/src/components/refresh/refresh.js +29 -0
- data/app/src/components/refresh/refresh.less +15 -0
- data/app/src/components/search/group.js +43 -0
- data/app/src/components/search/group_heading.js +50 -0
- data/app/src/components/search/group_title.js +37 -0
- data/app/src/components/search/result_item.js +55 -0
- data/app/src/components/search/search.js +118 -0
- data/app/src/components/user/activity.js +112 -0
- data/app/src/components/user/details.js +30 -0
- data/app/src/components/user/list.js +3 -0
- data/app/src/components/user/pubkeys.js +118 -0
- data/app/src/components/user/pubkeys.less +56 -0
- data/app/src/components/user/view.js +143 -0
- data/app/src/components/variable/activity.js +101 -0
- data/app/src/components/variable/details.js +46 -0
- data/app/src/components/variable/fetchers.js +77 -0
- data/app/src/components/variable/list.js +3 -0
- data/app/src/components/variable/updaters.js +77 -0
- data/app/src/components/variable/view.js +115 -0
- data/app/src/constants.js +36 -0
- data/{public → app/src}/images/conjur-logo.svg +0 -0
- data/{public → app/src}/images/icon-client-pc.svg +0 -0
- data/{public → app/src}/images/icon-environment.png +0 -0
- data/{public → app/src}/images/icon-person.svg +0 -0
- data/{public → app/src}/images/icon-policy.png +0 -0
- data/{public → app/src}/images/icon-resource.png +0 -0
- data/{public → app/src}/images/icon-service-dots.svg +0 -0
- data/{public → app/src}/images/icon-variable.png +0 -0
- data/app/src/pages/index.html +27 -0
- data/app/src/routes.js +64 -0
- data/app/src/stores/app_store.js +35 -0
- data/app/src/stores/audit_store.js +143 -0
- data/app/src/stores/graph_store.js +51 -0
- data/app/src/stores/group_store.js +104 -0
- data/app/src/stores/host_store.js +111 -0
- data/app/src/stores/layer_store.js +115 -0
- data/app/src/stores/policy_store.js +88 -0
- data/app/src/stores/resources_store.js +115 -0
- data/app/src/stores/route_store.js +21 -0
- data/app/src/stores/search_store.js +77 -0
- data/app/src/stores/user_store.js +109 -0
- data/app/src/stores/variable_store.js +93 -0
- data/app/src/styles/bootstrap.less +54 -0
- data/{public/css → app/src/styles}/styles.less +26 -82
- data/app/src/utils.js +38 -0
- data/app/src/vendor/pace.js +2 -0
- data/conjur-asset-ui.gemspec +3 -4
- data/docker/assets-build/Dockerfile +12 -0
- data/docker/conjur-ui/Dockerfile +33 -0
- data/docker/conjur-ui/README.md +38 -0
- data/docker/conjur-ui/mime.types +90 -0
- data/docker/conjur-ui/nginx.conf +110 -0
- data/docker/conjur-ui/start.py +72 -0
- data/docker/conjur-ui/start.sh +18 -0
- data/docker/conjur-ui/test.env +8 -0
- data/lib/conjur-asset-ui-version.rb +1 -1
- data/lib/conjur/command/ui.rb +10 -2
- data/lib/conjur/webserver/home.rb +3 -3
- data/lib/conjur/webserver/login.rb +1 -1
- data/lib/conjur/webserver/server.rb +16 -4
- data/public/js/views/roleGraph.js +91 -0
- metadata +167 -105
- data/.jshintrc +0 -41
- data/bower.json +0 -98
- data/gulpfile.js +0 -139
- data/package.json +0 -47
- data/preprocessor.js +0 -7
- data/public/_client_libs.html +0 -9
- data/public/index.html.erb +0 -63
- data/public/js/init.js +0 -196
- data/public/js/lib/pace.js +0 -2
- data/public/js/lib/sorted-set.no-require.js +0 -1145
- data/public/js/lib/sorted-set.no-require.js.txt +0 -6
- data/public/js/models/groupRecord.js +0 -72
- data/public/js/models/hostRecord.js +0 -60
- data/public/js/models/layerRecord.js +0 -79
- data/public/js/models/namespace.js +0 -12
- data/public/js/models/policyList.js +0 -16
- data/public/js/models/policyRecord.js +0 -54
- data/public/js/models/record.js +0 -117
- data/public/js/models/resourceList.js +0 -87
- data/public/js/models/userList.js +0 -25
- data/public/js/models/userRecord.js +0 -75
- data/public/js/models/variableList.js +0 -27
- data/public/js/models/variableRecord.js +0 -77
- data/public/js/routers.js +0 -242
- data/public/js/views/annotations.js +0 -47
- data/public/js/views/audit.js +0 -369
- data/public/js/views/breadcrumbs.js +0 -62
- data/public/js/views/chart.js +0 -617
- data/public/js/views/dashboard.js +0 -146
- data/public/js/views/generic.js +0 -122
- data/public/js/views/group.js +0 -109
- data/public/js/views/groups.js +0 -26
- data/public/js/views/host.js +0 -200
- data/public/js/views/hosts.js +0 -26
- data/public/js/views/layer.js +0 -146
- data/public/js/views/layers.js +0 -26
- data/public/js/views/mixins/search.js +0 -22
- data/public/js/views/mixins/tabs.js +0 -154
- data/public/js/views/namespaces.js +0 -40
- data/public/js/views/navSearch.js +0 -36
- data/public/js/views/owned.js +0 -184
- data/public/js/views/permissions.js +0 -254
- data/public/js/views/policies.js +0 -26
- data/public/js/views/policy.js +0 -70
- data/public/js/views/resource.js +0 -59
- data/public/js/views/role.js +0 -63
- data/public/js/views/searchResults.js +0 -212
- data/public/js/views/sections.js +0 -226
- data/public/js/views/time.js +0 -39
- data/public/js/views/user.js +0 -297
- data/public/js/views/users.js +0 -26
- data/public/js/views/variable.js +0 -310
- data/public/js/views/variables.js +0 -26
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/support/jasmine.yml +0 -112
- data/spec/javascripts/support/jasmine_helper.rb +0 -22
- data/spec/javascripts/support/run.html.erb +0 -23
- data/spec/javascripts/views/AuditSpec.js +0 -22
- data/spec/javascripts/views/AuditSpec.ls +0 -18
@@ -0,0 +1,101 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
|
3
|
+
import {pluralize} from '../../utils';
|
4
|
+
import {intersection, uniq, capitalize} from 'lodash';
|
5
|
+
|
6
|
+
var ResourceLink = require('../generic/resource_link');
|
7
|
+
|
8
|
+
var knownTypes = ['user', 'group', 'layer', 'host', 'variable', 'policy'];
|
9
|
+
|
10
|
+
export default React.createClass({
|
11
|
+
displayName: 'OwnedResourcesBox',
|
12
|
+
|
13
|
+
getInitialState() {
|
14
|
+
return {
|
15
|
+
filter: ''
|
16
|
+
};
|
17
|
+
},
|
18
|
+
|
19
|
+
handleChange(e) {
|
20
|
+
e.preventDefault();
|
21
|
+
|
22
|
+
this.setState({filter: e.target.value});
|
23
|
+
},
|
24
|
+
|
25
|
+
render() {
|
26
|
+
var filters = [];
|
27
|
+
|
28
|
+
if (!this.props.resources) {
|
29
|
+
return (
|
30
|
+
<span>None</span>
|
31
|
+
);
|
32
|
+
}
|
33
|
+
|
34
|
+
var items = this.props.resources
|
35
|
+
.sort(function(a, b) {
|
36
|
+
// TODO: sort by kind with custom weights, by id, by creation date
|
37
|
+
// automatically gives sort by kind, id
|
38
|
+
return a.id.toLowerCase().localeCompare(b.id.toLowerCase());
|
39
|
+
}).map(function(resource) {
|
40
|
+
var kind = resource.id.split(':')[1];
|
41
|
+
|
42
|
+
filters.push(kind);
|
43
|
+
|
44
|
+
if ((this.state.filter === '') ||
|
45
|
+
(this.state.filter !== 'other' && this.state.filter === kind) ||
|
46
|
+
(this.state.filter === 'other' &&
|
47
|
+
intersection([kind], knownTypes).length === 0)) {
|
48
|
+
|
49
|
+
return (
|
50
|
+
<li className="list-group-item list-group-item-noborder">
|
51
|
+
<ResourceLink id={resource.id} />
|
52
|
+
</li>
|
53
|
+
);
|
54
|
+
}
|
55
|
+
|
56
|
+
return '';
|
57
|
+
}.bind(this));
|
58
|
+
|
59
|
+
var toggleButton = '';
|
60
|
+
|
61
|
+
if (!this.props.tabview) {
|
62
|
+
toggleButton = (
|
63
|
+
<div className="hide-all">
|
64
|
+
<a onClick={this.props.handler}>Hide all «</a>
|
65
|
+
</div>
|
66
|
+
);
|
67
|
+
}
|
68
|
+
|
69
|
+
var filterSelect = '';
|
70
|
+
|
71
|
+
if (this.props.resources.length > 9 || this.state.filter !== '') {
|
72
|
+
// TODO: sort, when done with previous TODO
|
73
|
+
filterSelect = intersection(uniq(filters, true), knownTypes).map(function(f) {
|
74
|
+
return (
|
75
|
+
<option value={f}>{capitalize(pluralize(f))}</option>
|
76
|
+
);
|
77
|
+
});
|
78
|
+
|
79
|
+
filterSelect = (
|
80
|
+
<div className="form-group row">
|
81
|
+
<div className="col-xs-3">
|
82
|
+
<select className="form-control" type="select" ref="filter"
|
83
|
+
value={this.state.filter} onChange={this.handleChange}>
|
84
|
+
<option value="">Show all</option>
|
85
|
+
{filterSelect}
|
86
|
+
<option value="other">Other</option>
|
87
|
+
</select>
|
88
|
+
</div>
|
89
|
+
</div>
|
90
|
+
);
|
91
|
+
}
|
92
|
+
|
93
|
+
return (
|
94
|
+
<div className="owned">
|
95
|
+
{toggleButton}
|
96
|
+
{filterSelect}
|
97
|
+
<ul className="list-group">{items}</ul>
|
98
|
+
</div>
|
99
|
+
);
|
100
|
+
}
|
101
|
+
});
|
@@ -0,0 +1,138 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
cx = require('react/lib/cx');
|
3
|
+
|
4
|
+
import {filter, pluck, includes} from 'lodash';
|
5
|
+
|
6
|
+
var PermissionsTable = require('./permissions_table');
|
7
|
+
|
8
|
+
var PermissionsSummary = React.createClass({
|
9
|
+
displayName: 'PermissionsSummary',
|
10
|
+
|
11
|
+
render() {
|
12
|
+
var expand = '';
|
13
|
+
|
14
|
+
if (this.props.length > 0) {
|
15
|
+
expand = (
|
16
|
+
<span>
|
17
|
+
<br/>
|
18
|
+
<span>
|
19
|
+
<a onClick={this.props.expandHandler}>Show all »</a>
|
20
|
+
</span>
|
21
|
+
</span>
|
22
|
+
);
|
23
|
+
}
|
24
|
+
|
25
|
+
return (
|
26
|
+
<div>
|
27
|
+
<span>
|
28
|
+
{this.props.length} permissions
|
29
|
+
</span>
|
30
|
+
{expand}
|
31
|
+
</div>
|
32
|
+
);
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
export default React.createClass({
|
37
|
+
displayName: 'Permissions',
|
38
|
+
|
39
|
+
getDefaultProps() {
|
40
|
+
return {
|
41
|
+
resources: [],
|
42
|
+
roles: []
|
43
|
+
};
|
44
|
+
},
|
45
|
+
|
46
|
+
getInitialState() {
|
47
|
+
return {
|
48
|
+
expand: false
|
49
|
+
};
|
50
|
+
},
|
51
|
+
|
52
|
+
expand() {
|
53
|
+
this.setState({expand: true});
|
54
|
+
},
|
55
|
+
|
56
|
+
collapse() {
|
57
|
+
this.setState({expand: false});
|
58
|
+
},
|
59
|
+
|
60
|
+
setPermissions(_resources) {
|
61
|
+
/**
|
62
|
+
* Filter out owned resources.
|
63
|
+
* Filter out permissions on resources which are not held by the current role.
|
64
|
+
*/
|
65
|
+
var resources;
|
66
|
+
|
67
|
+
if (this.props.owned) {
|
68
|
+
var ownedIds = pluck(this.props.owned, 'id');
|
69
|
+
|
70
|
+
resources = filter(_resources, function(r) {
|
71
|
+
return !includes(ownedIds, r.id);
|
72
|
+
});
|
73
|
+
} else {
|
74
|
+
resources = _resources;
|
75
|
+
}
|
76
|
+
|
77
|
+
var roleSet = {};
|
78
|
+
|
79
|
+
this.props.roles.forEach(function(r) {
|
80
|
+
roleSet[r] = r;
|
81
|
+
});
|
82
|
+
|
83
|
+
var cleanResources = filter(resources, function(item) {
|
84
|
+
// assets of 'secret' kind are internal
|
85
|
+
return item.id.split(':')[1] !== 'secret';
|
86
|
+
});
|
87
|
+
|
88
|
+
cleanResources.forEach(function(resource) {
|
89
|
+
var permissions = resource.permissions,
|
90
|
+
hasPermissions = [];
|
91
|
+
|
92
|
+
permissions.forEach(function(permission) {
|
93
|
+
if (roleSet.hasOwnProperty(permission.role)) {
|
94
|
+
hasPermissions.push(permission);
|
95
|
+
}
|
96
|
+
});
|
97
|
+
|
98
|
+
resource.permissions = hasPermissions;
|
99
|
+
});
|
100
|
+
|
101
|
+
return cleanResources;
|
102
|
+
},
|
103
|
+
|
104
|
+
render() {
|
105
|
+
var resources = this.setPermissions(this.props.resources);
|
106
|
+
|
107
|
+
var content;
|
108
|
+
|
109
|
+
if (this.state.expand || this.props.tabview) {
|
110
|
+
content = (
|
111
|
+
<PermissionsTable resources={resources}
|
112
|
+
hideHandler={this.collapse}
|
113
|
+
tabview={this.props.tabview} />
|
114
|
+
);
|
115
|
+
} else {
|
116
|
+
content = (
|
117
|
+
<PermissionsSummary length={this.state.resources.length}
|
118
|
+
expandHandler={this.expand} />
|
119
|
+
);
|
120
|
+
}
|
121
|
+
|
122
|
+
var classes = cx({
|
123
|
+
permissions: true,
|
124
|
+
loading: false
|
125
|
+
});
|
126
|
+
|
127
|
+
var permissionsheader = this.props.tabview ? '' : (<h3>Permissions held</h3>);
|
128
|
+
|
129
|
+
return (
|
130
|
+
<section className={classes}>
|
131
|
+
{permissionsheader}
|
132
|
+
<div id="permissionDetails">
|
133
|
+
{content}
|
134
|
+
</div>
|
135
|
+
</section>
|
136
|
+
);
|
137
|
+
}
|
138
|
+
});
|
@@ -0,0 +1,101 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
|
3
|
+
var ResourceLink = require('../generic/resource_link'),
|
4
|
+
RoleLink = require('../generic/role_link');
|
5
|
+
|
6
|
+
import {sortBy, flatten} from 'lodash';
|
7
|
+
|
8
|
+
// Renders a permission as a tr
|
9
|
+
var PermissionRow = React.createClass({
|
10
|
+
displayName: 'PermissionRow',
|
11
|
+
|
12
|
+
render() {
|
13
|
+
var p = this.props.data;
|
14
|
+
|
15
|
+
return (
|
16
|
+
<tr>
|
17
|
+
<td>{p.privilege}</td>
|
18
|
+
<td>{p.grant_option ? 'yes' : 'no'}</td>
|
19
|
+
<td><RoleLink id={p.grantor}/></td>
|
20
|
+
</tr>
|
21
|
+
);
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
export default React.createClass({
|
26
|
+
displayName: 'PermissionsTable',
|
27
|
+
|
28
|
+
render() {
|
29
|
+
var rows = [];
|
30
|
+
|
31
|
+
var resources = sortBy(this.props.resources, function(r) {
|
32
|
+
return r.id; // this way it will be sorting by (kind, id)
|
33
|
+
});
|
34
|
+
|
35
|
+
resources.forEach(function(r) {
|
36
|
+
var rowspan = r.permissions.length + 1,
|
37
|
+
parts = r.id.split(':'),
|
38
|
+
kind = parts[1]; // ignore env?
|
39
|
+
|
40
|
+
var cells = [
|
41
|
+
(<td rowSpan={rowspan}> <ResourceLink id={r.id}/> </td>),
|
42
|
+
(<td rowSpan={rowspan}> {kind} </td>)
|
43
|
+
];
|
44
|
+
|
45
|
+
if (rowspan === 1) {
|
46
|
+
cells.push(<td colSpan="3"> full permissions </td>);
|
47
|
+
}
|
48
|
+
|
49
|
+
rows.push(
|
50
|
+
(<tr key={r.id}>{cells}</tr>)
|
51
|
+
);
|
52
|
+
|
53
|
+
if (rowspan > 1) {
|
54
|
+
rows.push(r.permissions.map(function(p) {
|
55
|
+
return (
|
56
|
+
<PermissionRow data={p} />
|
57
|
+
);
|
58
|
+
}));
|
59
|
+
}
|
60
|
+
|
61
|
+
});
|
62
|
+
|
63
|
+
rows = flatten(rows);
|
64
|
+
|
65
|
+
var showhidelink = (
|
66
|
+
<div>
|
67
|
+
<a onClick={this.props.hideHandler}>Hide all «</a>
|
68
|
+
</div>
|
69
|
+
);
|
70
|
+
|
71
|
+
if (this.props.tabview) {
|
72
|
+
showhidelink = '';
|
73
|
+
}
|
74
|
+
|
75
|
+
if (rows.length === 0) {
|
76
|
+
return (
|
77
|
+
<span>None</span>
|
78
|
+
);
|
79
|
+
}
|
80
|
+
|
81
|
+
return (
|
82
|
+
<div>
|
83
|
+
{showhidelink}
|
84
|
+
<table>
|
85
|
+
<thead>
|
86
|
+
<tr>
|
87
|
+
<th> Resource </th>
|
88
|
+
<th> Kind </th>
|
89
|
+
<th> Privilege </th>
|
90
|
+
<th> Can Grant? </th>
|
91
|
+
<th> Granted By </th>
|
92
|
+
</tr>
|
93
|
+
</thead>
|
94
|
+
<tbody>
|
95
|
+
{rows}
|
96
|
+
</tbody>
|
97
|
+
</table>
|
98
|
+
</div>
|
99
|
+
);
|
100
|
+
}
|
101
|
+
});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Fluxxor = require('fluxxor');
|
3
|
+
|
4
|
+
import {compact} from 'lodash';
|
5
|
+
|
6
|
+
var FluxMixin = Fluxxor.FluxMixin(React),
|
7
|
+
StoreWatchMixin = Fluxxor.StoreWatchMixin;
|
8
|
+
|
9
|
+
var TabbedArea = require('react-bootstrap/lib/TabbedArea'),
|
10
|
+
TabPane = require('react-bootstrap/lib/TabPane');
|
11
|
+
|
12
|
+
var TabMixin = require('../generic/tab_mixin'),
|
13
|
+
RoleLink = require('../generic/role_link'),
|
14
|
+
AuditTable = require('../audit/table');
|
15
|
+
|
16
|
+
export default React.createClass({
|
17
|
+
displayName: 'PolicyView',
|
18
|
+
|
19
|
+
mixins: [FluxMixin, StoreWatchMixin('policy', 'route'), TabMixin],
|
20
|
+
|
21
|
+
askForNewData(state) {
|
22
|
+
var actions = this.getFlux().actions;
|
23
|
+
|
24
|
+
actions.policy.load(state.id);
|
25
|
+
actions.resources.loadOne('policy', state.id);
|
26
|
+
},
|
27
|
+
|
28
|
+
componentDidMount() {
|
29
|
+
this.askForNewData(this.state);
|
30
|
+
},
|
31
|
+
|
32
|
+
componentWillUpdate(nextProps, nextState) {
|
33
|
+
if (this.state.id !== nextState.id) {
|
34
|
+
this.askForNewData(nextState);
|
35
|
+
}
|
36
|
+
|
37
|
+
return true;
|
38
|
+
},
|
39
|
+
|
40
|
+
getStateFromFlux() {
|
41
|
+
var flux = this.getFlux(),
|
42
|
+
id = flux.store('route').getParam('id'),
|
43
|
+
data = flux.store('policy').getData(),
|
44
|
+
resource = flux.store('resources').getResource('policy', id);
|
45
|
+
|
46
|
+
var ret = {
|
47
|
+
id: id,
|
48
|
+
loading: data.loading,
|
49
|
+
resource: resource.data,
|
50
|
+
owner: resource.data.owner,
|
51
|
+
annotations: resource.data.annotations,
|
52
|
+
owned: data.owned,
|
53
|
+
roles: data.roles,
|
54
|
+
resources: data.resources
|
55
|
+
};
|
56
|
+
|
57
|
+
ret.loading.resource = resource.loading;
|
58
|
+
ret.loading.owner = resource.loading;
|
59
|
+
ret.loading.annotations = resource.loading;
|
60
|
+
|
61
|
+
return ret;
|
62
|
+
},
|
63
|
+
|
64
|
+
render() {
|
65
|
+
//TODO: policy loader
|
66
|
+
//TODO in CLI: why not save text of policy as an annotation?
|
67
|
+
var overviewTab = (
|
68
|
+
<TabPane eventKey="overview" tab="Overview">
|
69
|
+
<dl className="dl-horizontal">
|
70
|
+
<dt>Owner</dt>
|
71
|
+
<dd><RoleLink id={this.state.owner} /></dd>
|
72
|
+
</dl>
|
73
|
+
</TabPane>
|
74
|
+
);
|
75
|
+
|
76
|
+
var permissionsTab = this.permissionsTab(this.state.resource.id),
|
77
|
+
membershipsTab = this.membershipsTab(this.state.resource.id),
|
78
|
+
annotationsTab = this.annotationsTab(),
|
79
|
+
ownedTab = this.ownedTab();
|
80
|
+
|
81
|
+
var auditTab = (
|
82
|
+
<TabPane eventKey="audit" tab="Recent Activity">
|
83
|
+
<div className="audit auditGroup">
|
84
|
+
<AuditTable roles={[this.state.resource.id]} tabview={true} />
|
85
|
+
</div>
|
86
|
+
</TabPane>
|
87
|
+
);
|
88
|
+
|
89
|
+
var tabs = compact([
|
90
|
+
overviewTab,
|
91
|
+
ownedTab,
|
92
|
+
membershipsTab,
|
93
|
+
permissionsTab,
|
94
|
+
annotationsTab,
|
95
|
+
auditTab
|
96
|
+
]);
|
97
|
+
|
98
|
+
return (
|
99
|
+
<div className="policy">
|
100
|
+
<h2>Policy {this.state.resource.identifier}</h2>
|
101
|
+
<TabbedArea defaultActiveKey="overview">
|
102
|
+
{tabs}
|
103
|
+
</TabbedArea>
|
104
|
+
</div>
|
105
|
+
);
|
106
|
+
}
|
107
|
+
});
|