Add a separator between blame and the edit icon
Change-Id: I36cf9acfbf4686404d42bf6d9d04f8ab9eca3ef4
(cherry picked from commit 32a9265505)
This commit is contained in:
@@ -290,13 +290,15 @@ limitations under the License.
|
|||||||
on-tap="_toggleBlame">[[_computeBlameToggleLabel(_isBlameLoaded, _isBlameLoading)]]</gr-button>
|
on-tap="_toggleBlame">[[_computeBlameToggleLabel(_isBlameLoaded, _isBlameLoading)]]</gr-button>
|
||||||
</span>
|
</span>
|
||||||
<template is="dom-if" if="[[_computeIsLoggedIn(_loggedIn)]]">
|
<template is="dom-if" if="[[_computeIsLoggedIn(_loggedIn)]]">
|
||||||
|
<span class="separator"></span>
|
||||||
<span class="editButton">
|
<span class="editButton">
|
||||||
<a href$="[[_computeEditURL(_change, _patchRange, _path)]]">
|
<gr-button
|
||||||
<iron-icon icon="gr-icons:edit"></iron-icon>
|
link
|
||||||
</a>
|
title="Edit current file"
|
||||||
<span class="separator"></span>
|
on-click="_goToEditFile">edit</gr-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
<span class="separator"></span>
|
||||||
<div class$="diffModeSelector [[_computeModeSelectHideClass(_isImageDiff)]]">
|
<div class$="diffModeSelector [[_computeModeSelectHideClass(_isImageDiff)]]">
|
||||||
<span>Diff view:</span>
|
<span>Diff view:</span>
|
||||||
<gr-diff-mode-selector
|
<gr-diff-mode-selector
|
||||||
|
|||||||
@@ -526,12 +526,11 @@
|
|||||||
return this._getDiffUrl(this._change, this._patchRange, newPath.path);
|
return this._getDiffUrl(this._change, this._patchRange, newPath.path);
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeEditURL(change, patchRange, path) {
|
_goToEditFile() {
|
||||||
if ([change, patchRange, path].some(arg => arg === undefined)) {
|
// TODO(taoalpha): add a shortcut for editing
|
||||||
return '';
|
const editUrl = Gerrit.Nav.getEditUrlForDiff(
|
||||||
}
|
this._change, this._path, this._patchRange.patchNum);
|
||||||
return Gerrit.Nav.getEditUrlForDiff(
|
return Gerrit.Nav.navigateToRelativeUrl(editUrl);
|
||||||
change, path, patchRange.patchNum);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -344,10 +344,51 @@ limitations under the License.
|
|||||||
PARENT), 'Should navigate to /c/42/1');
|
PARENT), 'Should navigate to /c/42/1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_computeEditURL uses Gerrit.Nav', () => {
|
test('edit should redirect to edit page', done => {
|
||||||
const getUrlStub = sandbox.stub(Gerrit.Nav, 'getEditUrlForDiff');
|
element._loggedIn = true;
|
||||||
element._computeEditURL(123, {patchNum: undefined}, 'abc/def');
|
element._path = 't.txt';
|
||||||
assert.isTrue(getUrlStub.called);
|
element._patchRange = {
|
||||||
|
basePatchNum: PARENT,
|
||||||
|
patchNum: '1',
|
||||||
|
};
|
||||||
|
element._change = {
|
||||||
|
_number: 42,
|
||||||
|
revisions: {
|
||||||
|
a: {_number: 1, commit: {parents: []}},
|
||||||
|
b: {_number: 2, commit: {parents: []}},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const redirectStub = sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
|
||||||
|
flush(() => {
|
||||||
|
const editBtn = Polymer.dom(element.root)
|
||||||
|
.querySelector('.editButton gr-button');
|
||||||
|
assert.isTrue(!!editBtn);
|
||||||
|
MockInteractions.tap(editBtn);
|
||||||
|
assert.isTrue(redirectStub.called);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('edit hidden when not logged in', done => {
|
||||||
|
element._loggedIn = false;
|
||||||
|
element._path = 't.txt';
|
||||||
|
element._patchRange = {
|
||||||
|
basePatchNum: PARENT,
|
||||||
|
patchNum: '1',
|
||||||
|
};
|
||||||
|
element._change = {
|
||||||
|
_number: 42,
|
||||||
|
revisions: {
|
||||||
|
a: {_number: 1, commit: {parents: []}},
|
||||||
|
b: {_number: 2, commit: {parents: []}},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
flush(() => {
|
||||||
|
const editBtn = Polymer.dom(element.root)
|
||||||
|
.querySelector('.editButton gr-button');
|
||||||
|
assert.isFalse(!!editBtn);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Diff preferences hidden when no prefs or logged out', () => {
|
test('Diff preferences hidden when no prefs or logged out', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user