ContentAlert.js.map 6.4 KB

1
  1. {"version":3,"sources":["../../src/app/content/ContentAlert.tsx"],"names":["React","Alert","AlertActionCloseButton","AlertGroup","AlertVariant","Msg","ContentAlert","Component","constructor","props","key","setState","alerts","state","filter","el","Date","getTime","variant","message","params","getUniqueId","push","localize","danger","setTimeout","hideAlert","instance","success","postAlert","warning","info","render","map"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AACA,SAASC,KAAT,EAAgBC,sBAAhB,EAAwCC,UAAxC,EAAoDC,YAApD;AACA,SAASC,GAAT;AAWA,OAAO,MAAMC,YAAN,SAA2BN,KAAK,CAACO,SAAjC,CAAiF;AAG5EC,EAAAA,WAAW,CAACC,KAAD,EAA2B;AAC1C,UAAMA,KAAN;;AAD0C,uCAqCzBC,GAAD,IAAiB;AACjC,WAAKC,QAAL,CAAc;AAAEC,QAAAA,MAAM,EAAE,CAAC,GAAG,KAAKC,KAAL,CAAWD,MAAX,CAAkBE,MAAlB,CAAyBC,EAAE,IAAIA,EAAE,CAACL,GAAH,KAAWA,GAA1C,CAAJ;AAAV,OAAd;AACH,KAvC6C;;AAAA,yCAyCxB,MAAO,IAAIM,IAAJ,GAAWC,OAAX,EAzCiB;;AAAA,uCA2C1B,CAACC,OAAD,EAAwBC,OAAxB,EAAyCC,MAAzC,KAA+D;AAC/E,YAAMR,MAAM,GAAG,KAAKC,KAAL,CAAWD,MAA1B;AACA,YAAMF,GAAG,GAAG,KAAKW,WAAL,EAAZ;AACAT,MAAAA,MAAM,CAACU,IAAP,CAAY;AACRZ,QAAAA,GADQ;AAERS,QAAAA,OAAO,EAAEd,GAAG,CAACkB,QAAJ,CAAaJ,OAAb,EAAsBC,MAAtB,CAFD;AAGRF,QAAAA;AAHQ,OAAZ;AAKA,WAAKP,QAAL,CAAc;AAAEC,QAAAA;AAAF,OAAd;;AAEA,UAAIM,OAAO,KAAKd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A;AAAhB,KAAD,KACnB,oBAAC,KAAD;AACI,sBAAcA,OADlB;AAEI,MAAA,YAAY,MAFhB;AAGI,MAAA,OAAO,EAAED,OAHb;AAII,MAAA,KAAK,EAAEC,OAJX;AAKI,MAAA,MAAM,EACF,oBAAC,sBAAD;AACI,QAAA,KAAK,EAAEA,OADX;AAEI,QAAA,YAAY,EAAG,GAAED,OAAQ,QAF7B;AAGI,QAAA,OAAO,EAAE,MAAM,KAAKQ,SAAL,CAAehB,GAAf;AAHnB,QANR;AAYI,MAAA,GAAG,EAAEA;AAZT,MADH,CADL,CADJ;AAmBH;;AAjFmF;;gBAA3EJ,Y","sourcesContent":["/*\n * Copyright 2019 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\nimport { Alert, AlertActionCloseButton, AlertGroup, AlertVariant } from '@patternfly/react-core';\nimport { Msg } from '../widgets/Msg';\n\ninterface ContentAlertProps { }\n\ninterface ContentAlertState {\n alerts: {\n key: number;\n message: string;\n variant: AlertVariant;\n }[];\n}\nexport class ContentAlert extends React.Component<ContentAlertProps, ContentAlertState> {\n private static instance: ContentAlert;\n\n private constructor(props: ContentAlertProps) {\n super(props);\n\n this.state = {\n alerts: []\n };\n ContentAlert.instance = this;\n }\n\n /**\n * @param message A literal text message or localization key.\n */\n public static success(message: string, params?: string[]): void {\n ContentAlert.instance.postAlert(AlertVariant.success, message, params);\n }\n\n /**\n * @param message A literal text message or localization key.\n */\n public static danger(message: string, params?: string[]): void {\n ContentAlert.instance.postAlert(AlertVariant.danger, message, params);\n }\n\n /**\n * @param message A literal text message or localization key.\n */\n public static warning(message: string, params?: string[]): void {\n ContentAlert.instance.postAlert(AlertVariant.warning, message, params);\n }\n\n /**\n * @param message A literal text message or localization key.\n */\n public static info(message: string, params?: string[]): void {\n ContentAlert.instance.postAlert(AlertVariant.info, message, params);\n }\n\n private hideAlert = (key: number) => {\n this.setState({ alerts: [...this.state.alerts.filter(el => el.key !== key)] });\n }\n\n private getUniqueId = () => (new Date().getTime());\n\n private postAlert = (variant: AlertVariant, message: string, params?: string[]) => {\n const alerts = this.state.alerts;\n const key = this.getUniqueId();\n alerts.push({\n key,\n message: Msg.localize(message, params),\n variant\n });\n this.setState({ alerts });\n\n if (variant !== AlertVariant.danger) {\n setTimeout(() => this.hideAlert(key), 8000);\n }\n }\n\n public render(): React.ReactNode {\n return (\n <AlertGroup isToast aria-live=\"assertive\">\n {this.state.alerts.map(({ key, variant, message }) => (\n <Alert\n aria-details={message}\n isLiveRegion\n variant={variant}\n title={message}\n action={\n <AlertActionCloseButton\n title={message}\n variantLabel={`${variant} alert`}\n onClose={() => this.hideAlert(key)}\n />\n }\n key={key} />\n ))}\n </AlertGroup>\n );\n }\n}"],"file":"ContentAlert.js"}