
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
127 lines
4.4 KiB
HTML
127 lines
4.4 KiB
HTML
<!--
|
|
@license
|
|
Copyright (C) 2017 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
|
|
|
<link rel="import" href="../../../behaviors/gr-access-behavior/gr-access-behavior.html">
|
|
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
|
|
<link rel="import" href="../../../behaviors/gr-url-encoding-behavior.html">
|
|
|
|
<link rel="import" href="../../../styles/gr-menu-page-styles.html">
|
|
<link rel="import" href="../../../styles/gr-subpage-styles.html">
|
|
<link rel="import" href="../../../styles/shared-styles.html">
|
|
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
|
<link rel="import" href="../gr-access-section/gr-access-section.html">
|
|
|
|
<script src="../../../scripts/util.js"></script>
|
|
|
|
<dom-module id="gr-repo-access">
|
|
<template>
|
|
<style include="shared-styles"></style>
|
|
<style include="gr-subpage-styles">
|
|
gr-button,
|
|
#inheritsFrom,
|
|
#editInheritFromInput,
|
|
.editing #inheritFromName,
|
|
.weblinks{
|
|
display: none;
|
|
}
|
|
#inheritsFrom.show {
|
|
display: flex;
|
|
min-height: 2em;
|
|
align-items: center;
|
|
}
|
|
.weblink {
|
|
margin-right: .2em;
|
|
}
|
|
.weblinks.show,
|
|
.referenceContainer {
|
|
display: block;
|
|
}
|
|
.rightsText {
|
|
margin-right: .3rem;
|
|
}
|
|
|
|
.editing gr-button,
|
|
.admin #editBtn {
|
|
display: inline-block;
|
|
margin: 1em 0;
|
|
}
|
|
.editing #editInheritFromInput {
|
|
display: inline-block;
|
|
}
|
|
</style>
|
|
<style include="gr-menu-page-styles"></style>
|
|
<main class$="[[_computeMainClass(_isAdmin, _canUpload, _editing)]]">
|
|
<div id="loading" class$="[[_computeLoadingClass(_loading)]]">
|
|
Loading...
|
|
</div>
|
|
<div id="loadedContent" class$="[[_computeLoadingClass(_loading)]]">
|
|
<h3 id="inheritsFrom" class$="[[_computeShowInherit(_inheritsFrom)]]">
|
|
<span class="rightsText">Rights Inherit From</span>
|
|
<a
|
|
href$="[[_computeParentHref(_inheritsFrom.name)]]"
|
|
rel="noopener"
|
|
id="inheritFromName">
|
|
[[_inheritsFrom.name]]</a>
|
|
<gr-autocomplete
|
|
id="editInheritFromInput"
|
|
text="{{_inheritFromFilter}}"
|
|
query="[[_query]]"
|
|
on-commit="_handleUpdateInheritFrom"></gr-autocomplete>
|
|
</h3>
|
|
<div class$="weblinks [[_computeWebLinkClass(_weblinks)]]">
|
|
History:
|
|
<template is="dom-repeat" items="[[_weblinks]]" as="link">
|
|
<a href="[[link.url]]" class="weblink" rel="noopener" target="[[link.target]]">
|
|
[[link.name]]
|
|
</a>
|
|
</template>
|
|
</div>
|
|
<gr-button id="editBtn"
|
|
on-tap="_handleEdit">[[_editOrCancel(_editing)]]</gr-button>
|
|
<gr-button id="saveBtn"
|
|
primary
|
|
on-tap="_handleSaveForReview"
|
|
disabled$="[[!_modified]]">
|
|
Save for review</gr-button>
|
|
<template
|
|
is="dom-repeat"
|
|
items="{{_sections}}"
|
|
initial-count="5"
|
|
target-framerate="60"
|
|
as="section">
|
|
<gr-access-section
|
|
capabilities="[[_capabilities]]"
|
|
section="{{section}}"
|
|
labels="[[_labels]]"
|
|
editing="[[_editing]]"
|
|
groups="[[_groups]]"
|
|
on-added-section-removed="_handleAddedSectionRemoved"></gr-access-section>
|
|
</template>
|
|
<div class="referenceContainer">
|
|
<gr-button id="addReferenceBtn"
|
|
on-tap="_handleCreateSection">Add Reference</gr-button>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
|
</template>
|
|
<script src="gr-repo-access.js"></script>
|
|
</dom-module>
|