;
+ const [visible, setVisible] = useState(false);
+ const showToast = () => {
+ setVisible(true);
+ };
+
+ const handleClosePress = () => {
+ clearTimeout(hideTimer);
+ // Wait for the transition
+ setVisible(() => {
+ setTimeout(() => {
+ onCloseToast(toast.id);
+ }, 150);
+ return false;
+ });
+ };
+
+ useEffect(() => {
+ setTimeout(showToast);
+
+ if (toast.duration > 0) {
+ hideTimer = setTimeout(handleClosePress, toast.duration);
+ }
+ return () => {
+ clearTimeout(hideTimer);
+ };
+ }, []);
+
+ return (
+
+
+ {toast.toastType === SUCCESS_TOAST && }
+ {toast.toastType === WARNING_TOAST ||
+ (toast.toastType === DANGER_TOAST && )}
+
+
+
+ );
+}
diff --git a/superset-frontend/src/messageToasts/components/ToastPresenter.jsx b/superset-frontend/src/messageToasts/components/ToastPresenter.jsx
deleted file mode 100644
index 69fa1449f..000000000
--- a/superset-frontend/src/messageToasts/components/ToastPresenter.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import PropTypes from 'prop-types';
-import React from 'react';
-
-import Toast from './Toast';
-import { toastShape } from '../propShapes';
-
-import '../stylesheets/toast.less';
-
-const propTypes = {
- toasts: PropTypes.arrayOf(toastShape),
- removeToast: PropTypes.func.isRequired,
-};
-
-const defaultProps = {
- toasts: [],
-};
-
-// eslint-disable-next-line react/prefer-stateless-function
-class ToastPresenter extends React.Component {
- render() {
- const { toasts, removeToast } = this.props;
-
- return (
- toasts.length > 0 && (
-
- {toasts.map(toast => (
-
- ))}
-
- )
- );
- }
-}
-
-ToastPresenter.propTypes = propTypes;
-ToastPresenter.defaultProps = defaultProps;
-
-export default ToastPresenter;
diff --git a/superset-frontend/src/messageToasts/components/ToastPresenter.tsx b/superset-frontend/src/messageToasts/components/ToastPresenter.tsx
new file mode 100644
index 000000000..545573501
--- /dev/null
+++ b/superset-frontend/src/messageToasts/components/ToastPresenter.tsx
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import styled from '@superset-ui/style';
+import { ToastType } from 'src/messageToasts/types';
+import Toast from './Toast';
+
+const StyledToastPresenter = styled.div`
+ max-width: 600px;
+ position: fixed;
+ bottom: 0px;
+ right: -110px;
+ transform: translate(-50%, 0);
+ z-index: ${({ theme }) => theme.zIndex.max};
+
+ .toast {
+ background: ${({ theme }) => theme.colors.grayscale.dark1};
+ border-radius: ${({ theme }) => theme.borderRadius};
+ box-shadow: 0 2px 4px 0
+ fade(
+ ${({ theme }) => theme.colors.grayscale.dark2},
+ ${({ theme }) => theme.opacity.mediumLight}
+ );
+ color: ${({ theme }) => theme.colors.grayscale.light5};
+ opacity: 0;
+ position: relative;
+ transform: translateY(-100%);
+ white-space: pre-line;
+ will-change: transform, opacity;
+ transition: transform ${({ theme }) => theme.transitionTiming}s,
+ opacity ${({ theme }) => theme.transitionTiming}s;
+
+ &:after {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 6px;
+ height: 100%;
+ }
+ }
+
+ .toast > button {
+ color: ${({ theme }) => theme.colors.grayscale.light5};
+ opacity: 1;
+ }
+
+ .toast--visible {
+ opacity: 1;
+ transform: translateY(0);
+ }
+`;
+
+type ToastShape = {
+ id: string;
+ toastType: ToastType;
+ text: string;
+ duration: number;
+};
+
+interface ToastPresenterProps {
+ toasts: Array;
+ removeToast: () => void;
+}
+
+const ToastPresenter = ({ toasts, removeToast }: ToastPresenterProps) =>
+ toasts.length > 0 && (
+
+ {toasts.map(toast => (
+
+ ))}
+
+ );
+
+export default ToastPresenter;
diff --git a/superset-frontend/src/messageToasts/stylesheets/toast.less b/superset-frontend/src/messageToasts/stylesheets/toast.less
deleted file mode 100644
index 7221e9fc2..000000000
--- a/superset-frontend/src/messageToasts/stylesheets/toast.less
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-@import '../../../stylesheets/less/variables.less';
-
-.toast-presenter {
- position: fixed;
- bottom: 16px;
- left: 50%;
- transform: translate(-50%, 0);
- width: 600px;
- z-index: @z-index-max;
-}
-
-.toast {
- background: @lightest;
- color: @almost-black;
- opacity: 0;
- position: relative;
- white-space: pre-line;
- box-shadow: 0 2px 4px 0 fade(@darkest, @opacity-medium-light);
- will-change: transform, opacity;
- transform: translateY(-100%);
- transition: transform @timing-normal, opacity @timing-normal;
-
- &:after {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- width: 6px;
- height: 100%;
- }
-}
-
-.toast > button {
- color: @almost-black;
-
- &:hover {
- color: @gray-dark;
- }
-}
-
-.toast--visible {
- transform: translateY(0);
- opacity: 1;
-}
-
-.toast--info:after {
- background: @info;
-}
-
-.toast--success:after {
- background: @success;
-}
-
-.toast--warning:after {
- background: @warning;
-}
-
-.toast--danger:after {
- background: @danger;
-}
diff --git a/superset-frontend/src/messageToasts/types.ts b/superset-frontend/src/messageToasts/types.ts
new file mode 100644
index 000000000..471a3a0ac
--- /dev/null
+++ b/superset-frontend/src/messageToasts/types.ts
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export type ToastType =
+ | 'INFO_TOAST'
+ | 'SUCCESS_TOAST'
+ | 'WARNING_TOAST'
+ | 'DANGER_TOAST';