PG: Skip unsupported global capabilities

In general Gerrit shouldn't care about configurations it doesn't use.
The same goes for the UI.

Bug: Issue 11368
Change-Id: I0bb2188e6d68591506e4141a56b900a09ce784e7
This commit is contained in:
Sven Selberg
2020-06-10 17:11:59 +02:00
parent dd9970baaf
commit b5f183e91e
2 changed files with 27 additions and 20 deletions

View File

@@ -83,7 +83,15 @@
},
_updateSection(section) {
this._permissions = this.toSortedArray(section.value.permissions);
let permissions = this.toSortedArray(section.value.permissions);
// We do not care about permissions for global capabilities that are not
// currently supported by the server (f.i. capabilities provided by
// plugins that are no longer installed).
if (section.id === GLOBAL_NAME) {
permissions = permissions.filter(
p => this.capabilities.hasOwnProperty(p.id));
}
this._permissions = permissions;
this._originalId = section.id;
},

View File

@@ -329,6 +329,24 @@ limitations under the License.
default_value: 0,
},
};
element.capabilities = {
accessDatabase: {
id: 'accessDatabase',
name: 'Access Database',
},
administrateServer: {
id: 'administrateServer',
name: 'Administrate Server',
},
batchChangesLimit: {
id: 'batchChangesLimit',
name: 'Batch Changes Limit',
},
createAccount: {
id: 'createAccount',
name: 'Create Account',
},
};
});
suite('Global section', () => {
setup(() => {
@@ -342,24 +360,6 @@ limitations under the License.
},
},
};
element.capabilities = {
accessDatabase: {
id: 'accessDatabase',
name: 'Access Database',
},
administrateServer: {
id: 'administrateServer',
name: 'Administrate Server',
},
batchChangesLimit: {
id: 'batchChangesLimit',
name: 'Batch Changes Limit',
},
createAccount: {
id: 'createAccount',
name: 'Create Account',
},
};
element._updateSection(element.section);
flushAsynchronousOperations();
});
@@ -387,7 +387,6 @@ limitations under the License.
},
},
};
element.capabilities = {};
element._updateSection(element.section);
flushAsynchronousOperations();
});