Update example user provider

This commit is contained in:
Michael Rogers 2023-05-26 16:54:25 -05:00
parent 6a9b9613e4
commit 6764ff0b33

View File

@ -58,7 +58,10 @@ const STATUSES = [{
* @implements {StatusUserProvider} * @implements {StatusUserProvider}
*/ */
export default class ExampleUserProvider extends EventEmitter { export default class ExampleUserProvider extends EventEmitter {
constructor(openmct, {defaultStatusRole} = {defaultStatusRole: undefined}) { constructor(openmct, {defaultStatusRole, statusRoles} = {
defaultStatusRole: undefined,
statusRoles: []
}) {
super(); super();
this.openmct = openmct; this.openmct = openmct;
@ -67,7 +70,9 @@ export default class ExampleUserProvider extends EventEmitter {
this.autoLoginUser = undefined; this.autoLoginUser = undefined;
this.status = STATUSES[0]; this.status = STATUSES[0];
this.pollQuestion = undefined; this.pollQuestion = undefined;
this.defaultStatusRole = defaultStatusRole; // this.defaultStatusRole = defaultStatusRole;
this.statusRoles = statusRoles;
this.selectedStatusRole = defaultStatusRole;
this.ExampleUser = createExampleUser(this.openmct.user.User); this.ExampleUser = createExampleUser(this.openmct.user.User);
this.loginPromise = undefined; this.loginPromise = undefined;
@ -96,7 +101,6 @@ export default class ExampleUserProvider extends EventEmitter {
canSetPollQuestion() { canSetPollQuestion() {
return Promise.resolve(true); return Promise.resolve(true);
} }
hasRole(roleId) { hasRole(roleId) {
if (!this.loggedIn) { if (!this.loggedIn) {
Promise.resolve(undefined); Promise.resolve(undefined);
@ -105,12 +109,20 @@ export default class ExampleUserProvider extends EventEmitter {
return Promise.resolve(this.user.getRoles().includes(roleId)); return Promise.resolve(this.user.getRoles().includes(roleId));
} }
getActiveRole() {
if (!this.loggedIn) {
Promise.resolve(undefined);
}
return Promise.resolve(this.user.getRoles())
}
getStatusRoleForCurrentUser() { getStatusRoleForCurrentUser() {
return Promise.resolve(this.defaultStatusRole);
return Promise.resolve(this.selectedStatusRole);
} }
getAllStatusRoles() { getAllStatusRoles() {
return Promise.resolve([this.defaultStatusRole]); return Promise.resolve(this.statusRoles);
} }
getStatusForRole(role) { getStatusForRole(role) {