Add support for the new list-owner rest API
The backend is going to return an object instead of an array.
See the following change for the details:
https://gerrit-review.googlesource.com/c/plugins/code-owners/+/293806
Change-Id: I61b5dba2cc725779c9c5b32c4f089727fde87c8f
diff --git a/ui/code-owners-service.js b/ui/code-owners-service.js
index 8bb14d1..cf9f1f5 100644
--- a/ui/code-owners-service.js
+++ b/ui/code-owners-service.js
@@ -277,7 +277,11 @@
try {
const owners = await this.codeOwnerApi.listOwnersForPath(changeId,
filePath);
- this._fetchedOwners.get(filePath).owners = new Set(owners);
+ // In the upcoming backend changes, the api will return an object instead
+ // of array. While this transition is in progress, the frontend supports
+ // both API - the old one and the new one.
+ this._fetchedOwners.get(filePath).owners = new Set(
+ owners instanceof Array ? owners : owners.code_owners);
} catch (e) {
this._fetchedOwners.get(filePath).error = e;
}