gerrit/polygerrit-ui/app/elements/admin/gr-permission
Becky Siegel 7c57cf9104 Fix access removal of added item
Previously, when removing an added item (of any type) nested inside of
another added type, the removal has no effect. This is because, in the
case of an add, there is no corresponding remove object, as there is
in the case of a modified section.

Example:

Modified access rules with a new ref and rule-2 was removed before
saving.

{
  ...,
  refs/for/new: {
    added: true,
    permissions: {
      permission-1: {
        added: true,
        rules {
          rule-1: {
            added: true,
            action: 'ALLOW"
          },
          rule-2: {
            added: true,
            removed: true,
            action: 'ALLOW"
          }
        }
      }
    }
  }
}

This change fixes the problem by actually removing the item completely
if it was added in the first place, as opposed to keeping a placeholder
that can be undone, which makes sense as both ways allow restoration
of the initial state of the access object.

The new access JSON for this example is as follows:
There is no reason for rule-2 to be in here at all because the server
does not have to remove it (it did not exist before).

{
  ...,
  refs/for/new: {
    added: true,
    permissions: {
      permission-1: {
        added: true,
        rules {
          rule-1: {
            added: true,
            action: 'ALLOW"
          },
        }
      }
    }
  }
}

Bug: Issue 8795
Change-Id: Ief7ebd18f0ad207358b68f504ffe2b0b322340f9
2018-04-23 14:44:46 -07:00
..
gr-permission_test.html Fix access removal of added item 2018-04-23 14:44:46 -07:00
gr-permission.html Fix access removal of added item 2018-04-23 14:44:46 -07:00
gr-permission.js Fix access removal of added item 2018-04-23 14:44:46 -07:00