Skip to content

Commit a7051fa

Browse files
committed
fix toast formatting
1 parent fc83c35 commit a7051fa

File tree

20 files changed

+372
-185
lines changed

20 files changed

+372
-185
lines changed

frontend/src/components/ConnectionConfiguration/AWS/configureAws.tsx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,22 @@ const ConfigureAWS: React.FC<configureAWSParams> = ({
8585
const [id] = useState(uuidv4())
8686
const [name, setName] = useState(`Metlo-Connection-${id}`)
8787
const toast = useToast()
88-
const create_toast_with_message = (msg: string, step: AWS_STEPS, statusCode?: number) => {
89-
toast(makeToast({
90-
title: `Encountered an error on step ${AWS_STEPS[step]}`,
91-
description: msg,
92-
status: "error",
93-
duration: 6000,
94-
}, statusCode))
88+
const create_toast_with_message = (
89+
msg: string,
90+
step: AWS_STEPS,
91+
statusCode?: number,
92+
) => {
93+
toast(
94+
makeToast(
95+
{
96+
title: `Encountered an error on step ${AWS_STEPS[step]}`,
97+
description: msg,
98+
status: "error",
99+
duration: 6000,
100+
},
101+
statusCode,
102+
),
103+
)
95104
}
96105

97106
const step_increment_function = (
@@ -110,7 +119,11 @@ const ConfigureAWS: React.FC<configureAWSParams> = ({
110119
console.log(err.data.error)
111120
},
112121
error => {
113-
create_toast_with_message(error.message as string, step, error.response?.status)
122+
create_toast_with_message(
123+
error.message as string,
124+
step,
125+
error.response?.status,
126+
)
114127
console.log(error)
115128
},
116129
setUpdating,
@@ -295,10 +308,12 @@ const ConfigureAWS: React.FC<configureAWSParams> = ({
295308
step: AWS_STEPS.EXEC_COMMAND,
296309
params,
297310
onComplete: () => {
298-
toast(makeToast({
299-
title: "Mirroring setup completed!",
300-
status: "success",
301-
}))
311+
toast(
312+
makeToast({
313+
title: "Mirroring setup completed!",
314+
status: "success",
315+
}),
316+
)
302317
},
303318
})
304319
}}

frontend/src/components/ConnectionConfiguration/AWS/instance_selection.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ const InstanceSelection: React.FC<KeySetupInterface> = ({
6161
.catch((err: AxiosError) => {
6262
setInstances([])
6363
setSelectedInstance("")
64-
toast(makeToast({
65-
title: "Couldn't fetch EC2 instance matching specs",
66-
status: "error",
67-
description: JSON.stringify(err.response.data),
68-
}, err.response?.status))
64+
toast(
65+
makeToast(
66+
{
67+
title: "Couldn't fetch EC2 instance matching specs",
68+
status: "error",
69+
description: JSON.stringify(err.response.data),
70+
},
71+
err.response?.status,
72+
),
73+
)
6974
})
7075
.finally(() => setLoadingState(false))
7176
}

frontend/src/components/ConnectionConfiguration/GCP/configureGcp.tsx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,22 @@ const ConfigureGCP: React.FC<configureAWSParams> = ({
8585
const [id] = useState(uuidv4())
8686
const [name, setName] = useState(`Metlo-Connection-${id}`)
8787
const toast = useToast()
88-
const create_toast_with_message = (msg: string, step: GCP_STEPS, statusCode?: number) => {
89-
toast(makeToast({
90-
title: `Encountered an error on step ${GCP_STEPS[step]}`,
91-
description: msg,
92-
status: "error",
93-
duration: 6000,
94-
}, statusCode))
88+
const create_toast_with_message = (
89+
msg: string,
90+
step: GCP_STEPS,
91+
statusCode?: number,
92+
) => {
93+
toast(
94+
makeToast(
95+
{
96+
title: `Encountered an error on step ${GCP_STEPS[step]}`,
97+
description: msg,
98+
status: "error",
99+
duration: 6000,
100+
},
101+
statusCode,
102+
),
103+
)
95104
}
96105

97106
const step_increment_function = (
@@ -113,7 +122,11 @@ const ConfigureGCP: React.FC<configureAWSParams> = ({
113122
console.log(err.data.error)
114123
},
115124
error => {
116-
create_toast_with_message(error.message as string, step, error.response?.status)
125+
create_toast_with_message(
126+
error.message as string,
127+
step,
128+
error.response?.status,
129+
)
117130
console.log(error)
118131
},
119132
setUpdating,
@@ -305,10 +318,12 @@ const ConfigureGCP: React.FC<configureAWSParams> = ({
305318
step: GCP_STEPS.EXEC_COMMAND,
306319
params,
307320
onComplete: () =>
308-
toast(makeToast({
309-
title: "Mirroring setup completed!",
310-
status: "success",
311-
})),
321+
toast(
322+
makeToast({
323+
title: "Mirroring setup completed!",
324+
status: "success",
325+
}),
326+
),
312327
})
313328
}}
314329
isCurrent={GCP_STEPS.EXEC_COMMAND == selected}

frontend/src/components/ConnectionConfiguration/GCP/destination_instance_config.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ const SourceMigConfig: React.FC<KeySetupInterface> = ({
4141
setImageTemplateURL(os_choice.data[0][1])
4242
})
4343
.catch(err => {
44-
toast(makeToast({
45-
title: "Encountered an error fetching OS Choices",
46-
status: "error",
47-
description: "Check the console for more details",
48-
}, err?.response?.status))
44+
toast(
45+
makeToast(
46+
{
47+
title: "Encountered an error fetching OS Choices",
48+
status: "error",
49+
description: "Check the console for more details",
50+
},
51+
err?.response?.status,
52+
),
53+
)
4954
console.warn(err)
5055
})
5156
}

frontend/src/components/ConnectionInfo/aws.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,25 @@ const AWS_INFO: React.FC<AWS_INFOInterface> = ({
4545
name: name,
4646
})
4747
.then(v => {
48-
toast(makeToast({ title: "Updated Name for Connection", status: "success" }))
48+
toast(
49+
makeToast({
50+
title: "Updated Name for Connection",
51+
status: "success",
52+
}),
53+
)
4954
setConnection({ ...connection, name: name })
5055
})
5156
.catch(err => {
52-
toast(makeToast({
53-
title: "Couldn't update name for connection",
54-
description: err.response?.data,
55-
status: "error",
56-
}, err?.response?.status))
57+
toast(
58+
makeToast(
59+
{
60+
title: "Couldn't update name for connection",
61+
description: err.response?.data,
62+
status: "error",
63+
},
64+
err?.response?.status,
65+
),
66+
)
5767
})
5868
}
5969
}
@@ -74,7 +84,13 @@ const AWS_INFO: React.FC<AWS_INFOInterface> = ({
7484
})
7585
.catch(err => {
7686
console.log(err)
77-
toast(makeToast({ title: "Couldn't download ssh key file", description: err.response?.data, status: "error" }))
87+
toast(
88+
makeToast({
89+
title: "Couldn't download ssh key file",
90+
description: err.response?.data,
91+
status: "error",
92+
}),
93+
)
7894
})
7995
}
8096
return (

frontend/src/components/ConnectionInfo/connectionSelector.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ const DeleteButton: React.FC<{
4848
const toast = useToast()
4949
const create_toast_with_message = (msg: string, statusCode?: number) => {
5050
console.log(msg)
51-
toast(makeToast({
52-
title: `Encountered an error while deleting connection`,
53-
description: msg,
54-
status: "error",
55-
duration: 6000,
56-
}, statusCode))
51+
toast(
52+
makeToast(
53+
{
54+
title: `Encountered an error while deleting connection`,
55+
description: msg,
56+
status: "error",
57+
duration: 6000,
58+
},
59+
statusCode,
60+
),
61+
)
5762
}
5863
const onBtnClick = async () => {
5964
await retrier({

frontend/src/components/ConnectionInfo/gcp.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,25 @@ const GCP_INFO: React.FC<GCP_INFOInterface> = ({
6262
name: name,
6363
})
6464
.then(v => {
65-
toast(makeToast({ title: "Updated Name for Connection", status: "success" }))
65+
toast(
66+
makeToast({
67+
title: "Updated Name for Connection",
68+
status: "success",
69+
}),
70+
)
6671
setConnection({ ...connection, name: name })
6772
})
6873
.catch(err => {
69-
toast(makeToast({
70-
title: "Couldn't update name for connection",
71-
description: err,
72-
status: "error",
73-
}, err?.response?.status))
74+
toast(
75+
makeToast(
76+
{
77+
title: "Couldn't update name for connection",
78+
description: err,
79+
status: "error",
80+
},
81+
err?.response?.status,
82+
),
83+
)
7484
})
7585
}
7686
}
@@ -91,7 +101,16 @@ const GCP_INFO: React.FC<GCP_INFOInterface> = ({
91101
})
92102
.catch(err => {
93103
console.log(err)
94-
toast(makeToast({ title: "Couldn't download ssh key file", description: err, status: "error" }, err?.response?.status))
104+
toast(
105+
makeToast(
106+
{
107+
title: "Couldn't download ssh key file",
108+
description: err,
109+
status: "error",
110+
},
111+
err?.response?.status,
112+
),
113+
)
95114
})
96115
}
97116

frontend/src/components/Endpoint/AlertDetail.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ const AlertDetail: React.FC<AlertDetailProps> = React.memo(
5050
const handleResolveClick = async () => {
5151
setResolving(true)
5252
try {
53-
const resp: Alert = await resolveAlert(currAlert.uuid, resolutionMessage)
54-
toast(makeToast({
55-
title: "Successfully resolved alert!",
56-
status: "success",
57-
duration: 5000,
58-
}))
53+
const resp: Alert = await resolveAlert(
54+
currAlert.uuid,
55+
resolutionMessage,
56+
)
57+
toast(
58+
makeToast({
59+
title: "Successfully resolved alert!",
60+
status: "success",
61+
duration: 5000,
62+
}),
63+
)
5964
const tempAlertList = [...alertList]
6065
for (let i = 0; i < tempAlertList.length; i++) {
6166
if (tempAlertList[i].uuid === resp.uuid) {
@@ -65,12 +70,17 @@ const AlertDetail: React.FC<AlertDetailProps> = React.memo(
6570
setCurrAlert(resp)
6671
setAlertList([...tempAlertList])
6772
} catch (err) {
68-
toast(makeToast({
69-
title: "Resolving Alert Failed",
70-
status: "error",
71-
duration: 5000,
72-
description: err.response.data
73-
}, err?.response?.status))
73+
toast(
74+
makeToast(
75+
{
76+
title: "Resolving Alert Failed",
77+
status: "error",
78+
duration: 5000,
79+
description: err.response.data,
80+
},
81+
err?.response?.status,
82+
),
83+
)
7484
} finally {
7585
setResolving(false)
7686
}

frontend/src/components/Endpoint/AlertTab.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ export const AlertTab: React.FC<AlertTabProps> = ({
3737
setTotalCount(res[1])
3838
})
3939
.catch(e =>
40-
toast(makeToast({
41-
title: "Fetching Alerts failed",
42-
status: "error",
43-
description: e.response?.data
44-
})),
40+
toast(
41+
makeToast({
42+
title: "Fetching Alerts failed",
43+
status: "error",
44+
description: e.response?.data,
45+
}),
46+
),
4547
)
4648
.finally(() => setFetching(false))
4749
}
@@ -59,17 +61,24 @@ export const AlertTab: React.FC<AlertTabProps> = ({
5961
setUpdating(true)
6062
try {
6163
const resp: Alert = await updateAlert(alertId, updateAlertParams)
62-
toast(makeToast({
63-
title: `Updating alert successful`,
64-
status: "success",
65-
}))
64+
toast(
65+
makeToast({
66+
title: `Updating alert successful`,
67+
status: "success",
68+
}),
69+
)
6670
fetchAlerts(params)
6771
} catch (err) {
68-
toast(makeToast({
69-
title: "Updating Alert failed",
70-
status: "error",
71-
description: err.response?.data
72-
}, err.response?.status))
72+
toast(
73+
makeToast(
74+
{
75+
title: "Updating Alert failed",
76+
status: "error",
77+
description: err.response?.data,
78+
},
79+
err.response?.status,
80+
),
81+
)
7382
} finally {
7483
setUpdating(false)
7584
}

0 commit comments

Comments
 (0)