Clean up code in gr-apply-fix-dialog
When reading code, I found some unused code, not removed by
Change 350174 + I cleaned up some hard to read code.
Release-Notes: skip
Change-Id: I25c912ab5b5a6e73ae99035edbc961c609e03ad3
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
index 7c224a9..a6a27c5 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
@@ -56,12 +56,6 @@
@query('#applyFixDialog')
applyFixDialog?: GrDialog;
- /** The currently observed dialog by `dialogOberserver`. */
- observedDialog?: GrDialog;
-
- /** The current observer observing the `observedDialog`. */
- dialogObserver?: ResizeObserver;
-
@query('#nextFix')
nextFix?: GrButton;
@@ -211,10 +205,6 @@
`;
}
- override disconnectedCallback() {
- super.disconnectedCallback();
- }
-
private renderHeader() {
return html`
<div slot="header">${this.currentFix?.description ?? ''}</div>
@@ -249,13 +239,21 @@
private renderFooter() {
const fixCount = this.fixSuggestions?.length ?? 0;
const reasonForDisabledApplyButton = this.computeTooltip();
- if (fixCount < 2 && !reasonForDisabledApplyButton) return nothing;
- return html`<div slot="footer" class="fix-picker">
- ${when(fixCount >= 2, () =>
- this.renderNavForMultipleSuggestedFixes(fixCount)
- )}
- ${this.renderWarning(reasonForDisabledApplyButton)}
- </div>`;
+ const shouldRenderNav = fixCount >= 2;
+ const shouldRenderWarning = !!reasonForDisabledApplyButton;
+
+ if (!shouldRenderNav && !shouldRenderWarning) return nothing;
+
+ return html`
+ <div slot="footer" class="fix-picker">
+ ${when(shouldRenderNav, () =>
+ this.renderNavForMultipleSuggestedFixes(fixCount)
+ )}
+ ${when(shouldRenderWarning, () =>
+ this.renderWarning(reasonForDisabledApplyButton)
+ )}
+ </div>
+ `;
}
private renderNavForMultipleSuggestedFixes(fixCount: number) {
@@ -406,9 +404,7 @@
async handleApplyFix(e: Event) {
if (e) e.stopPropagation();
- const changeNum = this.changeNum;
- const patchNum = this.patchNum;
- const change = this.change;
+ const {changeNum, patchNum, change} = this;
if (!changeNum || !patchNum || !change || !this.currentFix) {
throw new Error('Not all required properties are set.');
}