From 7c2539ec93a866e9a145aed9d11929036ea833bf Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 29 Apr 2022 14:16:29 +0200 Subject: [PATCH] feat(ui) - dashboard - report --- .../DashboardOptions/DashboardOptions.tsx | 33 +++++++++++++++++++ .../components/DashboardOptions/index.ts | 1 + .../DashboardView/DashboardView.tsx | 16 ++++----- 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx create mode 100644 frontend/app/components/Dashboard/components/DashboardOptions/index.ts diff --git a/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx b/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx new file mode 100644 index 000000000..b616d2e50 --- /dev/null +++ b/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { ItemMenu } from 'UI'; +import { connect } from 'react-redux'; + +interface Props { + editHandler: any + deleteHandler: any + renderReport: any + isEnterprise: boolean +} +function DashboardOptions(props: Props) { + const { editHandler, deleteHandler, renderReport, isEnterprise } = props; + const menuItems = [ + { icon: 'pencil', text: 'Rename', onClick: editHandler }, + { icon: 'text-paragraph', text: 'Add Description', onClick: editHandler }, + { icon: 'users', text: 'Visibility & Access', onClick: editHandler }, + { icon: 'trash', text: 'Delete', onClick: deleteHandler }, + ] + if (isEnterprise) { + menuItems.unshift({ icon: 'pdf-download', text: 'Download Report', onClick: renderReport }); + } + + return ( + + ); +} + +export default connect(state => ({ + isEnterprise: state.getIn([ 'user', 'client', 'edition' ]) === 'ee', +}))(DashboardOptions); \ No newline at end of file diff --git a/frontend/app/components/Dashboard/components/DashboardOptions/index.ts b/frontend/app/components/Dashboard/components/DashboardOptions/index.ts new file mode 100644 index 000000000..09297ef57 --- /dev/null +++ b/frontend/app/components/Dashboard/components/DashboardOptions/index.ts @@ -0,0 +1 @@ +export { default } from './DashboardOptions'; \ No newline at end of file diff --git a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx index 0b096794d..083e55d1a 100644 --- a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx +++ b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import { useObserver } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; -import { Button, PageTitle, Loader, NoContent, ItemMenu } from 'UI'; +import { Button, PageTitle, Loader, NoContent } from 'UI'; import { withSiteId } from 'App/routes'; import withModal from 'App/components/Modal/withModal'; import DashboardWidgetGrid from '../DashboardWidgetGrid'; @@ -14,6 +14,7 @@ import DateRange from 'Shared/DateRange'; import AlertFormModal from 'App/components/Alerts/AlertFormModal'; import withPageTitle from 'HOCs/withPageTitle'; import withReport from 'App/components/hocs/withReport'; +import DashboardOptions from '../DashboardOptions'; interface Props { siteId: number; @@ -110,15 +111,10 @@ function DashboardView(props: Props) {
-