[Missing Object] Notifications are shown as minimized (#6416)

* Add minimize to the notification model and minimize missing object notifications

* Add test

* Short circuit telemetry api functions if passed in domainObject is missing/type unknown

* Clear notifications properly after test
This commit is contained in:
Khalid Adil 2023-03-14 13:36:45 -05:00 committed by GitHub
parent b5002e166a
commit 600890c4a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 3 deletions

View File

@ -54,6 +54,7 @@ import EventEmitter from 'eventemitter3';
/**
* @typedef {object} NotificationOptions
* @property {number} [autoDismissTimeout] Milliseconds to wait before automatically dismissing the notification
* @property {boolean} [minimized] Allows for a notification to be minimized into the indicator by default
* @property {NotificationLink} [link] A link for the notification
*/
@ -327,7 +328,7 @@ export default class NotificationAPI extends EventEmitter {
/*
Check if there is already an active (ie. visible) notification
*/
if (!this.activeNotification) {
if (!this.activeNotification && !notification?.model?.options?.minimized) {
this._setActiveNotification(notification);
} else if (!this.activeTimeout) {
/*

View File

@ -108,6 +108,24 @@ describe('The Notifiation API', () => {
});
});
describe('the error method notificiation', () => {
let message = 'Minimized error message';
afterAll(() => {
notificationAPIInstance.dismissAllNotifications();
});
it('is not shown if configured to show minimized', (done) => {
notificationAPIInstance.activeNotification = undefined;
notificationAPIInstance.error(message, { minimized: true });
window.setTimeout(() => {
expect(notificationAPIInstance.notifications.length).toEqual(1);
expect(notificationAPIInstance.activeNotification).toEqual(undefined);
done();
}, defaultTimeout);
});
});
describe('the progress method', () => {
let title = 'This is a progress notification';
let message1 = 'Example progress message 1';

View File

@ -264,7 +264,7 @@ export default class TelemetryAPI {
* telemetry data
*/
async request(domainObject) {
if (this.noRequestProviderForAllObjects) {
if (this.noRequestProviderForAllObjects || domainObject.type === 'unknown') {
return [];
}
@ -318,6 +318,10 @@ export default class TelemetryAPI {
* the subscription
*/
subscribe(domainObject, callback, options) {
if (domainObject.type === 'unknown') {
return () => {};
}
const provider = this.#findSubscriptionProvider(domainObject);
if (!this.subscribeCache) {

View File

@ -129,6 +129,9 @@ export default class TelemetryCollection extends EventEmitter {
this.emit('requestStarted');
const modifiedOptions = await this.openmct.telemetry.applyRequestInterceptors(this.domainObject, options);
historicalData = await historicalProvider.request(this.domainObject, modifiedOptions);
if (!historicalData || !historicalData.length) {
return;
}
} catch (error) {
if (error.name !== 'AbortError') {
console.error('Error requesting telemetry data...');

View File

@ -28,7 +28,7 @@ export default function MissingObjectInterceptor(openmct) {
invoke: (identifier, object) => {
if (object === undefined) {
const keyString = openmct.objects.makeKeyString(identifier);
openmct.notifications.error(`Failed to retrieve object ${keyString}`);
openmct.notifications.error(`Failed to retrieve object ${keyString}`, { minimized: true });
return {
identifier,