@@ -20,6 +20,7 @@ function ProgramRecordActions({
20
20
} ) {
21
21
const [ programRecordUrl , setProgramRecordUrl ] = useState ( sharedRecordUUID && `${ getConfig ( ) . CREDENTIALS_BASE_URL } /records/programs/shared/${ sharedRecordUUID } ` ) ;
22
22
const [ showCopyTooltip , setShowCopyTooltip ] = useState ( false ) ;
23
+ const [ showCreateLinkAlert , setShowCreateLinkAlert ] = useState ( false ) ;
23
24
const [ showDownloadToast , setShowDownloadToast ] = useState ( false ) ;
24
25
const [ downloadRecord , setDownloadRecord ] = useState ( 'default' ) ;
25
26
@@ -46,6 +47,13 @@ function ProgramRecordActions({
46
47
description = "Completed state for the download program record button"
47
48
/>
48
49
) ,
50
+ error : (
51
+ < FormattedMessage
52
+ id = "download.button.error"
53
+ defaultMessage = "Download program record failed"
54
+ description = "Error state for the download program record button"
55
+ />
56
+ ) ,
49
57
} ,
50
58
icons : {
51
59
default : < Icon src = { Download } /> ,
@@ -97,7 +105,7 @@ function ProgramRecordActions({
97
105
} )
98
106
. catch ( ( error ) => {
99
107
logError ( error ) ;
100
- throw new Error ( error ) ;
108
+ setShowCreateLinkAlert ( true ) ;
101
109
} ) ;
102
110
handleCopyEvent ( ) ;
103
111
} ;
@@ -112,8 +120,8 @@ function ProgramRecordActions({
112
120
}
113
121
} )
114
122
. catch ( ( error ) => {
123
+ setDownloadRecord ( 'error' ) ;
115
124
logError ( error ) ;
116
- throw new Error ( error ) ;
117
125
} ) ;
118
126
} ;
119
127
@@ -177,6 +185,16 @@ function ProgramRecordActions({
177
185
defaultMessage = "Create program record link"
178
186
description = "Button text for creating a link to the program record"
179
187
/>
188
+ < Toast
189
+ onClose = { ( ) => setShowCreateLinkAlert ( false ) }
190
+ show = { showCreateLinkAlert }
191
+ >
192
+ < FormattedMessage
193
+ id = "create.link.error"
194
+ defaultMessage = "Program record link creation failed. Please log out, log back in, and try again."
195
+ description = "A message to briefly display when the creation of a shared program record link fails"
196
+ />
197
+ </ Toast >
180
198
</ Button >
181
199
) }
182
200
</ OverlayTrigger >
@@ -251,7 +269,7 @@ function ProgramRecordActions({
251
269
>
252
270
< FormattedMessage
253
271
id = "successful.record.download.toast.message"
254
- defaultMessage = "Program record sucessfullly downloaded"
272
+ defaultMessage = "Program record sucessfully downloaded"
255
273
description = "A message to briefly display when the user successfully downloads a program record"
256
274
/>
257
275
</ Toast >
@@ -268,7 +286,11 @@ ProgramRecordActions.propTypes = {
268
286
renderBackButton : PropTypes . func . isRequired ,
269
287
username : PropTypes . string . isRequired ,
270
288
programUUID : PropTypes . string . isRequired ,
271
- sharedRecordUUID : PropTypes . string . isRequired ,
289
+ sharedRecordUUID : PropTypes . string ,
290
+ } ;
291
+
292
+ ProgramRecordActions . defaultProps = {
293
+ sharedRecordUUID : '' ,
272
294
} ;
273
295
274
296
export default ProgramRecordActions ;
0 commit comments