Add getConfig() method to plugin restApi interface The REST API interface of Gerrit core's UI has a method to retrieve the server config and to cache it. This method was not enabled in the REST API interface for plugins. However, to e.g. find out which account fields are editable it would be helpful to have access to the cached server config. Change-Id: Ida161f8adca075f6470b361290ba091d99e3996d
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js index eb0c7e0..10deb95 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js
@@ -38,6 +38,10 @@ return getRestApi().getVersion(); }; + GrPluginRestApi.prototype.getConfig = function() { + return getRestApi().getConfig(); + }; + GrPluginRestApi.prototype.invalidateReposCache = function() { getRestApi().invalidateReposCache(); };
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html index 5983621..7a59337 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html
@@ -42,6 +42,7 @@ send: sendStub, getLoggedIn: sandbox.stub(), getVersion: sandbox.stub(), + getConfig: sandbox.stub(), }; stub('gr-rest-api-interface', Object.keys(restApiStub).reduce((a, k) => { a[k] = (...args) => restApiStub[k](...args); @@ -133,12 +134,20 @@ }); }); - test('getConfig', () => { + test('getVersion', () => { restApiStub.getVersion.returns(Promise.resolve('foo bar')); return instance.getVersion().then(result => { assert.isTrue(restApiStub.getVersion.calledOnce); assert.equal(result, 'foo bar'); }); }); + + test('getConfig', () => { + restApiStub.getConfig.returns(Promise.resolve('foo bar')); + return instance.getConfig().then(result => { + assert.isTrue(restApiStub.getConfig.calledOnce); + assert.equal(result, 'foo bar'); + }); + }); }); </script>