From e30e73e148d7e2edc18a5bf203ce37c1b83cc79f Mon Sep 17 00:00:00 2001 From: Angel Ruiz-Bates Date: Sat, 12 Dec 2020 19:58:34 -0400 Subject: [PATCH 1/4] Yellow editor page abort actions snackalert --- components/Editor/ActionsDialog/index.js | 46 +++++++++++------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/components/Editor/ActionsDialog/index.js b/components/Editor/ActionsDialog/index.js index 2a9d2f2..9ff0ffa 100644 --- a/components/Editor/ActionsDialog/index.js +++ b/components/Editor/ActionsDialog/index.js @@ -10,10 +10,10 @@ import ListItemText from '@material-ui/core/ListItemText'; import DialogTitle from '@material-ui/core/DialogTitle'; import Dialog from '@material-ui/core/Dialog'; import PauseIcon from '@material-ui/icons/Pause'; -import { ListItemIcon, Snackbar } from '@material-ui/core'; -import Alert from '@material-ui/lab/Alert'; +import { ListItemIcon } from '@material-ui/core'; import api from '../../../utils/api'; +import SnackAlert from '../../shared/SnackAlert'; const useStyles = makeStyles((theme) => ({ avatar: { @@ -27,9 +27,16 @@ function ActionsDialog({ }) { const [errorOpen, setErrorOpen] = useState(false); const [successOpen, setSuccessOpen] = useState(false); + const [warningOpen, setWarningOpen] = useState(false); const classes = useStyles(); const router = useRouter(); + const closeAlerts = () => { + setSuccessOpen(false); + setWarningOpen(false); + setErrorOpen(false); + }; + const handleError = () => { setErrorOpen(true); setTimeout(() => { @@ -39,11 +46,12 @@ function ActionsDialog({ const handleSuccess = () => { setTimeout(() => { - setSuccessOpen(false); + closeAlerts(); }, 2500); }; const handleAbort = () => { + closeAlerts(); api.patch('/events/abort', { bridge_slug: bridgeSlug, }) @@ -58,14 +66,20 @@ function ActionsDialog({ }; const handleActivate = () => { + closeAlerts(); api.patch(`/bridges/${bridgeSlug}/${active ? 'deactivate' : 'activate'}`).then(() => { router.push(`/bridge/${bridgeSlug}`); - setSuccessOpen(true); + if (active) { + setWarningOpen(true); + } else { + setSuccessOpen(true); + } handleSuccess(); }).catch(() => handleError()); }; const handleDelete = () => { + closeAlerts(); api.delete(`/bridges/${bridgeSlug}`).then(() => { router.push('/dashboard'); }).catch(() => handleError()); @@ -73,27 +87,9 @@ function ActionsDialog({ return ( - - - Success! Your bridge has been updated. - - - - - Some error occurred. Please try again. - - - + + + Bridge Actions From 9dbd2752ad038452229f24533dba1bc5f5a3c6d9 Mon Sep 17 00:00:00 2001 From: Angel Ruiz-Bates Date: Sat, 12 Dec 2020 20:22:02 -0400 Subject: [PATCH 2/4] spec fix --- components/Editor/ActionsDialog/index.js | 2 +- specs/integration/bridgeapi/bridges/id.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Editor/ActionsDialog/index.js b/components/Editor/ActionsDialog/index.js index 9ff0ffa..b84c3a8 100644 --- a/components/Editor/ActionsDialog/index.js +++ b/components/Editor/ActionsDialog/index.js @@ -88,7 +88,7 @@ function ActionsDialog({ return ( - + Bridge Actions diff --git a/specs/integration/bridgeapi/bridges/id.spec.js b/specs/integration/bridgeapi/bridges/id.spec.js index d3a2ecd..ea1e249 100644 --- a/specs/integration/bridgeapi/bridges/id.spec.js +++ b/specs/integration/bridgeapi/bridges/id.spec.js @@ -110,7 +110,7 @@ describe('Show bridge', () => { cy.get('#actions-button').click(); cy.get('#action-deactive').click(); - cy.get('#actions-success-message').contains('Success! Your bridge has been updated.'); + cy.get('#actions-warning-message').contains('Your bridge has been deactivated.'); }); it('can show error when deactiving fails', () => { From 5ee150b2673f0421d5829d8c7b362c2288d6882b Mon Sep 17 00:00:00 2001 From: Angel Ruiz-Bates Date: Mon, 21 Dec 2020 13:01:37 -0400 Subject: [PATCH 3/4] adds alert when bridge is deactivated --- components/Editor/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/Editor/index.js b/components/Editor/index.js index bbaf676..2528e78 100644 --- a/components/Editor/index.js +++ b/components/Editor/index.js @@ -9,6 +9,7 @@ import PropTypes from 'prop-types'; import { Formik, Form } from 'formik'; import { useRouter } from 'next/router'; +import Alert from '@material-ui/lab/Alert'; import Navbar from '../shared/dashboard/Navbar'; import Sidebar from '../Sidebar'; @@ -25,6 +26,10 @@ const useStyles = makeStyles((theme) => ({ root: { marginLeft: 180, }, + alert: { + width: '100%', + marginBottom: theme.spacing(2), + }, form: { minWidth: '100%', }, @@ -194,6 +199,7 @@ function Editor({ bridge, isEditView }) { {({ values, submitForm }) => (
+ This bridge is deactivated. Date: Mon, 21 Dec 2020 13:02:11 -0400 Subject: [PATCH 4/4] text change --- components/Editor/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Editor/index.js b/components/Editor/index.js index 2528e78..9c5024e 100644 --- a/components/Editor/index.js +++ b/components/Editor/index.js @@ -199,7 +199,7 @@ function Editor({ bridge, isEditView }) { {({ values, submitForm }) => ( - This bridge is deactivated. + This bridge is currently deactivated.