Move serverConfig from property to state

Release-Notes: skip
Change-Id: I82a225c7d497e3e116c6be7157da9479c517de48
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
index f44e7c5..f4cb25f 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
@@ -526,7 +526,6 @@
               <gr-commit-info
                 .change=${this.change}
                 .commitInfo=${parent}
-                .serverConfig=${this.serverConfig}
               ></gr-commit-info>
               <gr-tooltip-content
                 id="parentNotCurrentMessage"
@@ -553,7 +552,6 @@
             this.change?.current_revision,
             this.change?.revisions
           )}
-          .serverConfig=${this.serverConfig}
         ></gr-commit-info>
       </span>
     </section>`;
@@ -570,7 +568,6 @@
         <gr-commit-info
           .change=${this.change}
           .commitInfo=${this.computeRevertCommit()}
-          .serverConfig=${this.serverConfig}
         ></gr-commit-info>
       </span>
     </section>`;
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 0ec4b9c..441f512 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -1221,7 +1221,6 @@
               .permittedLabels=${this.change?.permitted_labels}
               .draftCommentThreads=${this.draftCommentThreads}
               .projectConfig=${this.projectConfig}
-              .serverConfig=${this.serverConfig}
               .canBeStarted=${this.canStartReview()}
               @send=${this.handleReplySent}
               @cancel=${this.handleReplyCancel}
@@ -1485,7 +1484,6 @@
             .changeUrl=${this.computeChangeUrl()}
             .editMode=${this.getEditMode()}
             .loggedIn=${this.loggedIn}
-            .serverConfig=${this.serverConfig}
             .shownFileCount=${this.shownFileCount}
             .patchNum=${this.patchRange?.patchNum}
             .basePatchNum=${this.patchRange?.basePatchNum}
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
index 97a2dca..e083a30 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
@@ -8,7 +8,10 @@
 import {ChangeInfo, CommitInfo, ServerInfo} from '../../../types/common';
 import {sharedStyles} from '../../../styles/shared-styles';
 import {LitElement, css, html} from 'lit';
