diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html index 3ac3a578ae..40db0915b1 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html @@ -36,6 +36,7 @@ limitations under the License. + @@ -203,6 +204,9 @@ limitations under the License. .scrollable { overflow: auto; } + #includedInOverlay { + width: 65em; + } @media screen and (min-width: 80em) { .commitMessage { max-width: var(--commit-message-max-width, 100ch); @@ -439,6 +443,7 @@ limitations under the License. revisions="[[_sortedRevisions]]" on-open-diff-prefs="_handleOpenDiffPrefs" on-open-download-dialog="_handleOpenDownloadDialog" + on-open-included-in-dialog="_handleOpenIncludedInDialog" on-expand-diffs="_expandAllDiffs" on-collapse-diffs="_collapseAllDiffs"> @@ -476,6 +481,12 @@ limitations under the License. config="[[_serverConfig.download]]" on-close="_handleDownloadDialogClose"> + + + { + Polymer.dom.flush(); + this.$.includedInOverlay.refit(); + }); + this.$.includedInOverlay.open(); + }, + + _handleIncludedInDialogClose(e) { + this.$.includedInOverlay.close(); + }, + _handleOpenDownloadDialog() { this.$.downloadOverlay.open().then(() => { this.$.downloadOverlay diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html index fd07d4ecf2..fb862603e3 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html +++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html @@ -131,6 +131,9 @@ limitations under the License. font-family: var(--font-family-bold); margin-right: 1em; } + .container.includedInContainer.hide { + display: none; + } @media screen and (max-width: 50em) { .patchInfo-header .desktop { display: none; @@ -166,6 +169,12 @@ limitations under the License. class="download" on-tap="_handleDownloadTap">Download + + + Included In + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js new file mode 100644 index 0000000000..93e644e053 --- /dev/null +++ b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js @@ -0,0 +1,96 @@ +// Copyright (C) 2018 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-included-in-dialog', + + /** + * Fired when the user presses the close button. + * + * @event close + */ + + properties: { + /** @type {?} */ + changeNum: { + type: Object, + observer: '_resetData', + }, + /** @type {?} */ + _includedIn: Object, + _loaded: { + type: Boolean, + value: false, + }, + _filterText: { + type: String, + value: '', + }, + }, + + loadData() { + if (!this.changeNum) { return; } + this._filterText = ''; + return this.$.restAPI.getChangeIncludedIn(this.changeNum).then( + configs => { + if (!configs) { return; } + this._includedIn = configs; + this._loaded = true; + }); + }, + + _resetData() { + this._includedIn = null; + this._loaded = false; + }, + + _computeGroups(includedIn, filterText) { + if (!includedIn) { return []; } + + const filter = item => !filterText.length || + item.toLowerCase().indexOf(filterText.toLowerCase()) !== -1; + + const groups = [ + {title: 'Branches', items: includedIn.branches.filter(filter)}, + {title: 'Tags', items: includedIn.tags.filter(filter)}, + ]; + if (includedIn.external) { + for (const externalKey of Object.keys(includedIn.external)) { + groups.push({ + title: externalKey, + items: includedIn.external[externalKey].filter(filter), + }); + } + } + return groups.filter(g => g.items.length); + }, + + _handleCloseTap(e) { + e.preventDefault(); + this.fire('close', null, {bubbles: false}); + }, + + _computeLoadingClass(loaded) { + return loaded ? 'loading loaded' : 'loading'; + }, + + _onFilterChanged() { + this.debounce('filter-change', () => { + this._filterText = this.$.filterInput.bindValue; + }, 100); + }, + }); +})(); diff --git a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog_test.html b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog_test.html new file mode 100644 index 0000000000..1f7af38e8c --- /dev/null +++ b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog_test.html @@ -0,0 +1,83 @@ + + + + +gr-included-in-dialog + + + + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js index 763e622754..5e9d913ae3 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js @@ -986,6 +986,13 @@ opt_errFn, null, params); }, + /** + * @param {number|string} changeNum + */ + getChangeIncludedIn(changeNum) { + return this._getChangeURLAndFetch(changeNum, '/in', null); + }, + _computeFilter(filter) { if (filter && filter.startsWith('^')) { filter = '&r=' + encodeURIComponent(filter); diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html index a06b470922..cbc5cb0846 100644 --- a/polygerrit-ui/app/test/index.html +++ b/polygerrit-ui/app/test/index.html @@ -68,6 +68,7 @@ limitations under the License. 'change/gr-download-dialog/gr-download-dialog_test.html', 'change/gr-file-list-header/gr-file-list-header_test.html', 'change/gr-file-list/gr-file-list_test.html', + 'change/gr-included-in-dialog/gr-included-in-dialog_test.html', 'change/gr-label-score-row/gr-label-score-row_test.html', 'change/gr-label-scores/gr-label-scores_test.html', 'change/gr-message/gr-message_test.html',