feat: export panel is updated (#3099)

Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
This commit is contained in:
Palash Gupta 2023-07-11 16:24:01 +05:30 committed by GitHub
parent 54899930b0
commit e746bae8db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 49 deletions

View File

@ -1,9 +0,0 @@
export const MENU_KEY = {
EXPORT: 'export',
CREATE_ALERTS: 'create-alerts',
};
export const MENU_LABEL = {
EXPORT: 'Export Panel',
CREATE_ALERTS: 'Create Alerts',
};

View File

@ -1,12 +1,12 @@
import { Button, Dropdown, MenuProps, Modal } from 'antd';
import { AlertOutlined, AreaChartOutlined } from '@ant-design/icons';
import { Button, Modal, Space } from 'antd';
import { queryParamNamesMap } from 'constants/queryBuilderQueryNames';
import ROUTES from 'constants/routes';
import history from 'lib/history';
import { useCallback, useMemo, useState } from 'react';
import { useCallback, useState } from 'react';
import { Dashboard } from 'types/api/dashboard/getAll';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { MENU_KEY, MENU_LABEL } from './config';
import ExportPanelContainer from './ExportPanel';
function ExportPanel({
@ -28,45 +28,30 @@ function ExportPanel({
);
}, [query]);
const onMenuClickHandler: MenuProps['onClick'] = useCallback(
(e: OnClickProps) => {
if (e.key === MENU_KEY.EXPORT) {
onModalToggle(true);
}
if (e.key === MENU_KEY.CREATE_ALERTS) {
onCreateAlertsHandler();
}
},
[onModalToggle, onCreateAlertsHandler],
);
const menu: MenuProps = useMemo(
() => ({
items: [
{
key: MENU_KEY.EXPORT,
label: MENU_LABEL.EXPORT,
},
{
key: MENU_KEY.CREATE_ALERTS,
label: MENU_LABEL.CREATE_ALERTS,
},
],
onClick: onMenuClickHandler,
}),
[onMenuClickHandler],
);
const onCancel = (value: boolean) => (): void => {
onModalToggle(value);
};
const onAddToDashboard = (): void => {
setIsExport(true);
};
return (
<>
<Dropdown trigger={['click']} menu={menu}>
<Button>Actions</Button>
</Dropdown>
<Space size={24}>
<Button
icon={<AreaChartOutlined />}
onClick={onAddToDashboard}
type="primary"
>
Add to Dashboard
</Button>
<Button onClick={onCreateAlertsHandler} icon={<AlertOutlined />}>
Setup Alerts
</Button>
</Space>
<Modal
footer={null}
onOk={onCancel(false)}
@ -85,10 +70,6 @@ function ExportPanel({
);
}
interface OnClickProps {
key: string;
}
export interface ExportPanelProps {
isLoading?: boolean;
onExport: (dashboard: Dashboard | null) => void;