diff --git a/Documentation/pg-plugin-endpoints.txt b/Documentation/pg-plugin-endpoints.txt index cb1041f855..cb80c7418b 100644 --- a/Documentation/pg-plugin-endpoints.txt +++ b/Documentation/pg-plugin-endpoints.txt @@ -149,11 +149,44 @@ The following endpoints are available to plugins. === change-list-header The `change-list-header` extension point adds a header to the change list view. - === change-list-item-cell The `change-list-item-cell` extension point adds a cell to the change list item. +In addition to default parameters, the following are available: + * `change` + current change of the row, an instance of link:rest-api-changes.html#change-info[ChangeInfo] + +=== change-view-tab-header +The `change-view-tab-header` extension point adds a primary tab to the change +view. This must be used in conjunction with `change-view-tab-content`. + +In addition to default parameters, the following are available: + +* `change` ++ +current change displayed, an instance of +link:rest-api-changes.html#change-info[ChangeInfo] + +* `revision` ++ +current revision displayed, an instance of +link:rest-api-changes.html#revision-info[RevisionInfo] + +=== change-view-tab-content +The `change-view-tab-content` extension point adds primary tab content to +the change view. This must be used in conjunction with `change-view-tab-header`. + +In addition to default parameters, the following are available: + +* `change` ++ +current change displayed, an instance of +link:rest-api-changes.html#change-info[ChangeInfo] + +* `revision` ++ +current revision displayed, an instance of +link:rest-api-changes.html#revision-info[RevisionInfo] 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 fc0cab0851..730f5270d4 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 @@ -519,8 +519,27 @@ limitations under the License. +
- + + Files + + + + +
+ +
+ +
+ @@ -575,7 +606,7 @@ limitations under the License. + on-selected-changed="_handleCommentTabChange"> Change Log diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js index bb51fcc49d..defbcdc4eb 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js @@ -253,6 +253,25 @@ type: Boolean, value: true, }, + _showFileTabContent: { + type: Boolean, + value: true, + }, + /** @type {Array} */ + _dynamicTabHeaderEndpoints: { + type: Array, + }, + _showPrimaryTabs: { + type: Boolean, + computed: '_computeShowPrimaryTabs(_dynamicTabHeaderEndpoints)', + }, + /** @type {Array} */ + _dynamicTabContentEndpoints: { + type: Array, + }, + _selectedFilesTabPluginEndpoint: { + type: String, + }, }, behaviors: [ @@ -310,6 +329,17 @@ this._setDiffViewMode(); }); + Gerrit.awaitPluginsLoaded().then(() => { + this._dynamicTabHeaderEndpoints = + Gerrit._endpoints.getDynamicEndpoints('change-view-tab-header'); + this._dynamicTabContentEndpoints = + Gerrit._endpoints.getDynamicEndpoints('change-view-tab-content'); + if (this._dynamicTabContentEndpoints.length + !== this._dynamicTabHeaderEndpoints.length) { + console.warn('Different number of tab headers and tab content.'); + } + }); + this.addEventListener('comment-save', this._handleCommentSave.bind(this)); this.addEventListener('comment-refresh', this._reloadDrafts.bind(this)); this.addEventListener('comment-discard', @@ -368,10 +398,18 @@ } }, - _handleTabChange() { + _handleCommentTabChange() { this._showMessagesView = this.$.commentTabs.selected === 0; }, + _handleFileTabChange() { + const selectedIndex = this.$$('#primaryTabs').selected; + this._showFileTabContent = selectedIndex === 0; + // Initial tab is the static files list. + this._selectedFilesTabPluginEndpoint = + this._dynamicTabContentEndpoints[selectedIndex - 1]; + }, + _handleEditCommitMessage(e) { this._editingCommitMessage = true; this.$.commitMessageEditor.focusTextarea(); @@ -699,6 +737,8 @@ // Selected has to be set after the paper-tabs are visible because // the selected underline depends on calculations made by the browser. this.$.commentTabs.selected = 0; + const primaryTabs = this.$$('#primaryTabs'); + if (primaryTabs) primaryTabs.selected = 0; this.async(() => { if (this.viewState.scrollTop) { @@ -821,6 +861,10 @@ this.fire('title-change', {title}); }, + _computeShowPrimaryTabs(dynamicTabContentEndpoints) { + return dynamicTabContentEndpoints.length > 0; + }, + _computeChangeUrl(change) { return Gerrit.Nav.getUrlForChange(change); }, 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 924ddabbdc..1a307f78e1 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 @@ -154,7 +154,10 @@ limitations under the License.
-

Files

+