/** * Copyright (c) Cisco Systems, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { customElementWithCheck } from "@/mixins"; import { LitElement, html, property, internalProperty } from "lit-element"; import styles from "./scss/module.scss"; import "@momentum-ui/web-components/dist/comp/md-spinner"; import "@momentum-ui/web-components/dist/comp/md-button"; import { nothing } from "lit-html"; const cloudFailureImage = "https://cjaas.cisco.com/assets/img/cloud-failure-192.png"; export namespace ErrorNotification { @customElementWithCheck("cjaas-error-notification") export class ELEMENT extends LitElement { /** * @prop error * Error title to display */ @property({ type: String, attribute: "title" }) title = ""; /** * @prop tracking-id * Tracking ID */ @property({ type: String, attribute: "tracking-id" }) trackingId = ""; @property({ type: Boolean, attribute: "compact-view" }) compactView = false; @property({ type: Boolean, attribute: "tiny-view" }) tinyView = false; @internalProperty() showErrorDetails = false; handleTryAgain() { this.dispatchEvent(new CustomEvent("error-try-again", {})); } expandErrorDetails() { this.showErrorDetails = !this.showErrorDetails; } copyTrackingId() { if (this.trackingId) { navigator.clipboard.writeText(this.trackingId); } } renderErrorDetails() { if (this.showErrorDetails) { return html` Show Less

Please share the Tracking ID with site administrator or the support team to investigate the situation.

Tracking ID: ${this.trackingId}
`; } else { return html` Learn More `; } } static get styles() { return styles; } render() { if (this.tinyView) { return html`
${this.title}. Try Again
${this.trackingId ? html` Tracking ID: ${this.trackingId} ` : nothing}
`; } else if (this.compactView) { return html`
failure-image

${this.title}. Try Again

${this.trackingId ? this.renderErrorDetails() : nothing}
`; } else { return html`
failure-image

${this.title}

Try Again ${this.trackingId ? this.renderErrorDetails() : nothing}
`; } } } } declare global { interface HTMLElementTagNameMap { "cjaas-error-notification": ErrorNotification.ELEMENT; } }