Show Apply Fix Suggestion only to owner
We show the 'Apply Fix' button only when the user is the owner of the
change. This was proposed during UX Review
Google-Bug-Id: b/335154824
Release-Notes: skip
Change-Id: Ice47747980bf0828bc504b5242f44874a128b8d6
diff --git a/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts b/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
index 1b30e0f..63c3832 100644
--- a/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
+++ b/polygerrit-ui/app/elements/shared/gr-fix-suggestions/gr-fix-suggestions.ts
@@ -21,6 +21,7 @@
import {pluginLoaderToken} from '../gr-js-api-interface/gr-plugin-loader';
import {SuggestionsProvider} from '../../../api/suggestions';
import {PROVIDED_FIX_ID} from '../../../utils/comment-util';
+import {when} from 'lit/directives/when.js';
/**
* gr-fix-suggestions is UI for comment.fix_suggestions.
@@ -44,6 +45,8 @@
@state()
suggestionsProvider?: SuggestionsProvider;
+ @state() private isOwner = false;
+
private readonly getConfigModel = resolve(this, configModelToken);
private readonly getChangeModel = resolve(this, changeModelToken);
@@ -62,6 +65,11 @@
() => this.getChangeModel().latestPatchNum$,
x => (this.latestPatchNum = x)
);
+ subscribe(
+ this,
+ () => this.getChangeModel().isOwner$,
+ x => (this.isOwner = x)
+ );
}
override connectedCallback() {
@@ -126,17 +134,21 @@
>
Show edit
</gr-button>
- <gr-button
- secondary
- flatten
- .loading=${this.applyingFix}
- .disabled=${this.isApplyEditDisabled()}
- class="action show-fix"
- @click=${this.handleApplyFix}
- .title=${this.computeApplyEditTooltip()}
- >
- Apply edit
- </gr-button>
+ ${when(
+ this.isOwner,
+ () =>
+ html`<gr-button
+ secondary
+ flatten
+ .loading=${this.applyingFix}
+ .disabled=${this.isApplyEditDisabled()}
+ class="action show-fix"
+ @click=${this.handleApplyFix}
+ .title=${this.computeApplyEditTooltip()}
+ >
+ Apply edit
+ </gr-button>`
+ )}
</div>
</div>
<gr-suggestion-diff-preview