Removed status.getStatusRoleForCurrentUser

This commit is contained in:
Michael Rogers 2023-06-16 18:18:30 -05:00
parent c52ee6c40d
commit 56827ad17b
4 changed files with 8 additions and 24 deletions

View File

@ -140,9 +140,9 @@ export default class StatusAPI extends EventEmitter {
const provider = this.#userAPI.getProvider(); const provider = this.#userAPI.getProvider();
if (provider.canProvideStatusForRole) { if (provider.canProvideStatusForRole) {
return provider.canProvideStatusForRole(role); return Promise.resolve(provider.canProvideStatusForRole(role));
} else { } else {
return false; return Promise.resolve(false);
} }
} }
@ -221,23 +221,6 @@ export default class StatusAPI extends EventEmitter {
} }
} }
/**
* The status role of the current user. A user may have multiple roles, but will only have one role
* that provides status at any time.
* @returns {Promise<import("./UserAPI").Role>} the role for which the current user can provide status.
*/
getStatusRoleForCurrentUser() {
const provider = this.#userAPI.getProvider();
if (provider.getStatusRoleForCurrentUser) {
const activeRole = this.#userAPI.getActiveRole();
return provider.getStatusRoleForCurrentUser(activeRole);
} else {
this.#userAPI.error("User provider cannot provide role status for this user");
}
}
/** /**
* @returns {Promise<Boolean>} true if the configured UserProvider can provide status for the currently logged in user, false otherwise. * @returns {Promise<Boolean>} true if the configured UserProvider can provide status for the currently logged in user, false otherwise.
* @see StatusUserProvider * @see StatusUserProvider

View File

@ -77,5 +77,4 @@ export default class StatusUserProvider extends UserProvider {
/** /**
* @returns {Promise<import("./UserAPI").Role>} the active status role for the currently logged in user * @returns {Promise<import("./UserAPI").Role>} the active status role for the currently logged in user
*/ */
async getStatusRoleForCurrentUser() {}
} }

View File

@ -94,11 +94,12 @@ export default {
this.openmct.user.status.off('pollQuestionChange', this.setPollQuestion); this.openmct.user.status.off('pollQuestionChange', this.setPollQuestion);
}, },
async mounted() { async mounted() {
console.log('mounted')
this.unsubscribe = []; this.unsubscribe = [];
await this.fetchUser(); await this.fetchUser();
this.fetchPossibleStatusesForUser(); this.fetchPossibleStatusesForUser();
this.fetchCurrentPoll(); this.fetchCurrentPoll();
this.fetchMyStatus(); await this.fetchMyStatus();
this.subscribeToMyStatus(); this.subscribeToMyStatus();
this.subscribeToPollQuestion(); this.subscribeToPollQuestion();
}, },
@ -123,8 +124,8 @@ export default {
this.indicator.text(pollQuestion?.question || ''); this.indicator.text(pollQuestion?.question || '');
}, },
async fetchMyStatus() { async fetchMyStatus() {
const activeStatusRole = await this.openmct.user.status.getStatusRoleForCurrentUser(); const activeRole = await this.openmct.user.getActiveRole();
const status = await this.openmct.user.status.getStatusForRole(activeStatusRole); const status = await this.openmct.user.status.getStatusForRole(activeRole);
if (status !== undefined) { if (status !== undefined) {
this.setStatus({status}); this.setStatus({status});

View File

@ -30,7 +30,8 @@ export default function operatorStatusPlugin(configuration) {
return function install(openmct) { return function install(openmct) {
if (openmct.user.hasProvider()) { if (openmct.user.hasProvider()) {
openmct.user.status.canProvideStatusForCurrentUser().then(canProvideStatus => { const activeRole = openmct.user.getActiveRole();
openmct.user.status.canProvideStatusForRole(activeRole).then(canProvideStatus => {
if (canProvideStatus) { if (canProvideStatus) {
const operatorStatusIndicator = new OperatorStatusIndicator(openmct, configuration); const operatorStatusIndicator = new OperatorStatusIndicator(openmct, configuration);