Remove use of "NoteDB" config in PolyGerrit

Change-Id: Iab11a19fef30333667b00cd98a9fd3c8270741d0
This commit is contained in:
Paladox none
2019-06-21 13:32:07 +00:00
parent b8a09cfa60
commit 2595f1b501
9 changed files with 66 additions and 158 deletions

View File

@@ -83,9 +83,6 @@ limitations under the License.
getLoggedIn() { return Promise.resolve(false); },
deleteVote() { return Promise.resolve({ok: true}); },
});
stub('gr-change-metadata', {
_computeShowReviewersByState() { return true; },
});
});
teardown(() => {

View File

@@ -200,38 +200,26 @@ limitations under the License.
allow-any-user></gr-account-list>
</span>
</section>
<template is="dom-if" if="[[_showReviewersByState]]">
<section>
<span class="title">Reviewers</span>
<span class="value">
<gr-reviewer-list
change="{{change}}"
mutable="[[_mutable]]"
reviewers-only
max-reviewers-displayed="3"></gr-reviewer-list>
</span>
</section>
<section>
<span class="title">CC</span>
<span class="value">
<gr-reviewer-list
change="{{change}}"
mutable="[[_mutable]]"
ccs-only
max-reviewers-displayed="3"></gr-reviewer-list>
</span>
</section>
</template>
<template is="dom-if" if="[[!_showReviewersByState]]">
<section>
<span class="title">Reviewers</span>
<span class="value">
<gr-reviewer-list
change="{{change}}"
mutable="[[_mutable]]"></gr-reviewer-list>
</span>
</section>
</template>
<section>
<span class="title">Reviewers</span>
<span class="value">
<gr-reviewer-list
change="{{change}}"
mutable="[[_mutable]]"
reviewers-only
max-reviewers-displayed="3"></gr-reviewer-list>
</span>
</section>
<section>
<span class="title">CC</span>
<span class="value">
<gr-reviewer-list
change="{{change}}"
mutable="[[_mutable]]"
ccs-only
max-reviewers-displayed="3"></gr-reviewer-list>
</span>
</section>
<section>
<span class="title">Repo</span>
<span class="value">
@@ -299,31 +287,29 @@ limitations under the License.
<span class="title">Strategy</span>
<span class="value">[[_computeStrategy(change)]]</span>
</section>
<template is="dom-if" if="[[serverConfig.note_db_enabled]]">
<section class="hashtag">
<span class="title">Hashtags</span>
<span class="value">
<template is="dom-repeat" items="[[change.hashtags]]">
<gr-linked-chip
class="hashtagChip"
text="[[item]]"
href="[[_computeHashtagURL(item)]]"
removable="[[!_hashtagReadOnly]]"
on-remove="_handleHashtagRemoved">
</gr-linked-chip>
</template>
<template is="dom-if" if="[[!_hashtagReadOnly]]">
<gr-editable-label
uppercase
label-text="Add a hashtag"
value="{{_newHashtag}}"
placeholder="[[_computeHashtagPlaceholder(_hashtagReadOnly)]]"
read-only="[[_hashtagReadOnly]]"
on-changed="_handleHashtagChanged"></gr-editable-label>
</template>
</span>
</section>
</template>
<section class="hashtag">
<span class="title">Hashtags</span>
<span class="value">
<template is="dom-repeat" items="[[change.hashtags]]">
<gr-linked-chip
class="hashtagChip"
text="[[item]]"
href="[[_computeHashtagURL(item)]]"
removable="[[!_hashtagReadOnly]]"
on-remove="_handleHashtagRemoved">
</gr-linked-chip>
</template>
<template is="dom-if" if="[[!_hashtagReadOnly]]">
<gr-editable-label
uppercase
label-text="Add a hashtag"
value="{{_newHashtag}}"
placeholder="[[_computeHashtagPlaceholder(_hashtagReadOnly)]]"
read-only="[[_hashtagReadOnly]]"
on-changed="_handleHashtagChanged"></gr-editable-label>
</template>
</span>
</section>
<div class="separatedSection">
<gr-change-requirements
change="{{change}}"

View File

@@ -84,9 +84,7 @@
type: Boolean,
computed: '_computeIsMutable(account)',
},
/**
* @type {{ note_db_enabled: string }}
*/
/** @type {?} */
serverConfig: Object,
parentIsCurrent: Boolean,
_notCurrentMessage: {
@@ -102,10 +100,6 @@
type: Boolean,
computed: '_computeHashtagReadOnly(_mutable, change)',
},
_showReviewersByState: {
type: Boolean,
computed: '_computeShowReviewersByState(serverConfig)',
},
/**
* @type {Defs.PushCertificateValidation}
*/
@@ -283,10 +277,6 @@
return _hashtagReadOnly ? '' : HASHTAG_ADD_MESSAGE;
},
_computeShowReviewersByState(serverConfig) {
return !!serverConfig.note_db_enabled;
},
_computeShowRequirements(change) {
if (change.status !== this.ChangeStatus.NEW) {
// TODO(maximeg) change this to display the stored

View File

@@ -117,18 +117,6 @@ limitations under the License.
assert.isTrue(element.$$('.strategy').hasAttribute('hidden'));
});
test('show CC section when NoteDb enabled', () => {
function hasCc() {
return element._showReviewersByState;
}
element.serverConfig = {};
assert.isFalse(hasCc());
element.serverConfig = {note_db_enabled: true};
assert.isTrue(hasCc());
});
test('weblinks use Gerrit.Nav interface', () => {
const weblinksStub = sandbox.stub(Gerrit.Nav, '_generateWeblinks')
.returns([{name: 'stubb', url: '#s'}]);
@@ -550,9 +538,6 @@ limitations under the License.
});
test('_computeHashtagReadOnly', () => {
element.serverConfig = {
note_db_enabled: true,
};
flushAsynchronousOperations();
let mutable = false;
assert.isTrue(element._computeHashtagReadOnly(mutable, change));
@@ -565,9 +550,6 @@ limitations under the License.
});
test('hashtag read only hides delete button', () => {
element.serverConfig = {
note_db_enabled: true,
};
flushAsynchronousOperations();
element.account = {};
element.change = change;
@@ -577,9 +559,6 @@ limitations under the License.
});
test('hashtag not read only does not hide delete button', () => {
element.serverConfig = {
note_db_enabled: true,
};
flushAsynchronousOperations();
element.account = {test: true};
change.actions.hashtags.enabled = true;
@@ -701,9 +680,6 @@ limitations under the License.
});
test('changing hashtag', () => {
element.serverConfig = {
note_db_enabled: true,
};
flushAsynchronousOperations();
element._newHashtag = 'new hashtag';
const newHashtag = ['new hashtag'];

View File

@@ -673,7 +673,6 @@ limitations under the License.
patch-num="[[computeLatestPatchNum(_allPatchSets)]]"
permitted-labels="[[_change.permitted_labels]]"
diff-drafts="[[_diffDrafts]]"
server-config="[[_serverConfig]]"
project-config="[[_projectConfig]]"
can-be-started="[[_canStartReview]]"
on-send="_handleReplySent"

View File

@@ -86,7 +86,6 @@ limitations under the License.
'+1',
],
};
element.serverConfig = {note_db_enabled: true};
sandbox.stub(element, 'fetchChangeUpdates')
.returns(Promise.resolve({isLatest: true}));
};

