Improve Fix Suggestions UI

- hide fix suggestion when comment is collapsed
- show ML-Suggested Edit when fix suggestion is from ML
- extend suggestionsProvider
 - getFixSuggestionTitle for option to have own title for fix
suggestion
 - getDocumentationLink for ability to have own documentation link

Release-Notes: skip
Google-Bug-Id: b/326195247
Change-Id: I3cdf2eccc9864f5e1efc463b74a389d6733f4f1f
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 02d64ff..4d5889f 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
@@ -18,6 +18,8 @@
 import {changeModelToken} from '../../../models/change/change-model';
 import {Comment, isDraft, PatchSetNumber} from '../../../types/common';
 import {OpenFixPreviewEventDetail} from '../../../types/events';
+import {pluginLoaderToken} from '../gr-js-api-interface/gr-plugin-loader';
+import {SuggestionsProvider} from '../../../api/suggestions';
 
 /**
  * gr-fix-suggestions is UI for comment.fix_suggestions.
@@ -38,10 +40,15 @@
 
   @state() latestPatchNum?: PatchSetNumber;
 
+  @state()
+  suggestionsProvider?: SuggestionsProvider;
+
   private readonly getConfigModel = resolve(this, configModelToken);
 
   private readonly getChangeModel = resolve(this, changeModelToken);
 
+  private readonly getPluginLoader = resolve(this, pluginLoaderToken);
+
   constructor() {
     super();
     subscribe(
@@ -56,6 +63,18 @@
     );
   }
 
+  override connectedCallback() {
+    super.connectedCallback();
+    this.getPluginLoader()
+      .awaitPluginsLoaded()
+      .then(() => {
+        const suggestionsPlugins =
+          this.getPluginLoader().pluginsModel.getState().suggestionsPlugins;
+        // We currently support results from only 1 provider.
+        this.suggestionsProvider = suggestionsPlugins?.[0]?.provider;
+      });
+  }
+
   static override get styles() {
     return [
       css`
@@ -79,11 +98,19 @@
   }
 
   override render() {
+    if (!this.comment?.fix_suggestions) return;
+    const fix_suggestions = this.comment.fix_suggestions;
     return html`<div class="header">
         <div class="title">
-          <span>Suggested edit</span>
+          <span
+            >${this.suggestionsProvider?.getFixSuggestionTitle?.(
+              fix_suggestions
+            ) || 'Suggested edit'}</span
+          >
           <a
-            href=${getDocUrl(this.docsBaseUrl, 'user-suggest-edits.html')}
+            href=${this.suggestionsProvider?.getDocumentationLink?.(
+              fix_suggestions
+            ) || getDocUrl(this.docsBaseUrl, 'user-suggest-edits.html')}
             target="_blank"
             rel="noopener noreferrer"
             ><gr-icon icon="help" title="read documentation"></gr-icon