Fix groups to prevent javascript errors with url
If you used the singleusergroup plugin, it would create
a group for the individual account. It won't include the url in the rest
api as you should not be able to view this group from the ui.
So when going to /admin/groups/1,members it would hide the group.
I am fixing this by doing "return;" which means it won't continue
to execute and get the url. As the url will throw an error as it would be undefined.
Bug: Issue 8644
Change-Id: I16feae0992e4976c48cc2faa0e471a3123414a9b
(cherry picked from commit dd9b6cab2b)
This commit is contained in:
@@ -156,10 +156,15 @@ limitations under the License.
|
||||
<template is="dom-repeat" items="[[_includedGroups]]">
|
||||
<tr>
|
||||
<td class="nameColumn">
|
||||
<a href$="[[_computeGroupUrl(item.url)]]"
|
||||
rel="noopener">
|
||||
<template is="dom-if" if="[[item.url]]">
|
||||
<a href$="[[_computeGroupUrl(item.url)]]"
|
||||
rel="noopener">
|
||||
[[item.name]]
|
||||
</a>
|
||||
</template>
|
||||
<template is="dom-if" if="[[!item.url]]">
|
||||
[[item.name]]
|
||||
</a>
|
||||
</template>
|
||||
</td>
|
||||
<td>[[item.description]]</td>
|
||||
<td class="deleteColumn">
|
||||
|
||||
@@ -116,6 +116,8 @@
|
||||
},
|
||||
|
||||
_computeGroupUrl(url) {
|
||||
if (!url) { return; }
|
||||
|
||||
const r = new RegExp(URL_REGEX, 'i');
|
||||
if (r.test(url)) {
|
||||
return url;
|
||||
|
||||
@@ -320,5 +320,20 @@ limitations under the License.
|
||||
assert.equal(element._itemId, 'testId3');
|
||||
assert.equal(element._itemName, 'testName3');
|
||||
});
|
||||
|
||||
test('_computeGroupUrl', () => {
|
||||
assert.isUndefined(element._computeGroupUrl(undefined));
|
||||
|
||||
assert.isUndefined(element._computeGroupUrl(false));
|
||||
|
||||
let url = '#/admin/groups/uuid-529b3c2605bb1029c8146f9de4a91c776fe64498';
|
||||
assert.equal(element._computeGroupUrl(url),
|
||||
'https://test/site/admin/groups/' +
|
||||
'uuid-529b3c2605bb1029c8146f9de4a91c776fe64498');
|
||||
|
||||
url = 'https://gerrit.local/admin/groups/' +
|
||||
'uuid-529b3c2605bb1029c8146f9de4a91c776fe64498';
|
||||
assert.equal(element._computeGroupUrl(url), url);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user