mirror of
https://github.com/nasa/openmct.git
synced 2025-01-13 16:29:57 +00:00
Added success notification and cleanup
This commit is contained in:
parent
c0e7804ccd
commit
ec7f954411
@ -58,8 +58,7 @@ const STATUSES = [{
|
||||
* @implements {StatusUserProvider}
|
||||
*/
|
||||
export default class ExampleUserProvider extends EventEmitter {
|
||||
constructor(openmct, {defaultStatusRole, statusRoles} = {
|
||||
defaultStatusRole: undefined,
|
||||
constructor(openmct, {statusRoles} = {
|
||||
statusRoles: []
|
||||
}) {
|
||||
super();
|
||||
@ -73,9 +72,7 @@ export default class ExampleUserProvider extends EventEmitter {
|
||||
status: STATUSES[0]
|
||||
}));
|
||||
this.pollQuestion = undefined;
|
||||
// this.defaultStatusRole = defaultStatusRole;
|
||||
this.statusRoles = statusRoles;
|
||||
this.selectedStatusRole = defaultStatusRole;
|
||||
|
||||
this.ExampleUser = createExampleUser(this.openmct.user.User);
|
||||
this.loginPromise = undefined;
|
||||
@ -123,9 +120,10 @@ export default class ExampleUserProvider extends EventEmitter {
|
||||
return this.user.getRoles();
|
||||
}
|
||||
|
||||
getStatusRoleForCurrentUser() {
|
||||
getStatusRoleForCurrentUser(role) {
|
||||
const matchedRole = this.statusRoleValues.find(x => x.role === role);
|
||||
|
||||
return Promise.resolve(this.selectedStatusRole);
|
||||
return Promise.resolve(matchedRole?.status);
|
||||
}
|
||||
|
||||
getAllStatusRoles() {
|
||||
|
@ -230,7 +230,9 @@ export default class StatusAPI extends EventEmitter {
|
||||
const provider = this.#userAPI.getProvider();
|
||||
|
||||
if (provider.getStatusRoleForCurrentUser) {
|
||||
return provider.getStatusRoleForCurrentUser();
|
||||
const activeRole = this.#userAPI.getActiveRole();
|
||||
|
||||
return provider.getStatusRoleForCurrentUser(activeRole);
|
||||
} else {
|
||||
this.#userAPI.error("User provider cannot provide role status for this user");
|
||||
}
|
||||
@ -244,7 +246,7 @@ export default class StatusAPI extends EventEmitter {
|
||||
const provider = this.#userAPI.getProvider();
|
||||
|
||||
if (provider.getStatusRoleForCurrentUser) {
|
||||
const activeStatusRole = await this.#userAPI.getProvider().getStatusRoleForCurrentUser();
|
||||
const activeStatusRole = await this.#userAPI.getActiveRole()
|
||||
const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole);
|
||||
|
||||
return canProvideStatus;
|
||||
|
@ -137,7 +137,7 @@ export default {
|
||||
subscribeToPollQuestion() {
|
||||
this.openmct.user.status.on('pollQuestionChange', this.setPollQuestion);
|
||||
},
|
||||
setStatus({role, status}) {
|
||||
setStatus({status}) {
|
||||
status = this.applyStyling(status);
|
||||
this.selectedStatus = status.key;
|
||||
this.indicator.iconClass(status.iconClassPoll);
|
||||
|
@ -59,16 +59,14 @@ export default {
|
||||
this.role = this.openmct.user.getActiveRole();
|
||||
this.loggedIn = this.openmct.user.isLoggedIn();
|
||||
},
|
||||
async fetchOrPromptForRole() {
|
||||
fetchOrPromptForRole() {
|
||||
const UserAPI = this.openmct.user;
|
||||
const activeRole = UserAPI.getActiveRole();
|
||||
this.selectedRole = activeRole;
|
||||
this.role = activeRole;
|
||||
if (!activeRole) {
|
||||
this.promptForRoleSelection();
|
||||
}
|
||||
|
||||
this.role = await this.openmct.user.status.getStatusRoleForCurrentUser();
|
||||
|
||||
},
|
||||
promptForRoleSelection() {
|
||||
const allRoles = this.openmct.user.getPossibleRoles();
|
||||
@ -82,9 +80,9 @@ export default {
|
||||
iconClass: 'info',
|
||||
title: 'Select Role',
|
||||
message: 'Please select your role for operator status.',
|
||||
currentSelection: this.selectedRole,
|
||||
currentSelection: this.role,
|
||||
onChange: (event) => {
|
||||
this.selectedRole = event.target.value;
|
||||
this.role = event.target.value;
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
@ -92,8 +90,8 @@ export default {
|
||||
emphasis: true,
|
||||
callback: () => {
|
||||
dialog.dismiss();
|
||||
//TODO: introduce a notification of success
|
||||
this.updateRole(this.selectedRole);
|
||||
this.updateRole(this.role);
|
||||
this.openmct.notifications.info(`Successfully set new role to ${this.role}`);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user