conjur-asset-ui 1.3.2 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.jshintrc +41 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -1
- data/README.md +38 -4
- data/Rakefile +69 -1
- data/TODO.md +31 -0
- data/bower.json +98 -0
- data/conjur-asset-ui.gemspec +3 -3
- 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/gulpfile.js +139 -0
- data/lib/conjur/command/ui.rb +1 -1
- data/lib/conjur/webserver/server.rb +14 -8
- data/lib/conjur-asset-ui-version.rb +1 -1
- data/package.json +47 -0
- data/preprocessor.js +7 -0
- data/public/_client_libs.html +1 -16
- data/public/build/css/styles.css +87 -0
- data/public/build/css/vendor.css +5 -0
- data/public/build/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/{fonts → build/fonts}/glyphicons-halflings-regular.svg +47 -47
- data/public/{fonts → build/fonts}/glyphicons-halflings-regular.ttf +0 -0
- data/public/build/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/build/js/app.min.js +4 -0
- data/public/build/js/vendor.min.js +23 -0
- data/public/build/maps/app.min.js.map +1 -0
- data/public/build/maps/vendor.min.js.map +1 -0
- data/public/css/styles.less +246 -17
- data/public/index.html.erb +11 -10
- data/public/js/init.js +186 -97
- data/public/js/lib/sorted-set.no-require.js +3 -28
- data/public/js/models/groupRecord.js +14 -12
- data/public/js/models/hostRecord.js +13 -8
- data/public/js/models/layerRecord.js +14 -12
- data/public/js/models/namespace.js +2 -0
- data/public/js/models/policyList.js +3 -1
- data/public/js/models/policyRecord.js +8 -8
- data/public/js/models/record.js +59 -27
- data/public/js/models/resourceList.js +28 -10
- data/public/js/models/userList.js +7 -2
- data/public/js/models/userRecord.js +14 -9
- data/public/js/models/variableList.js +18 -7
- data/public/js/models/variableRecord.js +18 -14
- data/public/js/routers.js +74 -37
- data/public/js/views/annotations.js +39 -28
- data/public/js/views/audit.js +31 -25
- data/public/js/views/breadcrumbs.js +62 -0
- data/public/js/views/chart.js +617 -0
- data/public/js/views/dashboard.js +144 -65
- data/public/js/views/generic.js +16 -9
- data/public/js/views/group.js +103 -55
- data/public/js/views/groups.js +3 -7
- data/public/js/views/host.js +192 -56
- data/public/js/views/hosts.js +2 -6
- data/public/js/views/layer.js +136 -82
- data/public/js/views/layers.js +2 -6
- data/public/js/views/mixins/search.js +12 -5
- data/public/js/views/mixins/tabs.js +95 -55
- data/public/js/views/navSearch.js +16 -5
- data/public/js/views/owned.js +14 -8
- data/public/js/views/permissions.js +244 -178
- data/public/js/views/policies.js +2 -4
- data/public/js/views/policy.js +65 -38
- data/public/js/views/resource.js +54 -34
- data/public/js/views/role.js +59 -37
- data/public/js/views/searchResults.js +205 -138
- data/public/js/views/sections.js +226 -0
- data/public/js/views/time.js +38 -13
- data/public/js/views/user.js +288 -59
- data/public/js/views/users.js +2 -7
- data/public/js/views/variable.js +293 -53
- data/public/js/views/variables.js +4 -8
- metadata +34 -56
- data/.git-hooks/pre_commit/ensure_livescript_compiled.rb +0 -31
- data/.overcommit.yml +0 -5
- data/compile_ls +0 -6
- data/livescript/views/audit.ls +0 -136
- data/public/_client_code.html +0 -42
- data/public/css/bootstrap.css +0 -7
- data/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/js/lib/JSXTransformer.js +0 -10862
- data/public/js/lib/async.js +0 -958
- data/public/js/lib/backbone.js +0 -2
- data/public/js/lib/bootstrap.js +0 -6
- data/public/js/lib/date.extensions.js +0 -141
- data/public/js/lib/less.js +0 -16
- data/public/js/lib/moment.js +0 -7768
- data/public/js/lib/prelude-browser-min.js +0 -1
- data/public/js/lib/react-bootstrap.js +0 -5346
- data/public/js/lib/react-bootstrap.min.js +0 -4
- data/public/js/lib/underscore-min.js +0 -6
- data/public/js/lib/underscore.string.min.js +0 -1
- data/public/js/main.js +0 -57
- data/vendor/prelude-ls/.gitignore +0 -2
- data/vendor/prelude-ls/.travis.yml +0 -3
- data/vendor/prelude-ls/CHANGELOG.md +0 -81
- data/vendor/prelude-ls/LICENSE +0 -22
- data/vendor/prelude-ls/Makefile +0 -50
- data/vendor/prelude-ls/README.md +0 -15
- data/vendor/prelude-ls/browser/prelude-browser-min.js +0 -1
- data/vendor/prelude-ls/browser/prelude-browser.js +0 -1172
- data/vendor/prelude-ls/lib/Func.js +0 -40
- data/vendor/prelude-ls/lib/List.js +0 -602
- data/vendor/prelude-ls/lib/Num.js +0 -129
- data/vendor/prelude-ls/lib/Obj.js +0 -153
- data/vendor/prelude-ls/lib/Str.js +0 -68
- data/vendor/prelude-ls/lib/index.js +0 -164
- data/vendor/prelude-ls/package.json +0 -50
- data/vendor/prelude-ls/package.ls +0 -46
- data/vendor/prelude-ls/src/Func.ls +0 -17
- data/vendor/prelude-ls/src/List.ls +0 -299
- data/vendor/prelude-ls/src/Num.ls +0 -83
- data/vendor/prelude-ls/src/Obj.ls +0 -61
- data/vendor/prelude-ls/src/Str.ls +0 -32
- data/vendor/prelude-ls/src/index.ls +0 -56
- data/vendor/prelude-ls/test/Func.ls +0 -36
- data/vendor/prelude-ls/test/List.ls +0 -751
- data/vendor/prelude-ls/test/Num.ls +0 -258
- data/vendor/prelude-ls/test/Obj.ls +0 -145
- data/vendor/prelude-ls/test/Prelude.ls +0 -49
- data/vendor/prelude-ls/test/Str.ls +0 -208
- data/vendor/prelude-ls/test/browser.html +0 -5
data/public/js/views/policies.js
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React */
|
2
3
|
|
3
4
|
(function(conjur, React) {
|
4
5
|
'use strict';
|
5
6
|
|
6
7
|
var GenericList = conjur.views.GenericList;
|
7
8
|
|
8
|
-
|
9
|
-
/*getInitialState: function() {
|
10
|
-
return { currentNamespace: "", members: [] };
|
11
|
-
},*/
|
9
|
+
this.PolicyBox = React.createClass({
|
12
10
|
render: function() {
|
13
11
|
return (
|
14
12
|
<div className="policyBox">
|
data/public/js/views/policy.js
CHANGED
@@ -1,43 +1,70 @@
|
|
1
1
|
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React, ReactBootstrap, _ */
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
4
|
+
(function(conjur, React, ReactBootstrap, _) {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var TabbedArea = ReactBootstrap.TabbedArea,
|
8
|
+
TabPane = ReactBootstrap.TabPane,
|
9
|
+
Tab = conjur.views.mixins.Tab,
|
10
|
+
RoleLink = conjur.views.RoleLink,
|
11
|
+
AuditBox = window.AuditBox;
|
12
|
+
|
13
|
+
this.Policy = React.createClass({
|
14
|
+
mixins: [Tab],
|
15
|
+
|
16
|
+
render: function() {
|
17
|
+
var policy = this.props.data.policy,
|
18
|
+
id = policy.id.split(':')[2];
|
19
|
+
|
20
|
+
//TODO: policy loader
|
21
|
+
//TODO in CLI: why not save text of policy as an annotation?
|
22
|
+
var overviewTab = (
|
23
|
+
<TabPane key="overview" tab="Overview">
|
24
|
+
<dl className="dl-horizontal">
|
25
|
+
<dt>Owner</dt>
|
26
|
+
<dd><RoleLink id={this.props.data.owner}/></dd>
|
27
|
+
</dl>
|
28
|
+
</TabPane>
|
29
|
+
);
|
30
|
+
|
31
|
+
var permissionsTab = this.permissionsTab(policy.id),
|
32
|
+
membershipsTab = this.membershipsTab(policy.id),
|
33
|
+
annotationsTab = this.annotationsTab(),
|
34
|
+
ownedTab = this.ownedTab();
|
35
|
+
|
36
|
+
var auditTab = (
|
37
|
+
<TabPane key="audit" tab="Recent Activity">
|
26
38
|
<div className="audit auditGroup">
|
27
39
|
<AuditBox roles={[policy.id]} tabview={true} />
|
28
40
|
</div>
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
41
|
+
</TabPane>
|
42
|
+
);
|
43
|
+
|
44
|
+
var tabs = _.compact([
|
45
|
+
overviewTab,
|
46
|
+
ownedTab,
|
47
|
+
membershipsTab,
|
48
|
+
permissionsTab,
|
49
|
+
annotationsTab,
|
50
|
+
auditTab
|
51
|
+
]);
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div className="policy">
|
55
|
+
<h2>Policy {id}</h2>
|
56
|
+
<TabbedArea defaultActiveKey="overview">
|
57
|
+
{tabs}
|
58
|
+
</TabbedArea>
|
59
|
+
</div>
|
60
|
+
);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
|
64
|
+
}).bind(conjur.views)
|
65
|
+
(
|
66
|
+
conjur,
|
67
|
+
React,
|
68
|
+
ReactBootstrap,
|
69
|
+
_
|
70
|
+
);
|
data/public/js/views/resource.js
CHANGED
@@ -1,39 +1,59 @@
|
|
1
1
|
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React, _ */
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
4
|
+
(function(conjur, React, _) {
|
5
|
+
'use strict';
|
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
|
+
this.ResourceLink = React.createClass({
|
14
|
+
render: function() {
|
15
|
+
var resourceId = this.props.id || this.props.data.id || this.props.data;
|
16
|
+
|
17
|
+
// guard against misuse such as https://github.com/conjurinc/conjur-asset-ui/issues/78
|
18
|
+
if (resourceId === undefined) {
|
19
|
+
return React.DOM.em({}, 'undefined');
|
20
|
+
}
|
21
|
+
|
22
|
+
var tokens = resourceId.split(':'),
|
23
|
+
kind = tokens[1],
|
24
|
+
id = tokens[tokens.length - 1],
|
25
|
+
text = this.props.text || id;
|
26
|
+
|
27
|
+
var knownTypes = ['user', 'group', 'layer', 'host', 'variable', 'policy'],
|
28
|
+
resourceIsKnown = _.contains(knownTypes, kind);
|
29
|
+
|
30
|
+
// we shouldn't build links to for unsupported resources
|
31
|
+
var href = '/ui/' + conjur.utils.pluralize(kind) + '/' + window.encodeURIComponent(id);
|
32
|
+
var classes = ['resource-link'];
|
33
|
+
|
34
|
+
if (!this.props.noIcon) {
|
35
|
+
if (resourceIsKnown) {
|
36
|
+
classes.push(kind);
|
37
|
+
} else {
|
38
|
+
classes.push('abstract');
|
39
|
+
|
40
|
+
if (text === id) {
|
41
|
+
text = [kind, text].join(':'); // prepend kind to id
|
42
|
+
}
|
43
|
+
}
|
44
|
+
} else if (text === id) {
|
45
|
+
text = [kind, text].join(':'); // prepend kind to id
|
31
46
|
}
|
47
|
+
|
48
|
+
return (
|
49
|
+
<a className={classes.join(' ')} href={href}>{text}</a>
|
50
|
+
);
|
32
51
|
}
|
33
|
-
}
|
34
|
-
text=[kind,text].join(":"); // prepend kind to id
|
35
|
-
}
|
52
|
+
});
|
36
53
|
|
37
|
-
|
38
|
-
|
39
|
-
|
54
|
+
}).bind(conjur.views)
|
55
|
+
(
|
56
|
+
conjur,
|
57
|
+
React,
|
58
|
+
_
|
59
|
+
);
|
data/public/js/views/role.js
CHANGED
@@ -1,41 +1,63 @@
|
|
1
1
|
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React, _ */
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
4
|
+
(function(conjur, React, _) {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
/** render a link to the role represented by this.props.id
|
8
|
+
Example: <RoleLink id='ci:user:jon'/>
|
9
|
+
*/
|
10
|
+
this.RoleLink = React.createClass({
|
11
|
+
render: function() {
|
12
|
+
// guard against misuse such as https://github.com/conjurinc/conjur-asset-ui/issues/78
|
13
|
+
if (this.props.id === undefined) {
|
14
|
+
return React.DOM.em({}, 'undefined');
|
15
|
+
}
|
16
|
+
|
17
|
+
var tokens = this.props.id.split(':'),
|
18
|
+
kind = tokens[1],
|
19
|
+
id = tokens[tokens.length-1],
|
20
|
+
href,
|
21
|
+
classes = ['role-link'],
|
22
|
+
knownTypes = ['user', 'group', 'layer', 'host', 'policy'],
|
23
|
+
kindIsKnown,
|
24
|
+
text;
|
25
|
+
|
26
|
+
if (tokens.length === 1) { // just username
|
27
|
+
kind = 'user';
|
28
|
+
id = tokens[0];
|
29
|
+
}
|
30
|
+
|
31
|
+
// TODO: shouldn't point to unknown types
|
32
|
+
href = '/ui/' + conjur.utils.pluralize(kind) + '/' + window.encodeURIComponent(id);
|
33
|
+
kindIsKnown = _.contains(knownTypes, kind);
|
34
|
+
text = id;
|
35
|
+
|
36
|
+
if (!this.props.noIcon) {
|
37
|
+
if (kindIsKnown) {
|
38
|
+
classes.push(kind);
|
39
|
+
} else {
|
40
|
+
classes.push('abstract'); // we have no picture for abstract role yet
|
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
|
31
48
|
}
|
49
|
+
|
50
|
+
return (
|
51
|
+
<a className={classes.join(' ')} href={href}>
|
52
|
+
{text}
|
53
|
+
</a>
|
54
|
+
);
|
32
55
|
}
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
});
|
56
|
+
});
|
57
|
+
|
58
|
+
}).bind(conjur.views)
|
59
|
+
(
|
60
|
+
conjur,
|
61
|
+
React,
|
62
|
+
_
|
63
|
+
);
|
@@ -1,145 +1,212 @@
|
|
1
1
|
/**@jsx React.DOM*/
|
2
|
+
/* global conjur, React, jQuery, _ */
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
},
|
27
|
-
|
28
|
-
title: function(){
|
29
|
-
var words = this.props.data.kind.replace(/[-_]/, ' ').split(' ');
|
30
|
-
words[words.length - 1] = conjur.utils.pluralize(words[words.length - 1]);
|
31
|
-
return words.map(_.str.capitalize).join(' ') + ' (' + this.props.data.items.length + ')';
|
32
|
-
}
|
33
|
-
});
|
34
|
-
|
35
|
-
var SearchResultItem = React.createClass({
|
36
|
-
render: function(){
|
37
|
-
return <div className="item">
|
38
|
-
<h4> { this.titleLink() } </h4>
|
39
|
-
<div className="details">
|
40
|
-
<strong> ID: </strong> <ResourceLink data={this.props.data.id} noIcon="true"/>
|
41
|
-
<strong> Owner: </strong> <RoleLink id={this.props.data.owner} noIcon="true"/>
|
42
|
-
</div>
|
43
|
-
<div className="comment">
|
44
|
-
{this.commentText()}
|
45
|
-
</div>
|
46
|
-
</div>;
|
47
|
-
},
|
48
|
-
|
49
|
-
commentText: function(){
|
50
|
-
var annots = this.annotationsMap();
|
51
|
-
return annots['description'] || "";
|
52
|
-
},
|
53
|
-
|
54
|
-
titleLink: function(){
|
55
|
-
var annots = this.annotationsMap();
|
56
|
-
return <ResourceLink data={this.props.data.id} text={annots['name']}/>
|
57
|
-
},
|
58
|
-
|
59
|
-
annotationsMap: function(){
|
60
|
-
if(this._annotationsMap) return this._annotationsMap;
|
61
|
-
var map = this._annotationsMap = {};
|
62
|
-
(this.props.data.annotations || []).forEach(function(a){
|
63
|
-
map[a.name] = a.value;
|
4
|
+
|
5
|
+
(function(conjur, React, $, _) {
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
var ResourceLink = conjur.views.ResourceLink,
|
9
|
+
RoleLink = conjur.views.RoleLink;
|
10
|
+
|
11
|
+
var SearchGroupTitle = React.createClass({
|
12
|
+
render: function() {
|
13
|
+
return (
|
14
|
+
<span>{this.title()}</span>
|
15
|
+
);
|
16
|
+
},
|
17
|
+
|
18
|
+
title: function() {
|
19
|
+
var words = this.props.data.kind.replace(/[-_]/, ' ').split(' ');
|
20
|
+
|
21
|
+
words[words.length - 1] = conjur.utils.pluralize(words[words.length - 1]);
|
22
|
+
|
23
|
+
return (
|
24
|
+
words.map(_.str.capitalize).join(' ') + ' (' + this.props.data.items.length + ')'
|
25
|
+
);
|
26
|
+
}
|
64
27
|
});
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
28
|
+
|
29
|
+
var SearchGroupHeading = React.createClass({
|
30
|
+
render: function() {
|
31
|
+
var targetId = '#search-collapse-' + this.props.data.kind;
|
32
|
+
|
33
|
+
return (
|
34
|
+
<div className="panel-heading">
|
35
|
+
<h4 className="panel-title">
|
36
|
+
<a data-toggle="collapse"
|
37
|
+
data-target={targetId}
|
38
|
+
className={'group-heading' + this.props.data.kind}>
|
39
|
+
<SearchGroupTitle data={this.props.data} />
|
40
|
+
</a>
|
41
|
+
</h4>
|
42
|
+
</div>
|
43
|
+
);
|
44
|
+
},
|
45
|
+
|
46
|
+
title: function() {
|
47
|
+
var words = this.props.data.kind.replace(/[-_]/, ' ').split(' ');
|
48
|
+
|
49
|
+
words[words.length - 1] = conjur.utils.pluralize(words[words.length - 1]);
|
50
|
+
|
51
|
+
return (
|
52
|
+
words.map(_.str.capitalize).join(' ') + ' (' + this.props.data.items.length + ')'
|
53
|
+
);
|
54
|
+
}
|
92
55
|
});
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
56
|
+
|
57
|
+
var SearchResultItem = React.createClass({
|
58
|
+
render: function() {
|
59
|
+
return (
|
60
|
+
<div className="item">
|
61
|
+
<h4>{this.titleLink()}</h4>
|
62
|
+
<div className="details">
|
63
|
+
<strong> ID: </strong> <ResourceLink data={this.props.data.id}
|
64
|
+
noIcon="true" />
|
65
|
+
<strong> Owner: </strong> <RoleLink id={this.props.data.owner}
|
66
|
+
noIcon="true" />
|
67
|
+
</div>
|
68
|
+
<div className="comment">
|
69
|
+
{this.commentText()}
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
);
|
73
|
+
},
|
74
|
+
|
75
|
+
commentText: function() {
|
76
|
+
var annots = this.annotationsMap();
|
77
|
+
|
78
|
+
return annots.description || '';
|
79
|
+
},
|
80
|
+
|
81
|
+
titleLink: function(){
|
82
|
+
var annots = this.annotationsMap();
|
83
|
+
|
84
|
+
return (
|
85
|
+
<ResourceLink data={this.props.data.id} text={annots.name} />
|
86
|
+
);
|
87
|
+
},
|
88
|
+
|
89
|
+
annotationsMap: function(){
|
90
|
+
if (this._annotationsMap) {
|
91
|
+
return this._annotationsMap;
|
92
|
+
}
|
93
|
+
|
94
|
+
var map = this._annotationsMap = {};
|
95
|
+
|
96
|
+
(this.props.data.annotations || []).forEach(function(a) {
|
97
|
+
map[a.name] = a.value;
|
98
|
+
});
|
99
|
+
|
100
|
+
return map;
|
101
|
+
}
|
101
102
|
});
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
103
|
+
|
104
|
+
// accepts props like data: { kind:"", items:[] }
|
105
|
+
var SearchGroup = React.createClass({
|
106
|
+
render: function() {
|
107
|
+
var id = 'search-group-' + this.props.data.kind;
|
108
|
+
|
109
|
+
var items = this.props.data.items.map(function(r) {
|
110
|
+
return (
|
111
|
+
<SearchResultItem data={r}/>
|
112
|
+
);
|
113
|
+
});
|
114
|
+
|
115
|
+
return (
|
116
|
+
<div id={id} className="panel panel-default search-group">
|
117
|
+
<SearchGroupHeading data={this.props.data}/>
|
118
|
+
<div id={'search-collapse-' + this.props.data.kind}
|
119
|
+
className="panel-collapse collapse in">
|
120
|
+
<div className="panel-body">
|
121
|
+
{items}
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
);
|
126
|
+
}
|
113
127
|
});
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
128
|
+
|
129
|
+
var SearchResults = this.SearchResults = React.createClass({
|
130
|
+
render: function() {
|
131
|
+
var results = this.props.data.results;
|
132
|
+
|
133
|
+
var grouped = _.groupBy(results, function(r) {
|
134
|
+
return r.id.split(':')[1];
|
135
|
+
});
|
136
|
+
|
137
|
+
// Don't care about these
|
138
|
+
delete grouped['environment-variables'];
|
139
|
+
delete grouped.notification;
|
140
|
+
delete grouped.queue;
|
141
|
+
|
142
|
+
var groups = _.map(grouped, function(items, key) {
|
143
|
+
var data = {items: items, kind: key}; // - prevent editor barfing
|
144
|
+
return <SearchGroup data={data}/>;
|
145
|
+
});
|
146
|
+
|
147
|
+
var scores = {
|
148
|
+
'policy': 1,
|
149
|
+
'layer': 2,
|
150
|
+
'group': 3,
|
151
|
+
'host': 4,
|
152
|
+
'user': 5,
|
153
|
+
'variable': 6,
|
154
|
+
'key_pair': 7
|
155
|
+
};
|
156
|
+
|
157
|
+
groups.sort(function(a, b) {
|
158
|
+
return (
|
159
|
+
(scores[a.props.data.kind] || 100) -
|
160
|
+
(scores[b.props.data.kind] || 100)
|
161
|
+
);
|
162
|
+
});
|
163
|
+
|
164
|
+
var toc = groups.map(function(g) {
|
165
|
+
var gid = '#search-group-' + g.props.data.kind;
|
166
|
+
|
167
|
+
return (
|
168
|
+
<div className="toc-item">
|
169
|
+
<a href={gid}><SearchGroupTitle data={g.props.data} /></a>
|
170
|
+
</div>
|
171
|
+
);
|
172
|
+
});
|
173
|
+
|
174
|
+
var heading = 'Found ' + this.props.data.results.length +
|
175
|
+
' resources matching "' + this.props.data.search + '"';
|
176
|
+
|
177
|
+
return (
|
178
|
+
<div id="searchResults">
|
179
|
+
<div className="searchResults">
|
180
|
+
<h3> { heading } </h3>
|
181
|
+
<div className="search-results-toc">
|
182
|
+
{toc}
|
183
|
+
</div>
|
184
|
+
<div className="search-results">
|
185
|
+
{groups}
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
);
|
190
|
+
}
|
119
191
|
});
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
var data = {search: search, results: results};
|
143
|
-
React.renderComponent(<SearchResults data={data}/>, container);
|
144
|
-
});
|
145
|
-
}
|
192
|
+
|
193
|
+
SearchResults.search = function(search, container) {
|
194
|
+
container = container || document.getElementById('content');
|
195
|
+
|
196
|
+
$.get(
|
197
|
+
conjur.app.endpoints.authz('resources', {search: search.replace('-',' ')}),
|
198
|
+
function(results) {
|
199
|
+
var data = {search: search, results: results};
|
200
|
+
React.renderComponent(<SearchResults data={data}/>, container);
|
201
|
+
}
|
202
|
+
);
|
203
|
+
};
|
204
|
+
|
205
|
+
|
206
|
+
}).bind(conjur.views)
|
207
|
+
(
|
208
|
+
conjur,
|
209
|
+
React,
|
210
|
+
jQuery,
|
211
|
+
_
|
212
|
+
);
|