conjur-asset-ui-beta 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.git-hooks/pre_commit/trailing_whitespace.rb +26 -0
- data/.gitignore +23 -0
- data/.project +18 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +76 -0
- data/TODO.md +31 -0
- data/app/.csscomb.json +304 -0
- data/app/.jshintrc +46 -0
- data/app/build/css/bootstrap.css +6906 -0
- data/app/build/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/build/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/build/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/build/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/build/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/build/images/conjur-logo.svg +26 -0
- data/app/build/images/icon-client-pc.svg +12 -0
- data/app/build/images/icon-environment.png +0 -0
- data/app/build/images/icon-person.svg +12 -0
- data/app/build/images/icon-policy.png +0 -0
- data/app/build/images/icon-resource.png +0 -0
- data/app/build/images/icon-service-dots.svg +13 -0
- data/app/build/images/icon-variable.png +0 -0
- data/app/build/index.html +26 -0
- data/app/build/js/app.js +78070 -0
- data/app/build/js/pace.js +2 -0
- data/app/config/preprocessor.js +9 -0
- data/app/config/webpack.js +84 -0
- data/app/gulpfile.js +144 -0
- data/app/package.json +83 -0
- data/app/src/actions.js +493 -0
- data/app/src/app.js +76 -0
- data/app/src/clients/audit.js +54 -0
- data/app/src/clients/generic.js +87 -0
- data/app/src/clients/layer_members.js +36 -0
- data/app/src/clients/list.js +82 -0
- data/app/src/clients/members.js +37 -0
- data/app/src/clients/search.js +19 -0
- data/app/src/components/app/__tests__/app-test.js +22 -0
- data/app/src/components/app/app.js +66 -0
- data/app/src/components/audit/__tests__/table_header-test.js +40 -0
- data/app/src/components/audit/box.js +11 -0
- data/app/src/components/audit/constants.js +7 -0
- data/app/src/components/audit/entry.js +107 -0
- data/app/src/components/audit/fields_mixin.js +13 -0
- data/app/src/components/audit/humanize_event.js +216 -0
- data/app/src/components/audit/table.js +100 -0
- data/app/src/components/audit/table_header.js +38 -0
- data/app/src/components/audit/timestamp.js +30 -0
- data/app/src/components/chart/chart.js +539 -0
- data/app/src/components/chart/chart_helper_mixin.js +79 -0
- data/app/src/components/custom/list.js +5 -0
- data/app/src/components/custom/view.js +71 -0
- data/app/src/components/dashboard/activity.js +113 -0
- data/app/src/components/dashboard/dashboard.js +47 -0
- data/app/src/components/flash/flash.js +17 -0
- data/app/src/components/generic/__tests__/time-test.js +43 -0
- data/app/src/components/generic/annotations.js +41 -0
- data/app/src/components/generic/breadcrumbs.js +59 -0
- data/app/src/components/generic/foldable_audit_section.js +252 -0
- data/app/src/components/generic/list.js +144 -0
- data/app/src/components/generic/list_factory.js +42 -0
- data/app/src/components/generic/resource_link.js +65 -0
- data/app/src/components/generic/role_link.js +65 -0
- data/app/src/components/generic/tab_mixin.js +148 -0
- data/app/src/components/generic/time.js +34 -0
- data/app/src/components/group/list.js +5 -0
- data/app/src/components/group/view.js +137 -0
- data/app/src/components/host/activity.js +93 -0
- data/app/src/components/host/details.js +30 -0
- data/app/src/components/host/host_link.js +20 -0
- data/app/src/components/host/list.js +5 -0
- data/app/src/components/host/view.js +113 -0
- data/app/src/components/layer/list.js +5 -0
- data/app/src/components/layer/view.js +180 -0
- data/app/src/components/navbar/__tests__/navbar-test.js +21 -0
- data/app/src/components/navbar/nav_search_form.js +41 -0
- data/app/src/components/navbar/navbar.js +71 -0
- data/app/src/components/owned_resources/owned_resources.js +86 -0
- data/app/src/components/owned_resources/owned_resources_box.js +106 -0
- data/app/src/components/permissions/permissions.js +143 -0
- data/app/src/components/permissions/permissions_table.js +104 -0
- data/app/src/components/policy/list.js +5 -0
- data/app/src/components/policy/view.js +98 -0
- data/app/src/components/refresh/refresh.js +30 -0
- data/app/src/components/refresh/refresh.less +15 -0
- data/app/src/components/search/group.js +45 -0
- data/app/src/components/search/group_heading.js +50 -0
- data/app/src/components/search/group_title.js +38 -0
- data/app/src/components/search/result_item.js +57 -0
- data/app/src/components/search/search.js +103 -0
- data/app/src/components/user/activity.js +92 -0
- data/app/src/components/user/details.js +30 -0
- data/app/src/components/user/list.js +5 -0
- data/app/src/components/user/pubkeys.js +116 -0
- data/app/src/components/user/pubkeys.less +56 -0
- data/app/src/components/user/view.js +123 -0
- data/app/src/components/variable/activity.js +83 -0
- data/app/src/components/variable/details.js +48 -0
- data/app/src/components/variable/fetchers.js +83 -0
- data/app/src/components/variable/list.js +5 -0
- data/app/src/components/variable/updaters.js +83 -0
- data/app/src/components/variable/view.js +105 -0
- data/app/src/constants.js +35 -0
- data/app/src/images/conjur-logo.svg +26 -0
- data/app/src/images/icon-client-pc.svg +12 -0
- data/app/src/images/icon-environment.png +0 -0
- data/app/src/images/icon-person.svg +12 -0
- data/app/src/images/icon-policy.png +0 -0
- data/app/src/images/icon-resource.png +0 -0
- data/app/src/images/icon-service-dots.svg +13 -0
- data/app/src/images/icon-variable.png +0 -0
- data/app/src/pages/index.html +26 -0
- data/app/src/routes.js +57 -0
- data/app/src/stores/app_store.js +29 -0
- data/app/src/stores/audit_store.js +77 -0
- data/app/src/stores/group_store.js +105 -0
- data/app/src/stores/host_store.js +98 -0
- data/app/src/stores/layer_store.js +115 -0
- data/app/src/stores/policy_store.js +89 -0
- data/app/src/stores/resources_store.js +118 -0
- data/app/src/stores/route_store.js +24 -0
- data/app/src/stores/search_store.js +73 -0
- data/app/src/stores/user_store.js +111 -0
- data/app/src/stores/variable_store.js +94 -0
- data/app/src/styles/bootstrap.less +56 -0
- data/app/src/styles/styles.less +634 -0
- data/app/src/utils.js +43 -0
- data/app/src/vendor/pace.js +2 -0
- data/conjur-asset-ui.gemspec +36 -0
- data/features/navigation_bar.feature +31 -0
- data/features/step_definitions/custom_step.rb +32 -0
- data/features/support/env.rb +38 -0
- data/features/support/hooks.rb +30 -0
- data/features/support/world.rb +17 -0
- data/lib/conjur-asset-ui-version.rb +7 -0
- data/lib/conjur-asset-ui.rb +7 -0
- data/lib/conjur/command/ui.rb +54 -0
- data/lib/conjur/webserver/api_proxy.rb +94 -0
- data/lib/conjur/webserver/authorize.rb +28 -0
- data/lib/conjur/webserver/conjur_info.rb +33 -0
- data/lib/conjur/webserver/home.rb +42 -0
- data/lib/conjur/webserver/login.rb +57 -0
- data/lib/conjur/webserver/renderer.rb +34 -0
- data/lib/conjur/webserver/server.rb +130 -0
- data/public/js/views/roleGraph.js +91 -0
- metadata +373 -0
@@ -0,0 +1,252 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var React = require('react'),
|
4
|
+
filter = require('lodash/collection/filter'),
|
5
|
+
take = require('lodash/array/take'),
|
6
|
+
map = require('lodash/collection/map'),
|
7
|
+
includes = require('lodash/collection/includes'),
|
8
|
+
isString = require('lodash/lang/isString');
|
9
|
+
|
10
|
+
var defaultNumberOfElements = 3;
|
11
|
+
|
12
|
+
// TODO: refactor to avoid this copypaste from audit.js
|
13
|
+
var knownRolsourceTypes = ['user', 'group', 'host', 'layer', 'policy'];
|
14
|
+
|
15
|
+
var AuditEntry = require('../audit/entry'),
|
16
|
+
ResourceLink = require('./resource_link'),
|
17
|
+
Time = require('./time'),
|
18
|
+
Refresh = require('../refresh/refresh');
|
19
|
+
|
20
|
+
var FoldableAuditSection = React.createClass({
|
21
|
+
displayName: 'FoldableAuditSection',
|
22
|
+
|
23
|
+
statics: {
|
24
|
+
updates(audit, isLoading) {
|
25
|
+
isLoading = isLoading || false;
|
26
|
+
|
27
|
+
var filter = function(e) {
|
28
|
+
return (
|
29
|
+
e.action === 'check' && e.privilege === 'update' &&
|
30
|
+
!(e.hasOwnProperty('error') ||
|
31
|
+
e.allowed === false)
|
32
|
+
);
|
33
|
+
};
|
34
|
+
|
35
|
+
var getItem = function(e) {
|
36
|
+
var user = [
|
37
|
+
(<Time timestamp={e.timestamp} relative="time from now" />),
|
38
|
+
(<ResourceLink id={e.user} />)
|
39
|
+
];
|
40
|
+
|
41
|
+
if (e.user !== e.acting_as) {
|
42
|
+
user.push(' acting as ');
|
43
|
+
user.push(<ResourceLink id={e.acting_as} />);
|
44
|
+
}
|
45
|
+
|
46
|
+
return user;
|
47
|
+
};
|
48
|
+
|
49
|
+
return (
|
50
|
+
<FoldableAuditSection audit={audit} title="Updates"
|
51
|
+
filter={filter} getItem={getItem}
|
52
|
+
openMsg="See full updates history"
|
53
|
+
isLoading={isLoading} />
|
54
|
+
);
|
55
|
+
},
|
56
|
+
|
57
|
+
warnings(audit, isLoading) {
|
58
|
+
isLoading = isLoading || false;
|
59
|
+
|
60
|
+
var filter = function(e) {
|
61
|
+
return (
|
62
|
+
e.hasOwnProperty('error') || e.allowed === false
|
63
|
+
);
|
64
|
+
};
|
65
|
+
|
66
|
+
var getItem = function(e) {
|
67
|
+
return AuditEntry(e);
|
68
|
+
};
|
69
|
+
|
70
|
+
return (
|
71
|
+
<FoldableAuditSection audit={audit} title="Warnings"
|
72
|
+
filter={filter} getItem={getItem}
|
73
|
+
openMsg="See full warnings history"
|
74
|
+
isLoading={isLoading} />
|
75
|
+
);
|
76
|
+
},
|
77
|
+
|
78
|
+
changes(audit, isLoading) {
|
79
|
+
isLoading = isLoading || false;
|
80
|
+
|
81
|
+
var filter = function(e) {
|
82
|
+
|
83
|
+
if (e.action === 'check') {
|
84
|
+
return false;
|
85
|
+
}
|
86
|
+
|
87
|
+
if (e.kind === 'audit' || e.kind === 'annotation') {
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
|
91
|
+
// TODO: refactor code to avoid copypaste from audit.js
|
92
|
+
// remove internal resources creation
|
93
|
+
if (isString(e.role) && (e.role.split(':')[1] === '@')) {
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (isString(e.resource) && (e.resource.split(':')[1] === '@')) {
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (isString(e.resource) && (e.resource.split(':')[1] === 'secret')) {
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
|
105
|
+
if (isString(e.grantee) && (e.grantee.split(':')[1] === '@')) {
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
|
109
|
+
// hide automated creation of roles corresponding to resources of known type
|
110
|
+
if ((e.kind === 'role') && (e.action === 'create')) {
|
111
|
+
var rolekind = e.role.split(':')[1];
|
112
|
+
|
113
|
+
if (includes(knownRolsourceTypes, rolekind)) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
// anything else is permission change
|
119
|
+
return true;
|
120
|
+
};
|
121
|
+
|
122
|
+
var getItem = function(e) {
|
123
|
+
return AuditEntry(e);
|
124
|
+
};
|
125
|
+
|
126
|
+
return (
|
127
|
+
<FoldableAuditSection audit={audit} title="Recent permission model changes"
|
128
|
+
filter={filter} getItem={getItem}
|
129
|
+
openMsg="See full history of permission model changes"
|
130
|
+
isLoading={isLoading} />
|
131
|
+
);
|
132
|
+
}
|
133
|
+
},
|
134
|
+
|
135
|
+
propTypes: {
|
136
|
+
audit: React.PropTypes.arrayOf(React.PropTypes.object),
|
137
|
+
filter: React.PropTypes.func,
|
138
|
+
getItem: React.PropTypes.func,
|
139
|
+
howMuch: React.PropTypes.number,
|
140
|
+
title: React.PropTypes.string,
|
141
|
+
openMsg: React.PropTypes.string,
|
142
|
+
isLoading: React.PropTypes.bool
|
143
|
+
},
|
144
|
+
|
145
|
+
defaultFilter(e) {
|
146
|
+
return typeof e === 'object';
|
147
|
+
},
|
148
|
+
|
149
|
+
defaultGetItem(e) {
|
150
|
+
return e.id;
|
151
|
+
},
|
152
|
+
|
153
|
+
getDefaultProps() {
|
154
|
+
return {
|
155
|
+
audit: [],
|
156
|
+
filter: this.defaultFilter,
|
157
|
+
getItem: this.defaultGetItem,
|
158
|
+
howMuch: defaultNumberOfElements,
|
159
|
+
title: 'Audit Section',
|
160
|
+
openMsg: 'See full history',
|
161
|
+
isLoading: false
|
162
|
+
};
|
163
|
+
},
|
164
|
+
|
165
|
+
getInitialState() {
|
166
|
+
return {showAll: false};
|
167
|
+
},
|
168
|
+
|
169
|
+
handleClick(e) {
|
170
|
+
e.preventDefault();
|
171
|
+
|
172
|
+
this.setState({showAll: !this.state.showAll});
|
173
|
+
},
|
174
|
+
|
175
|
+
reverseChronology(a, b) {
|
176
|
+
if (a.timestamp < b.timestamp) {
|
177
|
+
return 1;
|
178
|
+
} else if (a.timestamp > b.timestamp) {
|
179
|
+
return -1;
|
180
|
+
} else {
|
181
|
+
return 0;
|
182
|
+
}
|
183
|
+
},
|
184
|
+
|
185
|
+
getItems() {
|
186
|
+
var items = filter(this.props.audit,
|
187
|
+
this.props.filter)
|
188
|
+
.sort(this.reverseChronology),
|
189
|
+
className = [
|
190
|
+
'b-audit-section__item',
|
191
|
+
'list-group-item',
|
192
|
+
'list-group-item-noborder'
|
193
|
+
].join(' ');
|
194
|
+
|
195
|
+
if (!this.state.showAll) {
|
196
|
+
items = take(items, this.props.howMuch);
|
197
|
+
}
|
198
|
+
|
199
|
+
return map(items, function(e) {
|
200
|
+
return (
|
201
|
+
<li className={className}
|
202
|
+
key={'audit-entry-' + e.id}>
|
203
|
+
{this.props.getItem(e)}
|
204
|
+
</li>
|
205
|
+
);
|
206
|
+
}.bind(this));
|
207
|
+
},
|
208
|
+
|
209
|
+
render() {
|
210
|
+
var items = this.getItems(),
|
211
|
+
msg = this.state.showAll ?
|
212
|
+
'Show only top ' + (this.props.howMuch) :
|
213
|
+
this.props.openMsg,
|
214
|
+
empty = items.length === 0,
|
215
|
+
lessThan = items.length < (this.props.howMuch),
|
216
|
+
body = [
|
217
|
+
<h2 key="title">
|
218
|
+
{this.props.title}<Refresh show={this.props.isLoading} />
|
219
|
+
</h2>
|
220
|
+
];
|
221
|
+
|
222
|
+
if (!empty) {
|
223
|
+
body.push(
|
224
|
+
<ul className="b-audit-section__list list-unstyled list-group"
|
225
|
+
key="list">
|
226
|
+
{items}
|
227
|
+
</ul>
|
228
|
+
);
|
229
|
+
} else {
|
230
|
+
body.push(
|
231
|
+
<p key="info">There is no history records available</p>
|
232
|
+
);
|
233
|
+
}
|
234
|
+
|
235
|
+
if (!lessThan) {
|
236
|
+
body.push(
|
237
|
+
<div className="b-audit-section__toggle"
|
238
|
+
key="toggle">
|
239
|
+
<a href="#" onClick={this.handleClick}>{msg}</a>
|
240
|
+
</div>
|
241
|
+
);
|
242
|
+
}
|
243
|
+
|
244
|
+
return (
|
245
|
+
<div className="b-audit-section">
|
246
|
+
{body}
|
247
|
+
</div>
|
248
|
+
);
|
249
|
+
}
|
250
|
+
});
|
251
|
+
|
252
|
+
module.exports = FoldableAuditSection;
|
@@ -0,0 +1,144 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var React = require('react'),
|
4
|
+
Link = require('react-router').Link,
|
5
|
+
sortBy = require('lodash/collection/sortBy'),
|
6
|
+
capitalize = require('lodash/string/capitalize'),
|
7
|
+
values = require('lodash/object/values');
|
8
|
+
|
9
|
+
var RoleLink = require('./role_link');
|
10
|
+
|
11
|
+
var CustomTypeListItem = React.createClass({
|
12
|
+
display: 'CustomTypeListItem',
|
13
|
+
|
14
|
+
render() {
|
15
|
+
var kind = window.encodeURIComponent(this.props.data.record.kind),
|
16
|
+
id = window.encodeURIComponent(this.props.data.record.identifier),
|
17
|
+
label = this.props.data.record.kind + ':' + this.props.data.record.identifier;
|
18
|
+
|
19
|
+
return (
|
20
|
+
<tr>
|
21
|
+
<td className="id">
|
22
|
+
<Link to={this.props.data.kind}
|
23
|
+
params={{kind: kind, id: id}}>
|
24
|
+
{label}
|
25
|
+
</Link>
|
26
|
+
</td>
|
27
|
+
<td className="ownerId">
|
28
|
+
<RoleLink id={this.props.data.record.ownerid || this.props.data.record.owner} />
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
|
35
|
+
var GenericListItem = React.createClass({
|
36
|
+
display: 'GenericListItem',
|
37
|
+
|
38
|
+
render() {
|
39
|
+
return (
|
40
|
+
<tr>
|
41
|
+
<td className="id">
|
42
|
+
<Link to={this.props.data.kind}
|
43
|
+
params={{id: window.encodeURIComponent(this.props.data.record.identifier)}}>
|
44
|
+
{this.props.data.record.identifier}
|
45
|
+
</Link>
|
46
|
+
</td>
|
47
|
+
<td className="ownerId">
|
48
|
+
<RoleLink id={this.props.data.record.ownerid || this.props.data.record.owner} />
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
|
55
|
+
module.exports = React.createClass({
|
56
|
+
displayName: 'GenericList',
|
57
|
+
|
58
|
+
getInitialState() {
|
59
|
+
return {
|
60
|
+
sort: {
|
61
|
+
column: this.props.defaultColumn || 'id',
|
62
|
+
order: this.props.defaultOrder || 'asc'
|
63
|
+
},
|
64
|
+
columns: this.props.columns || {
|
65
|
+
id: {
|
66
|
+
id: 'id',
|
67
|
+
name: 'Id',
|
68
|
+
defaultSortOrder: 'desc'
|
69
|
+
},
|
70
|
+
owner: {
|
71
|
+
id: 'owner',
|
72
|
+
name: 'Owner',
|
73
|
+
defaultSortOrder: 'desc'
|
74
|
+
}
|
75
|
+
}
|
76
|
+
};
|
77
|
+
},
|
78
|
+
|
79
|
+
sortColumn(column) {
|
80
|
+
return function(e) {
|
81
|
+
e.preventDefault();
|
82
|
+
|
83
|
+
var order = (this.state.sort.order === 'asc') ? 'desc' : 'asc';
|
84
|
+
|
85
|
+
if (this.state.sort.column !== column) {
|
86
|
+
order = this.state.columns[column].defaultSortOrder;
|
87
|
+
}
|
88
|
+
|
89
|
+
this.setState({sort: {column: column, order: order}});
|
90
|
+
}.bind(this);
|
91
|
+
},
|
92
|
+
|
93
|
+
sortClass(column) {
|
94
|
+
var order = (this.state.sort.order === 'asc') ?
|
95
|
+
'glyphicon glyphicon-chevron-up' : 'glyphicon glyphicon-chevron-down';
|
96
|
+
|
97
|
+
return (this.state.sort.column === column) ? order : '';
|
98
|
+
},
|
99
|
+
|
100
|
+
render() {
|
101
|
+
var items = this.props.data.members.map(function(o) {
|
102
|
+
return o;
|
103
|
+
});
|
104
|
+
|
105
|
+
items = sortBy(items, this.state.sort.column);
|
106
|
+
|
107
|
+
if (this.state.sort.order === 'desc') {
|
108
|
+
items.reverse();
|
109
|
+
}
|
110
|
+
|
111
|
+
var rows = items.map(function (o) {
|
112
|
+
if (this.props.data.kind === 'custom-type') {
|
113
|
+
return (
|
114
|
+
<CustomTypeListItem data={{kind: this.props.data.kind, record: o}} key={o.id} />
|
115
|
+
);
|
116
|
+
}
|
117
|
+
|
118
|
+
return (
|
119
|
+
<GenericListItem data={{kind: this.props.data.kind, record: o}} key={o.id} />
|
120
|
+
);
|
121
|
+
}.bind(this));
|
122
|
+
|
123
|
+
var columns = values(this.state.columns).map(function(c) {
|
124
|
+
return (
|
125
|
+
<th onClick={this.sortColumn(c.id)} key={c.id} >
|
126
|
+
{c.name}<span className={'header ' + this.sortClass(c.id)} />
|
127
|
+
</th>
|
128
|
+
);
|
129
|
+
}, this);
|
130
|
+
|
131
|
+
return (
|
132
|
+
<table className={this.props.data.kind + 'List'}>
|
133
|
+
<thead>
|
134
|
+
<tr>
|
135
|
+
{columns}
|
136
|
+
</tr>
|
137
|
+
</thead>
|
138
|
+
<tbody>
|
139
|
+
{rows}
|
140
|
+
</tbody>
|
141
|
+
</table>
|
142
|
+
);
|
143
|
+
}
|
144
|
+
});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var React = require('react'),
|
4
|
+
Fluxxor = require('fluxxor'),
|
5
|
+
FluxMixin = Fluxxor.FluxMixin(React),
|
6
|
+
StoreWatchMixin = Fluxxor.StoreWatchMixin;
|
7
|
+
|
8
|
+
var GenericList = require('./list'),
|
9
|
+
Refresh = require('../refresh/refresh');
|
10
|
+
|
11
|
+
module.exports = function(kind, title) {
|
12
|
+
return React.createClass({
|
13
|
+
displayName: title + 'List',
|
14
|
+
|
15
|
+
mixins: [FluxMixin, StoreWatchMixin('resources')],
|
16
|
+
|
17
|
+
getStateFromFlux() {
|
18
|
+
var resources = this.getFlux().store('resources').getResources(kind);
|
19
|
+
|
20
|
+
return {
|
21
|
+
loading: resources.loading,
|
22
|
+
error: resources.error,
|
23
|
+
resources: resources.data
|
24
|
+
};
|
25
|
+
},
|
26
|
+
|
27
|
+
render() {
|
28
|
+
return (
|
29
|
+
<div className="variableBox">
|
30
|
+
<div className="variableList">
|
31
|
+
<h2>{title}<Refresh show={this.state.loading} /></h2>
|
32
|
+
<GenericList data={{kind: kind, members: this.state.resources}} />
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
);
|
36
|
+
},
|
37
|
+
|
38
|
+
componentDidMount() {
|
39
|
+
this.getFlux().actions.resources.load(kind);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var React = require('react'),
|
4
|
+
Link = require('react-router').Link,
|
5
|
+
includes = require('lodash/collection/includes');
|
6
|
+
|
7
|
+
/**
|
8
|
+
Renders a link to the resource with id given by this.props.data.
|
9
|
+
|
10
|
+
Includes a slick little icon for the following kinds:
|
11
|
+
TODO which kinds?
|
12
|
+
**/
|
13
|
+
module.exports = React.createClass({
|
14
|
+
displayName: 'ResourceLink',
|
15
|
+
|
16
|
+
knownTypes: ['user', 'group', 'layer', 'host', 'variable', 'policy'],
|
17
|
+
|
18
|
+
render() {
|
19
|
+
var resourceId = this.props.id;
|
20
|
+
|
21
|
+
// guard against misuse such as https://github.com/conjurinc/conjur-asset-ui/issues/78
|
22
|
+
if (resourceId === undefined) {
|
23
|
+
return (
|
24
|
+
<em>undefined</em>
|
25
|
+
);
|
26
|
+
}
|
27
|
+
|
28
|
+
var tokens = resourceId.split(':'),
|
29
|
+
kind = tokens[1],
|
30
|
+
id = tokens[tokens.length - 1],
|
31
|
+
text = this.props.text || id;
|
32
|
+
|
33
|
+
var resourceIsKnown = includes(this.knownTypes, kind),
|
34
|
+
classes = ['resource-link'];
|
35
|
+
|
36
|
+
if (!this.props.noIcon) {
|
37
|
+
if (resourceIsKnown) {
|
38
|
+
classes.push(kind);
|
39
|
+
} else {
|
40
|
+
classes.push('abstract');
|
41
|
+
|
42
|
+
if (text === id) {
|
43
|
+
text = [kind, text].join(':'); // prepend kind to id
|
44
|
+
}
|
45
|
+
}
|
46
|
+
} else if (text === id) {
|
47
|
+
text = [kind, text].join(':'); // prepend kind to id
|
48
|
+
}
|
49
|
+
|
50
|
+
if (resourceIsKnown) {
|
51
|
+
return (
|
52
|
+
<Link to={kind} params={{id: window.encodeURIComponent(id)}}
|
53
|
+
className={classes.join(' ')}>
|
54
|
+
{text}
|
55
|
+
</Link>
|
56
|
+
);
|
57
|
+
} else {
|
58
|
+
return (
|
59
|
+
<a href="#" className={classes.join(' ')}>
|
60
|
+
{text}
|
61
|
+
</a>
|
62
|
+
);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
});
|