Merge "Fix NPE when account has no preferredEmail"
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 158799d..1d2b39e 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -60,7 +60,6 @@
 import {Subject} from 'rxjs';
 import {debounceTime} from 'rxjs/operators';
 import {changeModelToken} from '../../../models/change/change-model';
-import {KnownExperimentId} from '../../../services/flags/flags';
 import {isBase64FileContent} from '../../../api/rest-api';
 import {createDiffUrl} from '../../../models/views/change';
 import {userModelToken} from '../../../models/user/user-model';
@@ -207,8 +206,6 @@
 
   private readonly reporting = getAppContext().reportingService;
 
-  private readonly flagsService = getAppContext().flagsService;
-
   private readonly getChangeModel = resolve(this, changeModelToken);
 
   private readonly getCommentsModel = resolve(this, commentsModelToken);
@@ -777,9 +774,6 @@
   }
 
   private renderSuggestEditButton() {
-    if (!this.flagsService.isEnabled(KnownExperimentId.SUGGEST_EDIT)) {
-      return nothing;
-    }
     if (
       !this.editing ||
       this.permanentEditingMode ||
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
index 59485e2..607d0f2 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
@@ -378,6 +378,17 @@
                   </gr-tooltip-content>
                 </div>
                 <div class="headerMiddle"></div>
+                <gr-button
+                  aria-disabled="false"
+                  class="action suggestEdit"
+                  link=""
+                  role="button"
+                  tabindex="0"
+                  title="This button copies the text to make a suggestion"
+                >
+                  <gr-icon filled="" icon="edit" id="icon"> </gr-icon>
+                  Suggest edit
+                </gr-button>
                 <span class="patchset-text">Patchset 1</span>
                 <span class="separator"></span>
                 <span class="date" tabindex="0">
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
index 405409d..9f3d79b 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts
@@ -19,8 +19,6 @@
 import {linkifyUrlsAndApplyRewrite} from '../../../utils/link-util';
 import '../gr-account-chip/gr-account-chip';
 import '../gr-user-suggestion-fix/gr-user-suggestion-fix';
-import {KnownExperimentId} from '../../../services/flags/flags';
-import {getAppContext} from '../../../services/app-context';
 import {
   getUserSuggestionFromString,
   USER_SUGGESTION_INFO_STRING,
@@ -42,8 +40,6 @@
   @state()
   private repoCommentLinks: CommentLinks = {};
 
-  private readonly flagsService = getAppContext().flagsService;
-
   private readonly getConfigModel = resolve(this, configModelToken);
 
   // Private const but used in tests.
@@ -158,10 +154,6 @@
   }
 
   private renderAsMarkdown() {
-    // Need to find out here, since customRender is not arrow function
-    const suggestEditsEnable = this.flagsService.isEnabled(
-      KnownExperimentId.SUGGEST_EDIT
-    );
     // Bind `this` via closure.
     const boundRewriteText = (text: string) => {
       const nonAsteriskRewrites = Object.fromEntries(
@@ -216,7 +208,7 @@
       renderer['codespan'] = (text: string) =>
         `<code>${unescapeHTML(text)}</code>`;
       renderer['code'] = (text: string, infostring: string) => {
-        if (suggestEditsEnable && infostring === USER_SUGGESTION_INFO_STRING) {
+        if (infostring === USER_SUGGESTION_INFO_STRING) {
           // default santizer in markedjs is very restrictive, we need to use
           // existing html element to mark element. We cannot use css class for
           // it. Therefore we pick mark - as not frequently used html element to
@@ -275,9 +267,7 @@
   override updated() {
     // Look for @mentions and replace them with an account-label chip.
     this.convertEmailsToAccountChips();
-    if (this.flagsService.isEnabled(KnownExperimentId.SUGGEST_EDIT)) {
-      this.convertCodeToSuggestions();
-    }
+    this.convertCodeToSuggestions();
   }
 
   private convertEmailsToAccountChips() {
diff --git a/polygerrit-ui/app/elements/shared/gr-user-suggestion-fix/gr-user-suggestion-fix.ts b/polygerrit-ui/app/elements/shared/gr-user-suggestion-fix/gr-user-suggestion-fix.ts
index ea67661..95c525a 100644
--- a/polygerrit-ui/app/elements/shared/gr-user-suggestion-fix/gr-user-suggestion-fix.ts
+++ b/polygerrit-ui/app/elements/shared/gr-user-suggestion-fix/gr-user-suggestion-fix.ts
@@ -5,8 +5,6 @@
  */
 import {css, html, LitElement, nothing} from 'lit';
 import {customElement} from 'lit/decorators.js';
-import {getAppContext} from '../../../services/app-context';
-import {KnownExperimentId} from '../../../services/flags/flags';
 import {fire} from '../../../utils/event-util';
 
 declare global {
@@ -23,8 +21,6 @@
 
 @customElement('gr-user-suggestion-fix')
 export class GrUserSuggetionFix extends LitElement {
-  private readonly flagsService = getAppContext().flagsService;
-
   static override get styles() {
     return [
       css`
@@ -65,9 +61,6 @@
   }
 
   override render() {
-    if (!this.flagsService.isEnabled(KnownExperimentId.SUGGEST_EDIT)) {
-      return nothing;
-    }
     if (!this.textContent) return nothing;
     const code = this.textContent;
     return html`<div class="header">
diff --git a/polygerrit-ui/app/services/flags/flags.ts b/polygerrit-ui/app/services/flags/flags.ts
index 7488e79..e55c6d3 100644
--- a/polygerrit-ui/app/services/flags/flags.ts
+++ b/polygerrit-ui/app/services/flags/flags.ts
@@ -18,5 +18,4 @@
   CHECKS_DEVELOPER = 'UiFeature__checks_developer',
   PUSH_NOTIFICATIONS_DEVELOPER = 'UiFeature__push_notifications_developer',
   PUSH_NOTIFICATIONS = 'UiFeature__push_notifications',
-  SUGGEST_EDIT = 'UiFeature__suggest_edit',
 }