View File

@@ -171,21 +171,19 @@ limitations under the License.
on-account-text-changed="_handleAccountTextEntry">
</gr-account-list>
</div>
<template is="dom-if" if="[[serverConfig.note_db_enabled]]">
<div class="peopleList">
<div class="peopleListLabel">CC</div>
<gr-account-list
id="ccs"
accounts="{{_ccs}}"
change="[[change]]"
filter="[[filterCCSuggestion]]"
pending-confirmation="{{_ccPendingConfirmation}}"
allow-any-input
placeholder="Add CC..."
on-account-text-changed="_handleAccountTextEntry">
</gr-account-list>
</div>
</template>
<div class="peopleList">
<div class="peopleListLabel">CC</div>
<gr-account-list
id="ccs"
accounts="{{_ccs}}"
change="[[change]]"
filter="[[filterCCSuggestion]]"
pending-confirmation="{{_ccPendingConfirmation}}"
allow-any-input
placeholder="Add CC..."
on-account-text-changed="_handleAccountTextEntry">
</gr-account-list>
</div>
<gr-overlay
id="reviewerConfirmationOverlay"
on-iron-overlay-canceled="_cancelPendingReviewer">

View File

@@ -141,10 +141,6 @@
},
},
permittedLabels: Object,
/**
* @type {{ note_db_enabled: boolean }}
*/
serverConfig: Object,
/**
* @type {{ commentlinks: Array }}
*/
@@ -195,10 +191,6 @@
type: String,
computed: '_computeSendButtonLabel(canBeStarted)',
},
_ccsEnabled: {
type: Boolean,
computed: '_computeCCsEnabled(serverConfig)',
},
_savingComments: Boolean,
_reviewersMutated: {
type: Boolean,
@@ -245,7 +237,7 @@
},
observers: [
'_changeUpdated(change.reviewers.*, change.owner, serverConfig)',
'_changeUpdated(change.reviewers.*, change.owner)',
'_ccsChanged(_ccs.splices)',
'_reviewersChanged(_reviewers.splices)',
],
@@ -629,14 +621,14 @@
'Say something nice...';
},
_changeUpdated(changeRecord, owner, serverConfig) {
this._rebuildReviewerArrays(changeRecord.base, owner, serverConfig);
_changeUpdated(changeRecord, owner) {
this._rebuildReviewerArrays(changeRecord.base, owner);
},
_rebuildReviewerArrays(change, owner, serverConfig) {
_rebuildReviewerArrays(change, owner) {
this._owner = owner;
let reviewers = [];
const reviewers = [];
const ccs = [];
for (const key in change) {
@@ -661,12 +653,7 @@
}
}
if (this._ccsEnabled) {
this._ccs = ccs;
} else {
this._ccs = [];
reviewers = reviewers.concat(ccs);
}
this._ccs = ccs;
this._reviewers = reviewers;
},
@@ -719,13 +706,12 @@
this.fire('cancel', null, {bubbles: false});
this.$.textarea.closeDropdown();
this._purgeReviewersPendingRemove(true);
this._rebuildReviewerArrays(this.change.reviewers, this._owner,
this.serverConfig);
this._rebuildReviewerArrays(this.change.reviewers, this._owner);
},
_saveTapHandler(e) {
e.preventDefault();
if (this._ccsEnabled && !this.$$('#ccs').submitEntryText()) {
if (!this.$$('#ccs').submitEntryText()) {
// Do not proceed with the save if there is an invalid email entry in
// the text field of the CC entry.
return;
@@ -741,7 +727,7 @@
},
_submit() {
if (this._ccsEnabled && !this.$$('#ccs').submitEntryText()) {
if (!this.$$('#ccs').submitEntryText()) {
// Do not proceed with the send if there is an invalid email entry in
// the text field of the CC entry.
return;
@@ -855,10 +841,6 @@
return canBeStarted ? ButtonTooltips.START_REVIEW : ButtonTooltips.SEND;
},
_computeCCsEnabled(serverConfig) {
return serverConfig && serverConfig.note_db_enabled;
},
_computeSavingLabelClass(savingComments) {
return savingComments ? 'saving' : '';
},

View File

@@ -97,7 +97,6 @@ limitations under the License.
'+1',
],
};
element.serverConfig = {};
getDraftCommentStub = sandbox.stub(element.$.storage, 'getDraftComment');
setDraftCommentStub = sandbox.stub(element.$.storage, 'setDraftComment');
@@ -296,7 +295,6 @@ limitations under the License.
const noButton =
element.$$('.reviewerConfirmationButtons gr-button:last-child');
element.serverConfig = {note_db_enabled: true};
element._ccPendingConfirmation = null;
element._reviewerPendingConfirmation = null;
flushAsynchronousOperations();
@@ -409,7 +407,6 @@ limitations under the License.
});
test('_reviewersMutated when account-text-change is fired from ccs', () => {
element.serverConfig = {note_db_enabled: true};
flushAsynchronousOperations();
assert.isFalse(element._reviewersMutated);
assert.isTrue(element.$$('#ccs').allowAnyInput);
@@ -496,19 +493,6 @@ limitations under the License.
flush(() => { element.send(); });
});
test('ccs are displayed if NoteDb is enabled', () => {
function hasCc() {
flushAsynchronousOperations();
return !!element.$$('#ccs');
}
element.serverConfig = {};
assert.isFalse(hasCc());
element.serverConfig = {note_db_enabled: true};
assert.isTrue(hasCc());
});
test('filterReviewerSuggestion', () => {
const owner = makeAccount();
const reviewer1 = makeAccount();
@@ -540,7 +524,6 @@ limitations under the License.
test('_focusOn', () => {
sandbox.spy(element, '_chooseFocusTarget');
element.serverConfig = {note_db_enabled: true};
flushAsynchronousOperations();
const textareaStub = sandbox.stub(element.$.textarea, 'async');
const reviewerEntryStub = sandbox.stub(element.$.reviewers.focusStart,
@@ -680,7 +663,6 @@ limitations under the License.
});
test('moving from cc to reviewer', () => {
element.serverConfig = {note_db_enabled: true};
element._reviewersPendingRemove = {
CC: [],
REVIEWER: [],
@@ -714,7 +696,6 @@ limitations under the License.
});
test('migrate reviewers between states', done => {
element.serverConfig = {note_db_enabled: true};
element._reviewersPendingRemove = {
CC: [],
REVIEWER: [],