Show Edit File Actions for commit message

You can open commit message and edit it in EDIT MODE. But there isn't
ACTIONS dropdown on commit message row. This change is adding this,
but dropdown has only OPEN actions since other actions doesn't make
sense for commit message.

Google-Bug-Id: b/332835638
Release-Notes: skip
Change-Id: I1a63c09ae0c78ac0fd74a15f441c13df43740c2e
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 dc75a16..48e3118 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
@@ -1489,7 +1489,11 @@
         this.editMode,
         () => html`
           <gr-edit-file-controls
-            class=${this.computeClass('', file.__path)}
+            class=${this.computeClass(
+              '',
+              file.__path,
+              /* showForCommitMessage */ true
+            )}
             .filePath=${file.__path}
           ></gr-edit-file-controls>
         `
@@ -2276,11 +2280,17 @@
     return delta > 0 ? 'added' : 'removed';
   }
 
-  private computeClass(baseClass?: string, path?: string) {
-    const classes = [];
-    if (baseClass) classes.push(baseClass);
-    if (isMagicPath(path)) classes.push('invisible');
-    return classes.join(' ');
+  // Private but used in tests.
+  computeClass(baseClass = '', path?: string, showForCommitMessage = false) {
+    const classes = [baseClass];
+    if (
+      !(showForCommitMessage && path === SpecialFilePath.COMMIT_MESSAGE) &&
+      isMagicPath(path)
+    ) {
+      classes.push('invisible');
+    }
+
+    return classes.join(' ').trim();
   }
 
   private computePathClass(path: string | undefined) {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
index 1cfbb83..eec829a 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
@@ -39,6 +39,7 @@
 import {
   createDefaultDiffPrefs,
   DiffViewMode,
+  SpecialFilePath,
 } from '../../../constants/constants';
 import {
   assertIsDefined,
@@ -2259,11 +2260,41 @@
       element.editMode = true;
       await element.updateComplete;
 
-      // Commit message should not have edit controls.
+      // Commit message can have edit controls.
       const editControls = Array.from(
         queryAll(element, '.row:not(.header-row)')
       ).map(row => row.querySelector('gr-edit-file-controls'));
-      assert.isTrue(editControls[0]!.classList.contains('invisible'));
+      assert.isFalse(editControls[0]!.classList.contains('invisible'));
+    });
+  });
+
+  suite('computeClass', () => {
+    test('works', () => {
+      assert.equal(
+        element.computeClass(
+          '',
+          SpecialFilePath.MERGE_LIST,
+          /* showForCommitMessage */ true
+        ),
+        'invisible'
+      );
+      assert.equal(
+        element.computeClass(
+          '',
+          SpecialFilePath.COMMIT_MESSAGE,
+          /* showForCommitMessage */ true
+        ),
+        ''
+      );
+      assert.equal(
+        element.computeClass(
+          '',
+          SpecialFilePath.COMMIT_MESSAGE,
+          /* showForCommitMessage */ false
+        ),
+        'invisible'
+      );
+      assert.equal(element.computeClass('', 'file.java'), '');
     });
   });
 });
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
index 7e49a12..e343a01 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
@@ -11,6 +11,7 @@
 import {customElement, property} from 'lit/decorators.js';
 import {fire} from '../../../utils/event-util';
 import {DropdownLink} from '../../../types/common';
+import {SpecialFilePath} from '../../../constants/constants';
 
 interface EditAction {
   label: string;
@@ -76,12 +77,18 @@
 
   _computeFileActions(actions: EditAction[]): DropdownLink[] {
     // TODO(kaspern): conditionally disable some actions based on file status.
-    return actions.map(action => {
-      return {
-        name: action.label,
-        id: action.id,
-      };
-    });
+    return actions
+      .filter(
+        action =>
+          this.filePath !== SpecialFilePath.COMMIT_MESSAGE ||
+          action.label === GrEditConstants.Actions.OPEN.label
+      )
+      .map(action => {
+        return {
+          name: action.label,
+          id: action.id,
+        };
+      });
   }
 }