Fix javascript errors in gr-admin-view components
To produce these errors, the repo must not exist, so it's as simple as
going to /admin/repos/<project-that-does-not-exist>.
Also this throws a 404 if it cannot fetch the configs.
Change-Id: I59b3bcb6ca78d2cc717993687d6560c0f2d96dbb
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
index d0af0f1..59a94c8 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.js
@@ -126,25 +126,40 @@
*/
_repoChanged(repo) {
if (!repo) { return Promise.resolve(); }
+
const promises = [];
+
+ const errFn = response => {
+ this.fire('page-error', {response});
+ };
+
// Always reset sections when a project changes.
this._sections = [];
- promises.push(this.$.restAPI.getRepoAccessRights(repo).then(res => {
- this._inheritsFrom = res.inherits_from;
- this._local = res.local;
- this._groups = res.groups;
- this._weblinks = res.config_web_links || [];
- this._canUpload = res.can_upload;
- return this.toSortedArray(this._local);
- }));
+ promises.push(this.$.restAPI.getRepoAccessRights(repo, errFn)
+ .then(res => {
+ if (!res) { return Promise.resolve(); }
- promises.push(this.$.restAPI.getCapabilities().then(res => {
- return res;
- }));
+ this._inheritsFrom = res.inherits_from;
+ this._local = res.local;
+ this._groups = res.groups;
+ this._weblinks = res.config_web_links || [];
+ this._canUpload = res.can_upload;
+ return this.toSortedArray(this._local);
+ }));
- promises.push(this.$.restAPI.getRepo(repo).then(res => {
- return res.labels;
- }));
+ promises.push(this.$.restAPI.getCapabilities(errFn)
+ .then(res => {
+ if (!res) { return Promise.resolve(); }
+
+ return res;
+ }));
+
+ promises.push(this.$.restAPI.getRepo(repo, errFn)
+ .then(res => {
+ if (!res) { return Promise.resolve(); }
+
+ return res.labels;
+ }));
promises.push(this.$.restAPI.getIsAdmin().then(isAdmin => {
this._isAdmin = isAdmin;