Skip to content

Commit 353e7b7

Browse files
committed
feat: add toast manager service
1 parent e6a6a05 commit 353e7b7

File tree

13 files changed

+199
-18
lines changed

13 files changed

+199
-18
lines changed

src/Assets/Icon/ic-error.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Assets/Icon/ic-info-filled.svg

Lines changed: 3 additions & 6 deletions
Loading

src/Assets/Icon/ic-locked.svg

Lines changed: 5 additions & 0 deletions
Loading

src/Assets/Icon/ic-sparkles.svg

Lines changed: 10 additions & 0 deletions
Loading

src/Assets/Icon/ic-success.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Common/Helper.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ import { AsyncOptions, AsyncState, UseSearchString } from './Types'
3030
import { scrollableInterface, DATE_TIME_FORMAT_STRING } from '../Shared'
3131
import { ReactComponent as ArrowDown } from '../Assets/Icon/ic-chevron-down.svg'
3232

33-
toast.configure({
34-
autoClose: 3000,
35-
hideProgressBar: true,
36-
pauseOnHover: true,
37-
pauseOnFocusLoss: true,
38-
closeOnClick: false,
39-
newestOnTop: true,
40-
toastClassName: 'devtron-toast',
41-
bodyClassName: 'devtron-toast__body',
42-
})
43-
4433
export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) {
4534
if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
4635
serverError.errors.map(({ userMessage, internalMessage }) => {

src/Common/ImageTags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ export const ImageTagsContainer = ({
395395
</div>
396396
{showTagsWarning && (
397397
<div className="cn-7 mb-8 flex left">
398-
<Info className="form__icon--info icon-dim-16 mr-2" />
398+
<Info className="icon-dim-16 mr-2" />
399399
Tags cannot be edited/removed later
400400
</div>
401401
)}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ReactElement } from 'react'
2+
import { ToastOptions } from 'react-toastify'
3+
import { ReactComponent as ICInfoFilled } from '@Icons/ic-info-filled.svg'
4+
import { ReactComponent as ICSuccess } from '@Icons/ic-success.svg'
5+
import { ReactComponent as ICError } from '@Icons/ic-error.svg'
6+
import { ReactComponent as ICWarning } from '@Icons/ic-warning.svg'
7+
import { ReactComponent as ICLocked } from '@Icons/ic-locked.svg'
8+
import { ReactComponent as ICSparkles } from '@Icons/ic-sparkles.svg'
9+
import { ToastVariantType } from './types'
10+
11+
export const TOAST_VARIANT_TO_CONFIG_MAP: Record<
12+
ToastVariantType,
13+
{
14+
icon: ReactElement
15+
} & Pick<ToastOptions, 'type'>
16+
> = {
17+
[ToastVariantType.info]: {
18+
icon: <ICInfoFilled />,
19+
type: 'info',
20+
},
21+
[ToastVariantType.success]: {
22+
icon: <ICSuccess />,
23+
type: 'success',
24+
},
25+
[ToastVariantType.error]: {
26+
icon: <ICError />,
27+
type: 'error',
28+
},
29+
[ToastVariantType.warn]: {
30+
icon: <ICWarning className="warning-icon-y5-imp" />,
31+
type: 'warning',
32+
},
33+
[ToastVariantType.notAuthorized]: {
34+
icon: <ICLocked />,
35+
type: 'info',
36+
},
37+
[ToastVariantType.updateAvailable]: {
38+
icon: <ICSparkles />,
39+
type: 'info',
40+
},
41+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as ToastManager } from './toastManager.service'
2+
export { ToastVariantType } from './types'
3+
export type { ToastProps } from './types'
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.Toastify__toast-container {
2+
padding: 0;
3+
width: 320px;
4+
}
5+
6+
.custom-toast {
7+
max-height: none;
8+
padding: 12px;
9+
box-shadow: none;
10+
border-radius: 4px;
11+
margin-bottom: 16px;
12+
min-height: 0;
13+
color: var(--N0);
14+
background: #1B1C1E;
15+
font-family: inherit;
16+
17+
&__body {
18+
margin: 0;
19+
padding: 0;
20+
gap: 8px;
21+
align-items: flex-start;
22+
align-self: center;
23+
24+
> .Toastify__toast-icon {
25+
margin: 0;
26+
width: auto;
27+
align-self: flex-start;
28+
}
29+
30+
button {
31+
color: var(--N0);
32+
33+
&:hover, &:active {
34+
color: var(--N0);
35+
}
36+
}
37+
}
38+
// TODO: fix the styling for progress bar
39+
}

0 commit comments

Comments
 (0)