PolyGerrit: Add support for muting and unmuting changes

Bug: Issue 6191
Change-Id: I95f01ed91e839c213987e3d5da68ca612c6e311c
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 7e53ea2..e901eab 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -48,11 +48,13 @@
     ABANDON: 'abandon',
     DELETE: '/',
     IGNORE: 'ignore',
+    MUTE: 'mute',
     PRIVATE: 'private',
     PRIVATE_DELETE: 'private.delete',
     RESTORE: 'restore',
     REVERT: 'revert',
     UNIGNORE: 'unignore',
+    UNMUTE: 'unmute',
     WIP: 'wip',
   };
 
@@ -225,6 +227,14 @@
             },
             {
               type: ActionType.CHANGE,
+              key: ChangeActions.MUTE,
+            },
+            {
+              type: ActionType.CHANGE,
+              key: ChangeActions.UNMUTE,
+            },
+            {
+              type: ActionType.CHANGE,
               key: ChangeActions.PRIVATE,
             },
             {
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
index ca562fe..8aa6bab 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -731,6 +731,85 @@
       });
     });
 
+    suite('mute change', () => {
+      setup(done => {
+        sandbox.stub(element, '_fireAction');
+
+        const MuteAction = {
+          __key: 'mute',
+          __type: 'change',
+          __primary: false,
+          method: 'PUT',
+          label: 'Mute',
+          title: 'Working...',
+          enabled: true,
+        };
+
+        element.actions = {
+          mute: MuteAction,
+        };
+
+        element.changeNum = '2';
+        element.patchNum = '2';
+
+        element.reload().then(() => {flush(done);});
+      });
+
+      test('make sure the mute button is not outside of the overflow menu',
+          () => {
+            assert.isNotOk(element.$$('[data-action-key="mute"]'));
+          });
+
+      test('muting change', () => {
+        assert.isOk(element.$.moreActions.$$('span[data-id="mute-change"]'));
+        element.setActionOverflow('change', 'mute', false);
+        flushAsynchronousOperations();
+        assert.isOk(element.$$('[data-action-key="mute"]'));
+        assert.isNotOk(
+            element.$.moreActions.$$('span[data-id="mute-change"]'));
+      });
+    });
+
+    suite('unmute change', () => {
+      setup(done => {
+        sandbox.stub(element, '_fireAction');
+
+        const UnmuteAction = {
+          __key: 'unmute',
+          __type: 'change',
+          __primary: false,
+          method: 'PUT',
+          label: 'Unmute',
+          title: 'Working...',
+          enabled: true,
+        };
+
+        element.actions = {
+          unmute: UnmuteAction,
+        };
+
+        element.changeNum = '2';
+        element.patchNum = '2';
+
+        element.reload().then(() => {flush(done);});
+      });
+
+
+      test('unmute button not outside of the overflow menu', () => {
+        assert.isNotOk(element.$$('[data-action-key="unmute"]'));
+      });
+
+      test('unmuting change', () => {
+        assert.isOk(
+            element.$.moreActions.$$('span[data-id="unmute-change"]'));
+        element.setActionOverflow('change', 'unmute', false);
+        flushAsynchronousOperations();
+        assert.isOk(element.$$('[data-action-key="unmute"]'));
+        assert.isNotOk(
+            element.$.moreActions.$$('span[data-id="unmute-change"]'));
+      });
+    });
+
     suite('quick approve', () => {
       setup(() => {
         element.change = {
@@ -800,7 +879,7 @@
         assert.isNull(approveButton);
       });
 
-      test('approves when taped', () => {
+      test('approves when tapped', () => {
         const fireActionStub = sandbox.stub(element, '_fireAction');
         MockInteractions.tap(
             element.$$('gr-button[data-action-key=\'review\']'));