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K,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,sBAAsB;IAIpF;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;CAsB3B","file":"client-notification-instance.d.ts","sourcesContent":["import { ClientNotification } from './client-notification';\r\nimport { NotificationConnection } from './notification-connection';\r\nimport { NotificationLinkType } from './notification-link-type';\r\nimport { NotificationState } from './notification-state';\r\n\r\nexport interface ClientNotificationLink {\r\n    /**\r\n     * The success link to navigate to the object view. (optional)\r\n     * At default, it brings to the home page of the module.\r\n     * The path is relative to from the manifest opened point unless linkType is specified\r\n     */\r\n    link: string;\r\n\r\n    /**\r\n     * The text to show up on the notification link text ex: \"Go to <linkText> on sme-xyz.domain.com\"\r\n     * By default the text will be the auto detected source name like \"Files\"\r\n     */\r\n    linkText?: string;\r\n\r\n    /**\r\n     * the type of notification link. Default behavior is RelativeToTool\r\n     */\r\n    linkType?: NotificationLinkType;\r\n}\r\n\r\n/**\r\n * Utility class to manage client notification\r\n */\r\nexport class ClientNotificationInstance {\r\n    private notification: ClientNotification;\r\n\r\n    /**\r\n     * Creates a new ClientNotificationInstance\r\n     * @param notificationConnection reference to NotificationConnection, can be found at AppContextService.notification\r\n     * @param nodeName the node name for the notification\r\n     */\r\n    constructor(private notificationConnection: NotificationConnection, private nodeName: string) {\r\n        this.notification = {\r\n            id: MsftSme.newGuid(),\r\n            state: NotificationState.InProgress,\r\n            title: '',\r\n            message: ''\r\n        };\r\n    }\r\n\r\n    /**\r\n     * Gets the notification ID to recycle.\r\n     * Sets this ID to the Work Item ID to share the notification.\r\n     */\r\n    public get id(): string {\r\n        return this.notification.id;\r\n    }\r\n\r\n    /**\r\n     * Shows an in progress notification\r\n     * This should be used for all started, submitted, in progress, or status update notifications\r\n     * @param title localized title for the notification. Should be like \"Executing some action\"\r\n     * @param message localized message for the notification. Should be natural language like \"Executing some action on target 'name'\"\r\n     * @param link optional custom link for notification\r\n     */\r\n    public showInProgress(title: string, message: string, link?: ClientNotificationLink) {\r\n        this.showNotification(title, message, link, NotificationState.InProgress);\r\n    }\r\n\r\n    /**\r\n     * Shows a critical notification\r\n     * @param title localized title for the notification.\r\n     * @param message localized message for the notification\r\n     * @param link optional custom link for notification\r\n     * @param solutionMessage optional solution message to address error\r\n     */\r\n    public showCritical(title: string, message: string, link?: ClientNotificationLink, solutionMessage?: string) {\r\n        this.showNotification(title, message, link, NotificationState.Critical, solutionMessage);\r\n    }\r\n\r\n    /**\r\n     * Shows an error notification\r\n     * @param title localized title for the notification. Should be like \"Failed to execute some action\"\r\n     * @param message localized message for the notification.\r\n     * Should be natural language like \"Failed to execute some action on target 'name'. Error: <error message>\"\r\n     * @param link optional custom link for notification\r\n     * @param solutionMessage optional solution message to address error\r\n     */\r\n    public showError(title: string, message: string, link?: ClientNotificationLink, solutionMessage?: string) {\r\n        this.showNotification(title, message, link, NotificationState.Error, solutionMessage);\r\n    }\r\n\r\n    /**\r\n     * Shows a warning notification\r\n     * @param title localized title for the notification.\r\n     * @param message localized message for the notification\r\n     * @param link optional custom link for notification\r\n     */\r\n    public showWarning(title: string, message: string, link?: ClientNotificationLink) {\r\n        this.showNotification(title, message, link, NotificationState.Warning);\r\n    }\r\n\r\n    /**\r\n     * Shows a success notification\r\n     * @param title localized title for the notification. Should be like \"Successfully executed some action\"\r\n     * @param message localized message for the notification.\r\n     * Should be natural language like \"Successfully executed some action on target 'name'\"\r\n     * @param link optional custom link for notification\r\n     */\r\n    public showSuccess(title: string, message: string, link?: ClientNotificationLink) {\r\n        this.showNotification(title, message, link, NotificationState.Success);\r\n    }\r\n\r\n    /**\r\n     * Shows an informational notification\r\n     * If the information is relative to an action currently in progress or already started, use showInProgressNotification\r\n     * @param title localized title for the notification.\r\n     * @param message localized message for the notification\r\n     * @param link optional custom link for notification\r\n     */\r\n    public showInformation(title: string, message: string, link?: ClientNotificationLink) {\r\n        this.showNotification(title, message, link, NotificationState.Informational);\r\n    }\r\n\r\n    /**\r\n     * show notification of given state\r\n     * @param title the localized title\r\n     * @param message the localized message\r\n     * @param link the link\r\n     * @param state the state\r\n     * @param solutionMessage optional solution message for error or critical notification\r\n     */\r\n    private showNotification(\r\n        title: string,\r\n        message: string,\r\n        link: ClientNotificationLink,\r\n        state: NotificationState,\r\n        solutionMessage?: string) {\r\n\r\n        if (MsftSme.isNullOrWhiteSpace(title) || MsftSme.isNullOrWhiteSpace(message)) {\r\n            throw new Error('Notification title and message must be defined and nonempty');\r\n        }\r\n\r\n        this.notification.state = state;\r\n        this.notification.title = title;\r\n        this.notification.message = message;\r\n        this.notification.solutionMessage = solutionMessage ? solutionMessage : null;\r\n\r\n        this.notification.link = link ? link.link : null;\r\n        this.notification.linkText = link ? link.linkText : null;\r\n        this.notification.linkType = link ? link.linkType : null;\r\n\r\n        this.notificationConnection.notify(this.nodeName, this.notification);\r\n    }\r\n}\r\n"]}