Skip to content

Commit

Permalink
fix: Adding report bug (apache#16065)
Browse files Browse the repository at this point in the history
* report add fix

* added theme
  • Loading branch information
AAfghahi committed Aug 4, 2021
1 parent 7c95595 commit 4359650
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -18,7 +18,7 @@
*/
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import { t, SupersetTheme, css } from '@superset-ui/core';
import { t, SupersetTheme, css, useTheme } from '@superset-ui/core';
import Icons from 'src/components/Icons';
import { Switch } from 'src/components/Switch';
import { AlertObject } from 'src/views/CRUD/alert/types';
Expand Down Expand Up @@ -47,6 +47,7 @@ export default function HeaderReportActionsDropDown({
currentReportDeleting,
setCurrentReportDeleting,
] = useState<AlertObject | null>(null);
const theme = useTheme();

const toggleActiveKey = async (data: AlertObject, checked: boolean) => {
if (data?.id) {
Expand All @@ -60,14 +61,15 @@ export default function HeaderReportActionsDropDown({
};

const menu = () => (
<Menu selectable={false}>
<Menu selectable={false} css={{ width: '200px' }}>
<Menu.Item>
{t('Email reports active')}
<Switch
data-test="toggle-active"
checked={report?.active}
onClick={(checked: boolean) => toggleActiveKey(report, checked)}
size="small"
css={{ marginLeft: theme.gridUnit * 2 }}
/>
</Menu.Item>
<Menu.Item onClick={showReportModal}>{t('Edit email report')}</Menu.Item>
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/reports/actions/reports.js
Expand Up @@ -102,8 +102,8 @@ export const addReport = report => dispatch => {
endpoint: `/api/v1/report/`,
jsonPayload: report,
})
.then(() => {
dispatch({ type: ADD_REPORT, report });
.then(({ json }) => {
dispatch({ type: ADD_REPORT, json });
dispatch(addSuccessToast(t('The report has been created')));
})
.catch(() =>
Expand Down

0 comments on commit 4359650

Please sign in to comment.