diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js index 12b5aadd2d..d09c942e46 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js @@ -225,6 +225,11 @@ class GrFileList extends mixinBehaviors( [ computed: '_computeShowDynamicColumns(_dynamicHeaderEndpoints, ' + '_dynamicContentEndpoints, _dynamicSummaryEndpoints)', }, + _showPrependedDynamicColumns: { + type: Boolean, + computed: '_computeShowPrependedDynamicColumns(' + + '_dynamicPrependedHeaderEndpoints, _dynamicPrependedContentEndpoints)', + }, /** @type {Array} */ _dynamicHeaderEndpoints: { type: Array, @@ -237,6 +242,14 @@ class GrFileList extends mixinBehaviors( [ _dynamicSummaryEndpoints: { type: Array, }, + /** @type {Array} */ + _dynamicPrependedHeaderEndpoints: { + type: Array, + }, + /** @type {Array} */ + _dynamicPrependedContentEndpoints: { + type: Array, + }, }; } @@ -295,18 +308,27 @@ class GrFileList extends mixinBehaviors( [ attached() { super.attached(); pluginLoader.awaitPluginsLoaded().then(() => { - this._dynamicHeaderEndpoints = pluginEndpoints.getDynamicEndpoints( - 'change-view-file-list-header'); - this._dynamicContentEndpoints = pluginEndpoints.getDynamicEndpoints( - 'change-view-file-list-content'); - this._dynamicSummaryEndpoints = pluginEndpoints.getDynamicEndpoints( - 'change-view-file-list-summary'); + this._dynamicHeaderEndpoints = pluginEndpoints + .getDynamicEndpoints('change-view-file-list-header'); + this._dynamicContentEndpoints = pluginEndpoints + .getDynamicEndpoints('change-view-file-list-content'); + this._dynamicPrependedHeaderEndpoints = pluginEndpoints + .getDynamicEndpoints('change-view-file-list-header-prepend'); + this._dynamicPrependedContentEndpoints = pluginEndpoints + .getDynamicEndpoints('change-view-file-list-content-prepend'); + this._dynamicSummaryEndpoints = pluginEndpoints + .getDynamicEndpoints('change-view-file-list-summary'); if (this._dynamicHeaderEndpoints.length !== this._dynamicContentEndpoints.length) { console.warn( 'Different number of dynamic file-list header and content.'); } + if (this._dynamicPrependedHeaderEndpoints.length !== + this._dynamicPrependedContentEndpoints.length) { + console.warn( + 'Different number of dynamic file-list header and content.'); + } if (this._dynamicHeaderEndpoints.length !== this._dynamicSummaryEndpoints.length) { console.warn( @@ -1432,10 +1454,22 @@ class GrFileList extends mixinBehaviors( [ _computeShowDynamicColumns( headerEndpoints, contentEndpoints, summaryEndpoints) { return headerEndpoints && contentEndpoints && summaryEndpoints && + headerEndpoints.length && headerEndpoints.length === contentEndpoints.length && headerEndpoints.length === summaryEndpoints.length; } + /** + * Shows registered dynamic prepended columns iff the 'header', 'content' + * endpoints are registered the exact same number of times. + */ + _computeShowPrependedDynamicColumns( + headerEndpoints, contentEndpoints) { + return headerEndpoints && contentEndpoints && + headerEndpoints.length && + headerEndpoints.length === contentEndpoints.length; + } + /** * Returns true if none of the inline diffs have been expanded. * diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js index 600b0bc7cf..cc4e9342e1 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js @@ -297,10 +297,22 @@ export const htmlTemplate = html`
+ +
File
Comments
Size
Delta
+