-import {customElement, property} from 'lit/decorators';
+import {customElement, property, state} from 'lit/decorators';
+import {subscribe} from '../../lit/subscription-controller';
+import {resolve} from '../../../models/dependency';
+import {configModelToken} from '../../../models/config/config-model';
 
 declare global {
   interface HTMLElementTagNameMap {
@@ -28,8 +31,9 @@
   @property({type: Object})
   commitInfo: CommitInfo | undefined;
 
-  @property({type: Object})
-  serverConfig: ServerInfo | undefined;
+  @state() serverConfig: ServerInfo | undefined;
+
+  private readonly getConfigModel = resolve(this, configModelToken);
 
   static override get styles() {
     return [
@@ -43,6 +47,17 @@
     ];
   }
 
+  constructor() {
+    super();
+    subscribe(
+      this,
+      () => this.getConfigModel().serverConfig$,
+      config => {
+        this.serverConfig = config;
+      }
+    );
+  }
+
   override render() {
     return html` <div class="container">
       <a
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
index 209c3b7..8971950 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
@@ -40,6 +40,7 @@
 import {resolve} from '../../../models/dependency';
 import {getAppContext} from '../../../services/app-context';
 import {subscribe} from '../../lit/subscription-controller';
+import {configModelToken} from '../../../models/config/config-model';
 
 @customElement('gr-file-list-header')
 export class GrFileListHeader extends LitElement {
@@ -83,9 +84,6 @@
   @property({type: Boolean})
   loggedIn: boolean | undefined;
 
-  @property({type: Object})
-  serverConfig?: ServerInfo;
-
   @property({type: Number})
   shownFileCount = 0;
 
@@ -104,6 +102,9 @@
   @state()
   diffPrefs?: DiffPreferencesInfo;
 
+  @state()
+  serverConfig?: ServerInfo;
+
   @query('#modeSelect')
   modeSelect?: GrDiffModeSelector;
 
@@ -115,6 +116,8 @@
 
   private readonly getShortcutsService = resolve(this, shortcutsServiceToken);
 
+  private readonly getConfigModel = resolve(this, configModelToken);
+
   // Caps the number of files that can be shown and have the 'show diffs' /
   // 'hide diffs' buttons still be functional.
   private readonly maxFilesForBulkActions = 225;
@@ -131,6 +134,13 @@
         this.diffPrefs = diffPreferences;
       }
     );
+    subscribe(
+      this,
+      () => this.getConfigModel().serverConfig$,
+      config => {
+        this.serverConfig = config;
+      }
+    );
   }
 
   static override styles = [
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
index df83d7e..d86bd7a 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -105,6 +105,7 @@
 import {BindValueChangeEvent, ValueChangedEvent} from '../../../types/events';
 import {customElement, property, state, query} from 'lit/decorators';
 import {subscribe} from '../../lit/subscription-controller';
+import {configModelToken} from '../../../models/config/config-model';
 
 const STORAGE_DEBOUNCE_INTERVAL_MS = 400;
 
@@ -213,9 +214,6 @@
   @property({type: Object})
   projectConfig?: ConfigInfo;
 
-  @property({type: Object})
-  serverConfig?: ServerInfo;
-
   @query('#reviewers') reviewersList?: GrAccountList;
 
   @query('#ccs') ccsList?: GrAccountList;
@@ -231,6 +229,8 @@
   @query('#reviewerConfirmationOverlay')
   reviewerConfirmationOverlay?: GrOverlay;
 
+  @state() serverConfig?: ServerInfo;
+
   @state()
   draft = '';
 
@@ -332,6 +332,8 @@
 
   private readonly jsAPI = getAppContext().jsApiService;
 
+  private readonly getConfigModel = resolve(this, configModelToken);
+
   storeTask?: DelayedTask;
 
   private isLoggedIn = false;
@@ -593,6 +595,13 @@
       () => getAppContext().userModel.loggedIn$,
       isLoggedIn => (this.isLoggedIn = isLoggedIn)
     );
+    subscribe(
+      this,
+      () => this.getConfigModel().serverConfig$,
+      config => {
+        this.serverConfig = config;
+      }
+    );
   }
 
   override connectedCallback() {
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
index 9394ab1..0a446b9 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
@@ -423,7 +423,8 @@
         Verified: 0,
       },
       add_to_attention_set: [
-        {reason: 'Anonymous replied on the change', user: 314},
+        // Name coming from createUserConfig in test-data-generator
+        {reason: 'Name of user not set replied on the change', user: 314},
       ],
       reviewers: [],
       remove_from_attention_set: [],
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
index d4dff53d..42826c7 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
@@ -7,13 +7,16 @@
 import {ServerInfo} from '../../../types/common';
 import {getAppContext} from '../../../services/app-context';
 import {LitElement, css, html} from 'lit';
-import {customElement, property} from 'lit/decorators';
+import {customElement, property, state} from 'lit/decorators';
 import {sharedStyles} from '../../../styles/shared-styles';
 import {formStyles} from '../../../styles/gr-form-styles';
 import {PropertyValues} from 'lit';
 import {fire} from '../../../utils/event-util';
 import {ValueChangedEvent} from '../../../types/events';
 import {ColumnNames} from '../../../constants/constants';
+import {subscribe} from '../../lit/subscription-controller';
+import {resolve} from '../../../models/dependency';
+import {configModelToken} from '../../../models/config/config-model';
 
 @customElement('gr-change-table-editor')
 export class GrChangeTableEditor extends LitElement {
@@ -23,14 +26,16 @@
   @property({type: Boolean})
   showNumber?: boolean;
 
-  @property({type: Object})
-  serverConfig?: ServerInfo;
-
   @property({type: Array})
   defaultColumns: string[] = [];
 
+  @state()
+  serverConfig?: ServerInfo;
+
   private readonly flagsService = getAppContext().flagsService;
 
+  private readonly getConfigModel = resolve(this, configModelToken);
+
   static override styles = [
     sharedStyles,
     formStyles,
@@ -54,6 +59,17 @@
     `,
   ];
 
+  constructor() {
+    super();
+    subscribe(
+      this,
+      () => this.getConfigModel().serverConfig$,
+      config => {
+        this.serverConfig = config;
+      }
+    );
+  }
+
   override render() {
     return html`<div class="gr-form-styles">
       <table id="changeCols">
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
index 058a7b2..7d1a92f 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
@@ -463,7 +463,6 @@
                 this.showNumber = e.detail.value;
                 this.changeTableChanged = true;
               }}
-              .serverConfig=${this.serverConfig}
               .displayedColumns=${this.localChangeTableColumns}
               @displayed-columns-changed=${(e: ValueChangedEvent<string[]>) => {
                 this.localChangeTableColumns = e.detail.value;