Commit 73c4cfb7 authored by kushalpandya's avatar kushalpandya

Refactor users list build up, fix isActive class for highlighting

parent 59f08f99
...@@ -309,23 +309,18 @@ export default class ProtectedTagAccessDropdown { ...@@ -309,23 +309,18 @@ export default class ProtectedTagAccessDropdown {
/* /*
* Build users * Build users
*/ */
const users = selectedItems.map((item) => { const users = selectedItems.filter(item => item.type === LEVEL_TYPES.USER).map((item) => {
let user = null; // Save identifiers for easy-checking more later
if (item.type === LEVEL_TYPES.USER) { map.push(LEVEL_TYPES.USER + item.user_id);
user = {
return {
id: item.user_id, id: item.user_id,
name: item.name, name: item.name,
username: item.username, username: item.username,
avatar_url: item.avatar_url, avatar_url: item.avatar_url,
type: LEVEL_TYPES.USER, type: LEVEL_TYPES.USER,
}; };
});
// Save identifiers for easy-checking more later
map.push(LEVEL_TYPES.USER + item.user_id);
}
return user;
}).filter(item => item !== null);
// Has to be checked against server response // Has to be checked against server response
// because the selected item can be in filter results // because the selected item can be in filter results
...@@ -430,7 +425,7 @@ export default class ProtectedTagAccessDropdown { ...@@ -430,7 +425,7 @@ export default class ProtectedTagAccessDropdown {
} }
userRowHtml(user, isActive) { userRowHtml(user, isActive) {
const isActiveClass = isActive ? 'isActive' : ''; const isActiveClass = isActive || '';
return ` return `
<li> <li>
...@@ -444,7 +439,7 @@ export default class ProtectedTagAccessDropdown { ...@@ -444,7 +439,7 @@ export default class ProtectedTagAccessDropdown {
} }
groupRowHtml(group, isActive) { groupRowHtml(group, isActive) {
const isActiveClass = isActive ? 'isActive' : ''; const isActiveClass = isActive || '';
const avatarEl = group.avatar_url ? `<img src='${group.avatar_url}' class='avatar avatar-inline' width='30'>` : ''; const avatarEl = group.avatar_url ? `<img src='${group.avatar_url}' class='avatar avatar-inline' width='30'>` : '';
return ` return `
...@@ -458,7 +453,7 @@ export default class ProtectedTagAccessDropdown { ...@@ -458,7 +453,7 @@ export default class ProtectedTagAccessDropdown {
} }
roleRowHtml(role, isActive) { roleRowHtml(role, isActive) {
const isActiveClass = isActive ? 'isActive' : ''; const isActiveClass = isActive || '';
return ` return `
<li> <li>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment