diff --git a/src/api/user/StatusAPI.js b/src/api/user/StatusAPI.js index dc62bb35d0..8380f6844c 100644 --- a/src/api/user/StatusAPI.js +++ b/src/api/user/StatusAPI.js @@ -140,9 +140,9 @@ export default class StatusAPI extends EventEmitter { const provider = this.#userAPI.getProvider(); if (provider.canProvideStatusForRole) { - return provider.canProvideStatusForRole(role); + return Promise.resolve(provider.canProvideStatusForRole(role)); } 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} 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} true if the configured UserProvider can provide status for the currently logged in user, false otherwise. * @see StatusUserProvider diff --git a/src/api/user/StatusUserProvider.js b/src/api/user/StatusUserProvider.js index 7c8d5bb63a..267d4ad133 100644 --- a/src/api/user/StatusUserProvider.js +++ b/src/api/user/StatusUserProvider.js @@ -77,5 +77,4 @@ export default class StatusUserProvider extends UserProvider { /** * @returns {Promise} the active status role for the currently logged in user */ - async getStatusRoleForCurrentUser() {} } diff --git a/src/plugins/operatorStatus/operatorStatus/OperatorStatus.vue b/src/plugins/operatorStatus/operatorStatus/OperatorStatus.vue index 3479a9312f..78446e55dd 100644 --- a/src/plugins/operatorStatus/operatorStatus/OperatorStatus.vue +++ b/src/plugins/operatorStatus/operatorStatus/OperatorStatus.vue @@ -94,11 +94,12 @@ export default { this.openmct.user.status.off('pollQuestionChange', this.setPollQuestion); }, async mounted() { + console.log('mounted') this.unsubscribe = []; await this.fetchUser(); this.fetchPossibleStatusesForUser(); this.fetchCurrentPoll(); - this.fetchMyStatus(); + await this.fetchMyStatus(); this.subscribeToMyStatus(); this.subscribeToPollQuestion(); }, @@ -123,8 +124,8 @@ export default { this.indicator.text(pollQuestion?.question || ''); }, async fetchMyStatus() { - const activeStatusRole = await this.openmct.user.status.getStatusRoleForCurrentUser(); - const status = await this.openmct.user.status.getStatusForRole(activeStatusRole); + const activeRole = await this.openmct.user.getActiveRole(); + const status = await this.openmct.user.status.getStatusForRole(activeRole); if (status !== undefined) { this.setStatus({status}); diff --git a/src/plugins/operatorStatus/plugin.js b/src/plugins/operatorStatus/plugin.js index 7d3afb8270..393d755132 100644 --- a/src/plugins/operatorStatus/plugin.js +++ b/src/plugins/operatorStatus/plugin.js @@ -30,7 +30,8 @@ export default function operatorStatusPlugin(configuration) { return function install(openmct) { if (openmct.user.hasProvider()) { - openmct.user.status.canProvideStatusForCurrentUser().then(canProvideStatus => { + const activeRole = openmct.user.getActiveRole(); + openmct.user.status.canProvideStatusForRole(activeRole).then(canProvideStatus => { if (canProvideStatus) { const operatorStatusIndicator = new OperatorStatusIndicator(openmct, configuration);