Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit 655db2b

Browse files
authored
refactored toast component (#874)
1 parent 3484f71 commit 655db2b

File tree

19 files changed

+561
-882
lines changed

19 files changed

+561
-882
lines changed

web/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"react-emoji-render": "^2.0.1",
2828
"react-infinite-scroll-component": "^6.1.0",
2929
"react-router-dom": "^6.26.2",
30+
"react-toastify": "^10.0.5",
3031
"redux": "^5.0.1",
3132
"remarkable": "^2.0.1",
3233
"typescript": "^5.6.2",

web/src/app.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,11 @@
7777
.serviceLinkIcon {
7878
@apply hover:text-teal-300 inline fill-current h-4 w-4
7979
}
80+
81+
:root:has(.no-doc-scroll) {
82+
overflow: hidden;
83+
}
84+
85+
:root {
86+
--toastify-color-progress-light: #2dd4bf
87+
}

web/src/app.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component, useEffect } from 'react';
2+
import "react-toastify/dist/ReactToastify.css";
23
import './app.css';
34
import Nav from "./components/nav/nav";
45
import StreamingBackend from "./streamingBackend";
@@ -20,7 +21,6 @@ import { DeployWizzard } from './views/deployWizzard/deployWizzard'
2021
import RepositoryWizard from './views/repositoryWizard/repositoryWizard';
2122
import Environments from './views/environments/environments'
2223
import Environment from './views/environment/environment';
23-
import PopUpWindow from './popUpWindow';
2424
import Footer from './views/footer/footer';
2525
import {
2626
ACTION_TYPE_USER,
@@ -29,6 +29,7 @@ import {
2929
import Posthog from './posthog';
3030
import './style.css'
3131
import GithubIntegration from './views/githubIntegration';
32+
import { ToastContainer } from 'react-toastify';
3233

3334
export default class App extends Component {
3435
constructor(props) {
@@ -113,10 +114,10 @@ export default class App extends Component {
113114
<Router>
114115
<StreamingBackend store={store} />
115116
<APIBackend store={store} gimletClient={gimletClient} />
116-
<PopUpWindow store={store} />
117117
<Posthog store={store} />
118118

119119
<div className="min-h-screen bg-neutral-100 dark:bg-neutral-900 pb-20">
120+
<ToastContainer limit={3} theme="light" className="max-w-lg w-full" />
120121
<Footer store={store} gimletClient={gimletClient} />
121122
<div className="">
122123
<Routes>

web/src/components/serviceDetail/serviceDetail.jsx

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import React, { useEffect, useState, useRef } from 'react';
1+
import { useEffect, useState, useRef } from 'react';
22
import { RolloutHistory } from "../rolloutHistory/rolloutHistory";
33
import Emoji from "react-emoji-render";
44
import { Fragment } from 'react'
55
import { Menu, Transition } from '@headlessui/react'
66
import { ArrowPathIcon } from '@heroicons/react/20/solid'
77
import {
88
ACTION_TYPE_ROLLOUT_HISTORY,
9-
ACTION_TYPE_POPUPWINDOWERROR,
10-
ACTION_TYPE_POPUPWINDOWRESET,
11-
ACTION_TYPE_POPUPWINDOWSUCCESS,
12-
ACTION_TYPE_POPUPWINDOWPROGRESS,
139
} from "../../redux/redux";
1410
import { copyToClipboard } from '../../views/settings/settings';
1511
import { usePostHog } from 'posthog-js/react'
@@ -18,6 +14,8 @@ import { AlertPanel } from './alert';
1814
import { Logs } from '../../views/footer/logs';
1915
import { Describe } from '../../views/footer/capacitor/Describe';
2016
import { ArrowTopRightOnSquareIcon, LinkIcon } from '@heroicons/react/24/solid';
17+
import { toast } from 'react-toastify';
18+
import { InProgress, Success, Error } from '../../popUpWindow';
2119

2220
function ServiceDetail(props) {
2321
const { store, gimletClient } = props;
@@ -28,6 +26,8 @@ function ServiceDetail(props) {
2826
const posthog = usePostHog()
2927
const [pullRequests, setPullRequests] = useState()
3028

29+
const progressToastId = useRef(null);
30+
3131
useEffect(() => {
3232
if (deploymentFromParams === stack.service.name) {
3333
window.scrollTo({ behavior: 'smooth', top: ref.current.offsetTop })
@@ -67,69 +67,48 @@ function ServiceDetail(props) {
6767
};
6868

6969
const deleteAppInstance = () => {
70-
store.dispatch({
71-
type: ACTION_TYPE_POPUPWINDOWPROGRESS, payload: {
72-
header: "Deleting application instance..."
73-
}
74-
});
70+
progressToastId.current = toast(<InProgress header="Deleting application instance..."/>, { autoClose: false });
7571

7672
gimletClient.deleteAppInstance(environment.name, stack.service.name)
7773
.then(() => {
78-
store.dispatch({
79-
type: ACTION_TYPE_POPUPWINDOWSUCCESS, payload: {
80-
header: "Success",
81-
message: "Application instance deleted",
82-
}
74+
toast.update(progressToastId.current, {
75+
render: <Success header="Application instance deleted"/>,
76+
className: "bg-green-50 shadow-lg p-2",
77+
bodyClassName: "p-2",
8378
});
8479
}, (err) => {
85-
store.dispatch({
86-
type: ACTION_TYPE_POPUPWINDOWERROR, payload: {
87-
header: "Error",
88-
message: err.statusText
89-
}
80+
toast.update(progressToastId.current, {
81+
render: <Error header="Error" message={err.statusText} />,
82+
className: "bg-red-50 shadow-lg p-2",
83+
bodyClassName: "p-2",
84+
progressClassName: "!bg-red-200",
85+
autoClose: 5000
9086
});
91-
setTimeout(() => {
92-
store.dispatch({
93-
type: ACTION_TYPE_POPUPWINDOWRESET
94-
});
95-
}, 3000);
9687
});
9788
}
9889

9990
const silenceAlert = (object, hours) => {
10091
var date = new Date();
10192
date.setHours(date.getHours() + hours);
10293

103-
store.dispatch({
104-
type: ACTION_TYPE_POPUPWINDOWPROGRESS, payload: {
105-
header: "Silence deployment alerts..."
106-
}
107-
});
94+
progressToastId.current = toast(<InProgress header="Silencing alerts..." />, { autoClose: false });
10895

10996
gimletClient.silenceAlert(object, date.toISOString())
11097
.then(() => {
111-
store.dispatch({
112-
type: ACTION_TYPE_POPUPWINDOWSUCCESS, payload: {
113-
header: "Success",
114-
}
98+
toast.update(progressToastId.current, {
99+
render: <Success header="Silenced" />,
100+
className: "bg-green-50 shadow-lg p-2",
101+
bodyClassName: "p-2",
102+
autoClose: 3000,
115103
});
116-
setTimeout(() => {
117-
store.dispatch({
118-
type: ACTION_TYPE_POPUPWINDOWRESET
119-
});
120-
}, 3000);
121104
}, (err) => {
122-
store.dispatch({
123-
type: ACTION_TYPE_POPUPWINDOWERROR, payload: {
124-
header: "Error",
125-
message: err.statusText
126-
}
105+
toast.update(progressToastId.current, {
106+
render: <Error header="Error" message={err.statusText} />,
107+
className: "bg-red-50 shadow-lg p-2",
108+
bodyClassName: "p-2",
109+
progressClassName: "!bg-red-200",
110+
autoClose: 5000
127111
});
128-
setTimeout(() => {
129-
store.dispatch({
130-
type: ACTION_TYPE_POPUPWINDOWRESET
131-
});
132-
}, 3000);
133112
});
134113
}
135114

web/src/index.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
@tailwind components;
33
@tailwind utilities;
44

5-
:root:has(.no-doc-scroll) {
6-
overflow:hidden;
7-
}
8-
95
@font-face {
106
font-family: 'geist';
117
src: url('./GeistVF.woff2') format('woff');

0 commit comments

Comments
 (0)