11import * as React from "react" ;
2+ import { css } from "@emotion/react" ;
23import {
34 Dialog ,
45 DialogActions ,
@@ -14,18 +15,28 @@ import BloomButton from "../react_components/bloomButton";
1415import { makeTheme , kindParams } from "./theme" ;
1516import { useL10n } from "../react_components/l10nHooks" ;
1617import { ProblemKind } from "./ProblemDialog" ;
18+ import { hookupLinkHandler } from "../utils/linkHandler" ;
19+ import { kBloomBlue , kFormBackground } from "../utils/colorUtils" ;
1720
18- export const NotifyDialog : React . FunctionComponent < {
19- reportLabel ?: string | null ;
20- secondaryLabel ?: string | null ;
21- message : string | null ;
22- } > = props => {
23- const theme = makeTheme ( ProblemKind . NonFatal ) ;
21+ export interface INotifyDialogProps {
22+ message ?: string | null ; // The localized message to notify the user about.
23+ reportLabel ?: string | null ; // The localized text that goes on the Report button. Omit or pass "" to disable Report button.
24+ secondaryLabel ?: string | null ; // The localized text that goes on the secondary action button. Omit or pass "" to disable the secondary action button.
25+ detailsBoxText ?: string | null ; // Localized text to go into a grey details box under the message. Omit or pass "" to not show a details box.
26+ titleOverride ?: string | null ; // If present, wil be used in place of the dialog title defined for this level in themes.ts
27+ titleL10nKeyOverride ?: string | null ; // The L10nKey for the titleOverride, if present.
28+ themeOverride ?: ProblemKind | null ; // If present, will be used in place of the dialog theme defined for this level in themes.ts
29+ }
2430
25- const englishTitle = kindParams [ ProblemKind . NonFatal ] . title ;
26- const titleKey = kindParams [ ProblemKind . NonFatal ] . l10nKey ;
31+ export const NotifyDialog : React . FC < INotifyDialogProps > = props => {
32+ const theme = makeTheme ( props . themeOverride || ProblemKind . NonFatal ) ;
33+
34+ const englishTitle = props . titleOverride ?? kindParams [ ProblemKind . NonFatal ] . title ;
35+ const titleKey = props . titleL10nKeyOverride ?? kindParams [ ProblemKind . NonFatal ] . l10nKey ;
2736 const localizedDlgTitle = useL10n ( englishTitle , titleKey ) ;
2837
38+ React . useEffect ( ( ) => hookupLinkHandler ( ) , [ ] ) ;
39+
2940 const getDialog = ( ) => {
3041 return (
3142 < Dialog
@@ -45,16 +56,32 @@ export const NotifyDialog: React.FunctionComponent<{
4556 onClick={() => post("common/closeReactDialog")}
4657 /> */ }
4758 </ DialogTitle >
48- < DialogContent className = { "dialog-content" } >
49- { /* InnerHTML is used so that we can insert markup like <br> into the message. */ }
50- < DialogContentText
51- className = "allowSelect"
52- dangerouslySetInnerHTML = { {
53- __html : props . message || ""
54- } }
55- />
56- </ DialogContent >
57- { getDialogActionButtons ( ) }
59+ < DialogContent className = { "dialog-content" } >
60+ { /* InnerHTML is used so that we can insert markup like <br> into the message. */ }
61+ < DialogContentText
62+ className = "allowSelect"
63+ dangerouslySetInnerHTML = { {
64+ __html : props . message || ""
65+ } }
66+ />
67+ { props . detailsBoxText &&
68+ < DialogContentText
69+ css = { css `
70+ background-color : ${ kFormBackground } ;
71+ padding : 10px ;
72+ margin-top : 20px ;
73+ margin-bottom : 20px ;
74+ a {
75+ color : ${ kBloomBlue } ; // we are passing links in the detailsBoxText
76+ }
77+ }` }
78+ dangerouslySetInnerHTML = { {
79+ __html : props . detailsBoxText || ""
80+ } }
81+ />
82+ }
83+ </ DialogContent >
84+ { getDialogActionButtons ( ) }
5885 </ Dialog >
5986 ) ;
6087 } ;
@@ -111,16 +138,21 @@ export const NotifyDialog: React.FunctionComponent<{
111138 } ;
112139
113140 const getCloseButton = ( ) : JSX . Element | null => {
141+ const buttonLabel = props . themeOverride === ProblemKind . Fatal ? "Quit" : "Close" ;
142+ const l10nKey =
143+ props . themeOverride === ProblemKind . Fatal
144+ ? "ReportProblemDialog.Quit"
145+ : "Common.Close" ;
114146 return (
115147 < BloomButton
116148 enabled = { true }
117- l10nKey = { "Common.Close" }
149+ l10nKey = { l10nKey }
118150 hasText = { true }
119151 onClick = { ( ) => {
120152 post ( "common/closeReactDialog" ) ;
121153 } }
122154 >
123- Close
155+ { buttonLabel }
124156 </ BloomButton >
125157 ) ;
126158 } ;
0 commit comments