Add link to old UI to edit project access

If a user is an admin, show them the GWT link. If not an admin, don't
display.

Bug: Issue 7309
Change-Id: I63ce2e0ab22c68ebc6dbf0744fab06e9299329f3
This commit is contained in:
Becky Siegel
2017-09-30 10:14:16 +01:00
parent 2083ce4fcf
commit 27bbf7ad3a
4 changed files with 42 additions and 3 deletions

View File

@@ -127,7 +127,9 @@ limitations under the License.
</template>
<template is="dom-if" if="[[_showProjectAccess]]" restamp="true">
<main class="table">
<gr-project-access project="[[params.project]]"></gr-project-access>
<gr-project-access
path="[[path]]"
project="[[params.project]]"></gr-project-access>
</main>
</template>
<template is="dom-if" if="[[params.placeholder]]" restamp="true">

View File

@@ -29,9 +29,22 @@ limitations under the License.
<dom-module id="gr-project-access">
<template>
<style include="shared-styles"></style>
<style include="shared-styles">
.gwtLink {
margin-bottom: 1em;
}
.gwtLink {
display: none;
}
.admin .gwtLink {
display: block;
}
</style>
<style include="gr-menu-page-styles"></style>
<main>
<main class$="[[_computeAdminClass(_isAdmin)]]">
<div class="gwtLink">This is currently in read only mode. To modify content, go to the
<a href$="[[computeGwtUrl(path)]]" rel="external">Old UI</a>
</div>
<template is="dom-if" if="[[_inheritsFrom]]">
<h3 id="inheritsFrom">Rights Inherit From
<a href$="[[_computeParentHref(_inheritsFrom.name)]]" rel="noopener">

View File

@@ -22,7 +22,13 @@
type: String,
observer: '_projectChanged',
},
// The current path
path: String,
_isAdmin: {
type: Boolean,
value: false,
},
_capabilities: Object,
_groups: Object,
/** @type {?} */
@@ -67,6 +73,10 @@
return res.labels;
}));
promises.push(this.$.restAPI.getIsAdmin().then(isAdmin => {
this._isAdmin = isAdmin;
}));
return Promise.all(promises).then(value => {
this._capabilities = value[1];
this._labels = value[2];
@@ -79,6 +89,10 @@
});
},
_computeAdminClass(isAdmin) {
return isAdmin ? 'admin' : '';
},
_computeParentHref(projectName) {
return this.getBaseUrl() +
`/admin/projects/${this.encodeURL(projectName, true)},access`;

View File

@@ -83,11 +83,14 @@ limitations under the License.
'getCapabilities').returns(Promise.resolve(capabilitiesRes));
const projectStub = sandbox.stub(element.$.restAPI, 'getProject').returns(
Promise.resolve(projectRes));
const adminStub = sandbox.stub(element.$.restAPI, 'getIsAdmin').returns(
Promise.resolve(true));
element._projectChanged('New Project').then(() => {
assert.isTrue(accessStub.called);
assert.isTrue(capabilitiesStub.called);
assert.isTrue(projectStub.called);
assert.isTrue(adminStub.called);
assert.isNotOk(element._inheritsFrom);
assert.deepEqual(element._local, accessRes.local);
assert.deepEqual(element._sections,
@@ -143,6 +146,13 @@ limitations under the License.
'/admin/projects/test-project,access');
});
test('_computeAdminClass', () => {
let isAdmin = true;
assert.equal(element._computeAdminClass(isAdmin), 'admin');
isAdmin = false;
assert.equal(element._computeAdminClass(isAdmin), '');
});
test('inherit section', () => {
sandbox.stub(element, '_computeParentHref');
assert.isNotOk(Polymer.dom(element.root).querySelector('#inheritsFrom'));