@@ -6,80 +6,86 @@ import {
66 NotificationIDs ,
77 NotificationType ,
88 newAddNotificationAction ,
9- newRemoveNotificationAction
9+ newRemoveNotificationAction ,
1010} from '../../notifications'
1111import type { DispatchFn } from '../../helpers'
1212
13- export const goModMissingNotification = ( dispatch : DispatchFn ) => newAddNotificationAction ( {
14- id : NotificationIDs . GoModMissing ,
15- type : NotificationType . Error ,
16- title : 'Go.mod file is missing' ,
17- description : 'Go.mod file is required to import sub-packages.' ,
18- canDismiss : true ,
19- actions : [
20- {
21- key : 'ok' ,
22- label : 'Create go.mod' ,
23- primary : true ,
24- onClick : ( ) => {
25- dispatch < FileUpdatePayload [ ] > ( {
26- type : WorkspaceAction . ADD_FILE ,
27- payload : [
28- {
29- filename : goModFile ,
30- content : goModTemplate ,
31- } ,
32- ] ,
33- } )
13+ export const goModMissingNotification = ( dispatch : DispatchFn ) =>
14+ newAddNotificationAction ( {
15+ id : NotificationIDs . GoModMissing ,
16+ type : NotificationType . Error ,
17+ title : 'Go.mod file is missing' ,
18+ description : 'Go.mod file is required to import sub-packages.' ,
19+ canDismiss : true ,
20+ actions : [
21+ {
22+ key : 'ok' ,
23+ label : 'Create go.mod' ,
24+ primary : true ,
25+ onClick : ( ) => {
26+ dispatch < FileUpdatePayload [ ] > ( {
27+ type : WorkspaceAction . ADD_FILE ,
28+ payload : [
29+ {
30+ filename : goModFile ,
31+ content : goModTemplate ,
32+ } ,
33+ ] ,
34+ } )
35+ } ,
3436 } ,
35- } ,
36- ] ,
37- } )
38-
39- export const goEnvChangedNotification = ( dispatch : DispatchFn ) => newAddNotificationAction ( {
40- id : NotificationIDs . GoTargetSwitched ,
41- type : NotificationType . Warning ,
42- title : 'Go environment temporarily changed' ,
43- description : 'This program will be executed using WebAssembly as Go program contains "//go:build" tag.' ,
44- canDismiss : true ,
45- actions : [
46- {
47- key : 'ok' ,
48- label : 'Ok' ,
49- primary : true ,
50- onClick : ( ) => dispatch ( newRemoveNotificationAction ( NotificationIDs . GoTargetSwitched ) ) ,
51- } ,
52- ] ,
53- } )
37+ ] ,
38+ } )
5439
55- export const goProgramExitNotification = ( code : number ) => newAddNotificationAction ( {
56- id : NotificationIDs . WASMAppExitError ,
57- type : NotificationType . Warning ,
58- title : 'Go program finished' ,
59- description : `Go program exited with non zero code: ${ code } ` ,
60- canDismiss : true ,
61- } )
40+ export const goEnvChangedNotification = ( dispatch : DispatchFn ) =>
41+ newAddNotificationAction ( {
42+ id : NotificationIDs . GoTargetSwitched ,
43+ type : NotificationType . Warning ,
44+ title : 'Go environment temporarily changed' ,
45+ description : 'This program will be executed using WebAssembly as Go program contains "//go:build" tag.' ,
46+ canDismiss : true ,
47+ actions : [
48+ {
49+ key : 'ok' ,
50+ label : 'Ok' ,
51+ primary : true ,
52+ onClick : ( ) => dispatch ( newRemoveNotificationAction ( NotificationIDs . GoTargetSwitched ) ) ,
53+ } ,
54+ ] ,
55+ } )
6256
63- export const wasmErrorNotification = ( err : any ) => newAddNotificationAction ( {
64- id : NotificationIDs . WASMAppExitError ,
65- type : NotificationType . Error ,
66- title : 'Failed to run WebAssembly program' ,
67- description : err . toString ( ) ,
68- canDismiss : true ,
69- } )
57+ export const goProgramExitNotification = ( code : number ) =>
58+ newAddNotificationAction ( {
59+ id : NotificationIDs . WASMAppExitError ,
60+ type : NotificationType . Warning ,
61+ title : 'Go program finished' ,
62+ description : `Go program exited with non zero code: ${ code } ` ,
63+ canDismiss : true ,
64+ } )
7065
66+ export const wasmErrorNotification = ( err : any ) =>
67+ newAddNotificationAction ( {
68+ id : NotificationIDs . WASMAppExitError ,
69+ type : NotificationType . Error ,
70+ title : 'Failed to run WebAssembly program' ,
71+ description : err . toString ( ) ,
72+ canDismiss : true ,
73+ } )
7174
72- export const downloadProgressNotification = ( progress ?: Required < Pick < NotificationProgress , 'total' | 'current' > > , updateOnly ?: boolean ) => newAddNotificationAction (
73- {
74- id : NotificationIDs . WASMAppDownload ,
75- type : NotificationType . Info ,
76- title : 'Downloading compiled application' ,
77- description : progress ? `${ formatBytes ( progress . current ) } / ${ formatBytes ( progress . total ) } ` : undefined ,
78- canDismiss : false ,
79- progress : progress ?? {
80- indeterminate : true ,
75+ export const downloadProgressNotification = (
76+ progress ?: Required < Pick < NotificationProgress , 'total' | 'current' > > ,
77+ updateOnly ?: boolean ,
78+ ) =>
79+ newAddNotificationAction (
80+ {
81+ id : NotificationIDs . WASMAppDownload ,
82+ type : NotificationType . Info ,
83+ title : 'Downloading compiled application' ,
84+ description : progress ? `${ formatBytes ( progress . current ) } / ${ formatBytes ( progress . total ) } ` : undefined ,
85+ canDismiss : false ,
86+ progress : progress ?? {
87+ indeterminate : true ,
88+ } ,
8189 } ,
82- } ,
83- updateOnly ,
84- )
85-
90+ updateOnly ,
91+ )
0 commit comments