UNPKG

@finos/legend-application

Version:
57 lines 3.02 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type SuperGenericFunction } from '@finos/legend-shared'; export declare const DEFAULT_NOTIFICATION_HIDE_TIME = 6000; export declare const DEFAULT_ERROR_NOTIFICATION_HIDE_TIME = 10000; export declare enum NOTIFCATION_SEVERITY { ILEGAL_STATE = "ILEGAL_STATE",// highest priority since this implies bugs - we expect user to never see this ERROR = "ERROR", WARNING = "WARNING", SUCCESS = "SUCCESS", INFO = "INFO" } export interface NotificationAction { icon: React.ReactNode; action: () => void; } export declare class Notification { severity: NOTIFCATION_SEVERITY; message: string; actions: NotificationAction[]; autoHideDuration?: number | undefined; constructor(severity: NOTIFCATION_SEVERITY, message: string, actions: NotificationAction[], autoHideDuration: number | undefined); } export declare class NotificationService { notification?: Notification | undefined; constructor(); setNotification(notification: Notification | undefined): void; notify(message: string, actions?: NotificationAction[], autoHideDuration?: number | null): void; notifySuccess(message: string, actions?: NotificationAction[], autoHideDuration?: number | null): void; notifyWarning(content: string | Error, actions?: NotificationAction[], autoHideDuration?: number | null): void; notifyError(content: Error | string, actions?: NotificationAction[]): void; getErrorMessage(content: Error | string): string | undefined; notifyIllegalState(message: string, actions?: NotificationAction[], autoHideDuration?: number | null): void; notifyUnsupportedFeature(featureName: string): void; /** * This function creates a more user-friendly way to throw error in the UI. Rather than crashing the whole app, we will * just notify and replacing the value should get with an alternative (e.g. `undefined`). A good use-case for this * is where we would not expect an error to throw (i.e. `IllegalStateError`), but we want to be sure that if the error * ever occurs, it still shows very apparently in the UI, as such, printing out in the console is not good enough, * but crashing the app is bad too, so this is a good balance. */ notifyAndReturnAlternativeOnError: <U extends SuperGenericFunction, W>(fn: U, alternative: W) => ReturnType<U> | W | undefined; } //# sourceMappingURL=NotificationService.d.ts.map