-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ui - display all domains that reference current user #2789
base: master
Are you sure you want to change the base?
ui - display all domains that reference current user #2789
Conversation
ui/src/api.js
Outdated
|
||
listUserDomains(roleName) { | ||
listUserDomains() { | ||
return new Promise((resolve, reject) => { | ||
fetchr | ||
.read('domain-list') | ||
.params({ roleName }) | ||
.read('domain-role-member') | ||
.params({ expand: true }) | ||
.end((err, data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using different api to obtain domain details. not passing principal as it is picked up from the request context
930d5ca
to
fdd4fe9
Compare
Signed-off-by: aporss <[email protected]>
fdd4fe9
to
f0d2cee
Compare
ui/src/redux/thunks/domains.js
Outdated
|
||
|
||
const transformDomainListResult = (domainsData) => { | ||
let domainsToReturn = []; | ||
|
||
// 'prefix' is a list of unique domain names for given principal | ||
if (!domainsData || !domainsData.memberRoles || !domainsData['prefix']) { | ||
return domainsToReturn; | ||
} | ||
|
||
let adminDomains = new Set(); | ||
let nonAdminDomains = domainsData['prefix'].slice(); // list of all unique domain names | ||
|
||
// processing non-admin domains separately because user can be an admin of same domain only once | ||
// but can be non-admin member of same domain via multiple roles/groups | ||
domainsData.memberRoles.forEach(role => { | ||
if (role.roleName === 'admin') { | ||
// create admin domain object | ||
adminDomains.add({ | ||
name: role.domainName, | ||
adminDomain: true | ||
}); | ||
// remove admin domain from list of non admin domains | ||
const adminDomainIndex = nonAdminDomains.indexOf(role.domainName); | ||
nonAdminDomains.splice(adminDomainIndex, 1); | ||
} | ||
}); | ||
|
||
// add admin domains | ||
domainsToReturn.push(...adminDomains); | ||
|
||
// create and add non admin domains | ||
nonAdminDomains.forEach(domain => { | ||
domainsToReturn.push({ | ||
name: domain, | ||
adminDomain: false | ||
}) | ||
}) | ||
|
||
// sorting domains alphabetically | ||
domainsToReturn.sort((a, b) => a.name.localeCompare(b.name)); | ||
|
||
return domainsToReturn; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to docs thunks is the preferred location for data transformation, not the reducers
const domainsData = await API().listUserDomains(); | ||
const domainsList = transformDomainListResult(domainsData); | ||
dispatch(loadUserDomainList(domainsList)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transforming data returned by fetchr
By changing API call - the returned data format was changed thus breaking the snapshot generation. |
Signed-off-by: aporss <[email protected]>
js file reformatting was done on some files unrelated to pr because these files were failing github build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only formatting change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only formatting change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only formatting change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only formatting change
Description
Change to UI domains list for current user to include domains with indirect membership, e.g. domains that assume delegated roles.
Contribution Checklist: