Skip to content

Commit a324345

Browse files
committed
fix: add reload icon in update available toast
1 parent 7bc170d commit a324345

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/App.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { lazy, Suspense, useRef, useState, useEffect } from 'react'
1818
import { Route, Switch, Redirect, useHistory, useLocation } from 'react-router-dom'
19-
import './css/application.scss';
19+
import './css/application.scss'
2020
import {
2121
showError,
2222
BreadcrumbStore,
@@ -26,9 +26,10 @@ import {
2626
useUserEmail,
2727
URLS as CommonURLS,
2828
ToastManager,
29-
ToastVariantType
29+
ToastVariantType,
3030
} from '@devtron-labs/devtron-fe-common-lib'
3131
import { ReactComponent as ICSparkles } from '@Icons/ic-sparkles.svg'
32+
import { ReactComponent as ICArrowClockwise } from '@Icons/ic-arrow-clockwise.svg'
3233
import { useRegisterSW } from 'virtual:pwa-register/react'
3334
import {
3435
useOnline,
@@ -78,19 +79,22 @@ export default function App() {
7879
useEffect(() => {
7980
if (didMountRef.current) {
8081
if (!isOnline) {
82+
onlineToast(
83+
{
84+
variant: ToastVariantType.error,
85+
title: 'You are offline!',
86+
description: 'You are not seeing real-time data and any changes you make will not be saved.',
87+
},
88+
{
89+
autoClose: false,
90+
},
91+
)
92+
} else {
8193
onlineToast({
82-
variant: ToastVariantType.error,
83-
title: 'You are offline!',
84-
description: 'You are not seeing real-time data and any changes you make will not be saved.',
85-
}, {
86-
autoClose: false
94+
variant: ToastVariantType.success,
95+
title: 'Connected!',
96+
description: "You're back online.",
8797
})
88-
} else {
89-
onlineToast({
90-
variant: ToastVariantType.success,
91-
title: 'Connected!',
92-
description: "You're back online.",
93-
})
9498
}
9599
} else {
96100
didMountRef.current = true
@@ -245,6 +249,7 @@ export default function App() {
245249
text: 'Reload',
246250
dataTestId: 'reload-btn',
247251
onClick: update,
252+
startIcon: <ICArrowClockwise />,
248253
},
249254
icon: <ICSparkles />,
250255
progressBarBg: UPDATE_AVAILABLE_TOAST_PROGRESS_BG,
@@ -281,6 +286,7 @@ export default function App() {
281286
text: 'Reload',
282287
dataTestId: 'reload-btn',
283288
onClick: reloadLocation,
289+
startIcon: <ICArrowClockwise />,
284290
},
285291
icon: <ICSparkles />,
286292
progressBarBg: UPDATE_AVAILABLE_TOAST_PROGRESS_BG,

src/components/v2/devtronStackManager/DevtronStackManager.service.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { get, post, ToastManager, ToastVariantType } from '@devtron-labs/devtron-fe-common-lib'
1818
import { ReactComponent as ICSparkles } from '@Icons/ic-sparkles.svg'
19+
import { ReactComponent as ICArrowClockwise } from '@Icons/ic-arrow-clockwise.svg'
1920
import { ModuleNameMap, Routes, UPDATE_AVAILABLE_TOAST_PROGRESS_BG } from '../../../config'
2021
import {
2122
AllModuleInfoResponse,
@@ -110,6 +111,7 @@ export const getModuleInfo = async (moduleName: string, forceReload?: boolean):
110111
text: 'Reload',
111112
dataTestId: 'reload-button',
112113
onClick: reloadLocation,
114+
startIcon: <ICArrowClockwise />,
113115
},
114116
icon: <ICSparkles />,
115117
progressBarBg: UPDATE_AVAILABLE_TOAST_PROGRESS_BG,

src/stories/ToastManager.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react'
2+
import { action } from '@storybook/addon-actions'
23
import { Button, ToastManager, ToastVariantType } from '@devtron-labs/devtron-fe-common-lib'
34
import { ReactComponent as ICArrowClockwise } from '@Icons/ic-arrow-clockwise.svg'
45
import { ReactComponent as ICSparkles } from '@Icons/ic-sparkles.svg'
@@ -65,6 +66,7 @@ export const WithButton: Story = {
6566
dataTestId: 'button',
6667
text: 'Reload',
6768
startIcon: <ICArrowClockwise />,
69+
onClick: action('Reload clicked'),
6870
},
6971
},
7072
},
@@ -100,6 +102,9 @@ export const CustomIconAndProgressBar: Story = {
100102
...Default.args.toastProps,
101103
icon: <ICSparkles />,
102104
progressBarBg: UPDATE_AVAILABLE_TOAST_PROGRESS_BG,
105+
buttonProps: {
106+
...WithButton.args.toastProps.buttonProps,
107+
},
103108
},
104109
},
105110
}

0 commit comments

Comments
 (0)