PolyGerrit: Implment /admin/groups/<group>,audit-log
Change-Id: I23fa7dab7aceef747d879b5f873f77ed3f792d89
This commit is contained in:
@@ -31,6 +31,7 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-group/gr-group.html">
|
||||
<link rel="import" href="../gr-plugin-list/gr-plugin-list.html">
|
||||
<link rel="import" href="../gr-project/gr-project.html">
|
||||
<link rel="import" href="../gr-group-audit-log/gr-group-audit-log.html">
|
||||
<link rel="import" href="../gr-project-detail-list/gr-project-detail-list.html">
|
||||
|
||||
<dom-module id="gr-admin-view">
|
||||
@@ -105,6 +106,13 @@ limitations under the License.
|
||||
class="table"></gr-project-detail-list>
|
||||
</main>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_showGroupAuditLog]]" restamp="true">
|
||||
<main class="table">
|
||||
<gr-group-audit-log
|
||||
group-id="[[params.groupId]]"
|
||||
class="table"></gr-group-audit-log>
|
||||
</main>
|
||||
</template>
|
||||
<template is="dom-if" if="[[params.placeholder]]" restamp="true">
|
||||
<gr-placeholder title="Admin" path="[[path]]"></gr-placeholder>
|
||||
</template>
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
value: false,
|
||||
},
|
||||
_showGroup: Boolean,
|
||||
_showGroupAuditLog: Boolean,
|
||||
_showGroupList: Boolean,
|
||||
_showProjectMain: Boolean,
|
||||
_showProjectList: Boolean,
|
||||
@@ -122,7 +123,15 @@
|
||||
name: this._groupName,
|
||||
view: 'gr-group',
|
||||
url: `/admin/groups/${this.encodeURL(this._groupId, true)}`,
|
||||
children: [],
|
||||
children: [
|
||||
{
|
||||
name: 'Audit Log',
|
||||
detailType: 'audit-log',
|
||||
view: 'gr-group-audit-log',
|
||||
url: `/admin/groups/${this.encodeURL(this._groupId, true)}` +
|
||||
',audit-log',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
filteredLinks.push(linkCopy);
|
||||
@@ -142,6 +151,7 @@
|
||||
|
||||
_paramsChanged(params) {
|
||||
this.set('_showGroup', params.adminView === 'gr-group');
|
||||
this.set('_showGroupAuditLog', params.adminView === 'gr-group-audit-log');
|
||||
this.set('_showGroupList', params.adminView === 'gr-admin-group-list');
|
||||
this.set('_showProjectMain', params.adminView === 'gr-project');
|
||||
this.set('_showProjectList',
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../../behaviors/gr-list-view-behavior/gr-list-view-behavior.html">
|
||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../styles/gr-table-styles.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
|
||||
<dom-module id="gr-group-audit-log">
|
||||
<template>
|
||||
<style include="shared-styles"></style>
|
||||
<style include="gr-table-styles"></style>
|
||||
<table id="list" class="genericList">
|
||||
<tr class="headerRow">
|
||||
<th class="date topHeader">Date</th>
|
||||
<th class="type topHeader">Type</th>
|
||||
<th class="member topHeader">Member</th>
|
||||
<th class="by-user topHeader">By User</th>
|
||||
</tr>
|
||||
<tr id="loading" class$="loadingMsg [[computeLoadingClass(_loading)]]">
|
||||
<td>Loading...</td>
|
||||
</tr>
|
||||
<template is="dom-repeat" items="[[_auditLog]]"
|
||||
class$="[[computeLoadingClass(_loading)]]">
|
||||
<tr class="table">
|
||||
<td class="date">
|
||||
<gr-date-formatter
|
||||
has-tooltip
|
||||
date-str="[[item.date]]">
|
||||
</gr-date-formatter>
|
||||
</td>
|
||||
<td class="type">[[itemType(item.type)]]</td>
|
||||
<td class="member">
|
||||
<a href$="[[_computeGroupUrl(item.member._account_id)]]">
|
||||
[[item.member.name]]
|
||||
</a>
|
||||
</td>
|
||||
<td class="by-user">[[item.user.username]]</td>
|
||||
</tr>
|
||||
</template>
|
||||
</table>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
</template>
|
||||
<script src="gr-group-audit-log.js"></script>
|
||||
</dom-module>
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2017 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Polymer({
|
||||
is: 'gr-group-audit-log',
|
||||
|
||||
properties: {
|
||||
groupId: Object,
|
||||
_auditLog: Array,
|
||||
_loading: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
Gerrit.ListViewBehavior,
|
||||
],
|
||||
|
||||
ready() {
|
||||
this._getAuditLogs();
|
||||
},
|
||||
|
||||
_getAuditLogs() {
|
||||
return this.$.restAPI.getGroupAuditLog(this.groupId).then(auditLog => {
|
||||
if (!auditLog) {
|
||||
this._auditLog = [];
|
||||
return;
|
||||
}
|
||||
this._auditLog = Object.keys(auditLog).map(key => {
|
||||
const audit = auditLog[key];
|
||||
audit.name = key;
|
||||
return audit;
|
||||
});
|
||||
this._loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
_status(item) {
|
||||
return item.disabled ? 'Disabled' : 'Enabled';
|
||||
},
|
||||
|
||||
_computeGroupUrl(id) {
|
||||
return this.getBaseUrl() + '/admin/groups/' + id;
|
||||
},
|
||||
|
||||
itemType(type) {
|
||||
let item;
|
||||
switch (type) {
|
||||
case 'ADD_GROUP':
|
||||
case 'ADD_USER':
|
||||
item = 'Added';
|
||||
break;
|
||||
case 'REMOVE_GROUP':
|
||||
case 'REMOVE_USER':
|
||||
item = 'Removed';
|
||||
break;
|
||||
default:
|
||||
item = '';
|
||||
}
|
||||
return item;
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -151,6 +151,22 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Matches /admin/groups/<group>,audit-log[/]
|
||||
page(/^\/admin\/groups\/(.+),audit-log$/, loadUser, data => {
|
||||
restAPI.getLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
app.params = {
|
||||
view: Gerrit.Nav.View.ADMIN,
|
||||
adminView: 'gr-group-audit-log',
|
||||
detailType: 'audit-log',
|
||||
groupId: data.params[0],
|
||||
};
|
||||
} else {
|
||||
page.redirect('/login/' + encodeURIComponent(data.canonicalPath));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Matches /admin/groups[,<offset>][/].
|
||||
page(/^\/admin\/groups(,(\d+))?(\/)?$/, loadUser, data => {
|
||||
restAPI.getLoggedIn().then(loggedIn => {
|
||||
|
||||
@@ -283,6 +283,10 @@
|
||||
return this.send('PUT', `/groups/${encodeId}/options`, options);
|
||||
},
|
||||
|
||||
getGroupAuditLog(group) {
|
||||
return this._fetchSharedCacheURL('/groups/' + group + '/log.audit');
|
||||
},
|
||||
|
||||
getVersion() {
|
||||
return this._fetchSharedCacheURL('/config/server/version');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user