Add support for REVERTED file status

Screenshots https://imgur.com/a/mx6fyCc

Release-Notes: skip
Google-Bug-Id: b/241482688
Change-Id: I987af395972eccc0368215ff1aaa78f532114a5b
diff --git a/polygerrit-ui/app/api/rest-api.ts b/polygerrit-ui/app/api/rest-api.ts
index ab33eed..a7af005 100644
--- a/polygerrit-ui/app/api/rest-api.ts
+++ b/polygerrit-ui/app/api/rest-api.ts
@@ -90,6 +90,7 @@
   REWRITTEN = 'W',
   MODIFIED = 'M', // Not returned by BE, M is the default
   UNMODIFIED = 'U', // Not returned by BE, but added by UI for certain files
+  REVERTED = 'X', // Not returned by BE, but added by UI for certain files
 }
 
 /**
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index 115b709..20752b5 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -218,6 +218,8 @@
   // Private but used in tests.
   @state() filesLeftBase: NormalizedFileInfo[] = [];
 
+  @state() private filesRightBase: NormalizedFileInfo[] = [];
+
   // Private but used in tests.
   @state()
   loggedIn = false;
@@ -747,6 +749,13 @@
     );
     subscribe(
       this,
+      () => this.getFilesModel().filesRightBase$,
+      files => {
+        this.filesRightBase = [...files];
+      }
+    );
+    subscribe(
+      this,
       () => this.getBrowserModel().diffViewMode$,
       diffView => {
         this.diffViewMode = diffView;
@@ -1107,9 +1116,14 @@
     const fileWasAlreadyChanged = this.filesLeftBase.some(
       info => info.__path === file?.__path
     );
+    const fileIsReverted =
+      fileWasAlreadyChanged &&
+      !this.filesRightBase.some(info => info.__path === file?.__path);
     const newlyChanged = hasExtendedStatus && !fileWasAlreadyChanged;
 
-    const status = file?.status ?? FileInfoStatus.MODIFIED;
+    const status = fileIsReverted
+      ? FileInfoStatus.REVERTED
+      : file?.status ?? FileInfoStatus.MODIFIED;
     const left = `patchset ${this.patchRange?.basePatchNum}`;
     const right = `patchset ${this.patchRange?.patchNum}`;
     const postfix = ` between ${left} and ${right}`;
diff --git a/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status.ts b/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status.ts
index 0ccdc9b..578eda4 100644
--- a/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status.ts
+++ b/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status.ts
@@ -27,6 +27,8 @@
       return 'Rewritten';
     case FileInfoStatus.UNMODIFIED:
       return 'Unchanged';
+    case FileInfoStatus.REVERTED:
+      return 'Reverted';
     default:
       assertNever(status, `Unsupported status: ${status}`);
   }
@@ -73,6 +75,9 @@
           background-color: transparent;
           color: var(--file-status-font-color);
         }
+        div.status gr-icon {
+          color: var(--file-status-font-color);
+        }
         div.status.M {
           border: 1px solid var(--border-color);
           line-height: calc(var(--line-height-normal) - 2px);
@@ -92,6 +97,9 @@
         div.status.U {
           background-color: var(--file-status-unchanged);
         }
+        div.status.X {
+          background-color: var(--file-status-reverted);
+        }
         .size-16 {
           font-size: 16px;
           position: relative;
@@ -113,11 +121,18 @@
         tabindex="0"
         aria-label=${this.computeLabel()}
       >
-        ${this.status ?? ''}
+        ${this.renderIconOrLetter()}
       </div>
     </gr-tooltip-content>`;
   }
 
+  private renderIconOrLetter() {
+    if (this.status === FileInfoStatus.REVERTED) {
+      return html`<gr-icon small icon="undo"></gr-icon>`;
+    }
+    return html`<span>${this.status ?? ''}</span>`;
+  }
+
   private renderNewlyChanged() {
     if (!this.newlyChanged) return;
     return html`<gr-tooltip-content title=${this.computeLabel()} has-tooltip>
diff --git a/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status_test.ts b/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status_test.ts
index 9b4ddb5..f6624a9 100644
--- a/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-file-status/gr-file-status_test.ts
@@ -29,7 +29,7 @@
         element,
         /* HTML */ `
           <gr-tooltip-content has-tooltip="" title="">
-            <div class="status" aria-label="" tabindex="0"></div>
+            <div class="status" aria-label="" tabindex="0"><span></span></div>
           </gr-tooltip-content>
         `
       );
@@ -41,7 +41,9 @@
         element,
         /* HTML */ `
           <gr-tooltip-content has-tooltip="" title="Added">
-            <div class="A status" aria-label="Added" tabindex="0">A</div>
+            <div class="A status" aria-label="Added" tabindex="0">
+              <span>A</span>
+            </div>
           </gr-tooltip-content>
         `
       );
@@ -60,7 +62,9 @@
             ></gr-icon>
           </gr-tooltip-content>
           <gr-tooltip-content has-tooltip="" title="Newly Added">
-            <div class="A status" aria-label="Newly Added" tabindex="0">A</div>
+            <div class="A status" aria-label="Newly Added" tabindex="0">
+              <span>A</span>
+            </div>
           </gr-tooltip-content>
         `
       );
diff --git a/polygerrit-ui/app/styles/themes/app-theme.ts b/polygerrit-ui/app/styles/themes/app-theme.ts
index fb6a3a7..117e7cc 100644
--- a/polygerrit-ui/app/styles/themes/app-theme.ts
+++ b/polygerrit-ui/app/styles/themes/app-theme.ts
@@ -323,6 +323,7 @@
     --file-status-modified: var(--gray-300);
     --file-status-renamed: var(--orange-300);
     --file-status-unchanged: var(--gray-300);
+    --file-status-reverted: var(--gray-300);
 
     /* fonts */
     --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI',
diff --git a/polygerrit-ui/app/styles/themes/dark-theme.ts b/polygerrit-ui/app/styles/themes/dark-theme.ts
index 629b972..3388aed 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme.ts
+++ b/polygerrit-ui/app/styles/themes/dark-theme.ts
@@ -188,6 +188,7 @@
     --file-status-modified: var(--gray-500);
     --file-status-renamed: var(--orange-400);
     --file-status-unchanged: var(--gray-500);
+    --file-status-reverted: var(--gray-500);
 
     /* fonts */
     --font-weight-bold: 700; /* 700 is the same as 'bold' */