diff --git a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx index 9651ba90c..e78be299f 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx @@ -1,18 +1,75 @@ +import { LockOutlined, TeamOutlined } from '@ant-design/icons'; +import { Switch, Table, TableColumnsType, Tag, Tooltip } from 'antd'; import { observer } from 'mobx-react-lite'; import React from 'react'; -import { NoContent, Pagination } from 'UI'; -import { useStore } from 'App/mstore'; -import { sliceListPerPage } from 'App/utils'; -import DashboardListItem from './DashboardListItem'; -import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; -import { Tooltip } from 'antd'; +import { connect } from 'react-redux'; +import { withRouter } from 'react-router-dom'; -function DashboardList() { +import { checkForRecent } from 'App/date'; +import { useStore } from 'App/mstore'; +import Dashboard from 'App/mstore/types/dashboard'; +import { dashboardSelected, withSiteId } from 'App/routes'; +import { NoContent } from 'UI'; + +import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; + +function DashboardList({ history, siteId }: { history: any; siteId: string }) { const { dashboardStore } = useStore(); const list = dashboardStore.filteredList; const dashboardsSearch = dashboardStore.filter.query; const lenth = list.length; + + const tableConfig: TableColumnsType = [ + { + title: 'Title', + dataIndex: 'name', + width: '25%', + render: (t) =>
{t}
, + }, + { + title: 'Description', + ellipsis: { + showTitle: false, + }, + width: '25%', + dataIndex: 'description', + }, + { + title: 'Last Modified', + dataIndex: 'updatedAt', + width: '16.67%', + sorter: (a, b) => a.updatedAt.toMillis() - b.updatedAt.toMillis(), + sortDirections: ['ascend', 'descend'], + render: (date) => checkForRecent(date, 'LLL dd, yyyy, hh:mm a'), + }, + { + title: 'Modified By', + dataIndex: 'updatedBy', + width: '16.67%', + sorter: (a, b) => a.updatedBy.localeCompare(b.updatedBy), + sortDirections: ['ascend', 'descend'], + }, + { + title: ( +
+
Visibility
+ + dashboardStore.updateKey('filter', { + ...dashboardStore.filter, + showMine: !dashboardStore.filter.showMine, + })} checkedChildren={'Public'} unCheckedChildren={'Private'} /> +
+ ), + width: '16.67%', + dataIndex: 'isPublic', + render: (isPublic: boolean) => ( + : }> + {isPublic ? 'Team' : 'Private'} + + ), + }, + ]; return (
- {dashboardsSearch !== '' ? 'No matching results' : "You haven't created any dashboards yet"} + {dashboardsSearch !== '' + ? 'No matching results' + : "You haven't created any dashboards yet"}
} subtext={
- A Dashboard is a collection of Utilize cards to visualize key user interactions or product performance metrics.
} className="text-center">Cards that can be shared across teams. + A Dashboard is a collection of{' '} + + Utilize cards to visualize key user interactions or product + performance metrics. + + } + className="text-center" + > + Cards + {' '} + that can be shared across teams. } > -
-
-
Title
-
Visibility
-
Last Modified
-
- - {sliceListPerPage(list, dashboardStore.page - 1, dashboardStore.pageSize).map( - (dashboard: any) => ( - - - - ) - )} -
- -
-
- Showing{' '} - {Math.min(list.length, dashboardStore.pageSize)}{' '} - out of {list.length} Dashboards -
- dashboardStore.updateKey('page', page)} - limit={dashboardStore.pageSize} - debounceRequest={100} - /> -
+ + `Showing ${range[0]}-${range[1]} of ${total} items`, + size: 'small', + }} + onRow={(record) => ({ + onClick: () => { + dashboardStore.selectDashboardById(record.dashboardId); + const path = withSiteId( + dashboardSelected(record.dashboardId), + siteId + ); + history.push(path); + }, + })} + /> ); } -export default observer(DashboardList); +export default connect((state: any) => ({ + siteId: state.getIn(['site', 'siteId']), +}))(withRouter(observer(DashboardList))); diff --git a/frontend/app/components/Dashboard/components/DashboardList/DashboardListItem.tsx b/frontend/app/components/Dashboard/components/DashboardList/DashboardListItem.tsx deleted file mode 100644 index e076dd6d5..000000000 --- a/frontend/app/components/Dashboard/components/DashboardList/DashboardListItem.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import { Icon } from 'UI'; -import { connect } from 'react-redux'; -import { IDashboard } from 'App/mstore/types/dashboard'; -import { checkForRecent } from 'App/date'; -import { withSiteId, dashboardSelected } from 'App/routes'; -import { useStore } from 'App/mstore'; -import { withRouter, RouteComponentProps } from 'react-router-dom'; - -interface Props extends RouteComponentProps { - dashboard: IDashboard; - siteId: string; -} - -function DashboardListItem(props: Props) { - const { dashboard, siteId, history } = props; - const { dashboardStore } = useStore(); - - const onItemClick = () => { - dashboardStore.selectDashboardById(dashboard.dashboardId); - const path = withSiteId(dashboardSelected(dashboard.dashboardId), siteId); - history.push(path); - }; - return ( -
-
-
-
-
- -
-
{dashboard.name}
-
-
-
-
- - {dashboard.isPublic ? 'Team' : 'Private'} -
-
-
{checkForRecent(dashboard.createdAt, 'LLL dd, yyyy, hh:mm a')}
-
- {dashboard.description ?
{dashboard.description}
: null} -
- ); -} -// @ts-ignore -export default connect((state) => ({ siteId: state.getIn(['site', 'siteId']) }))(withRouter(DashboardListItem)); diff --git a/frontend/app/components/Dashboard/components/DashboardList/DashboardSearch.tsx b/frontend/app/components/Dashboard/components/DashboardList/DashboardSearch.tsx index d60a6886c..e0ad2048c 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/DashboardSearch.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/DashboardSearch.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useState } from 'react'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; -import { Icon } from 'UI'; import { debounce } from 'App/utils'; +import { Input } from 'antd'; let debounceUpdate: any = () => {}; @@ -24,16 +24,15 @@ function DashboardSearch() { }; return ( -
- - -
+ dashboardStore.updateKey('filter', { ...dashboardStore.filter, query: value })} + /> ); } diff --git a/frontend/app/components/Dashboard/components/DashboardList/Header.tsx b/frontend/app/components/Dashboard/components/DashboardList/Header.tsx index 9290ff799..ef92298dc 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/Header.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/Header.tsx @@ -1,10 +1,11 @@ import React from 'react'; -import { Button, PageTitle, Toggler, Icon } from 'UI'; -import Select from 'Shared/Select'; +import { PageTitle } from 'UI'; import DashboardSearch from './DashboardSearch'; import { useStore } from 'App/mstore'; import { observer, useObserver } from 'mobx-react-lite'; import { withSiteId } from 'App/routes'; +import { Button } from 'antd' +import { PlusOutlined } from "@ant-design/icons"; function Header({ history, siteId }: { history: any; siteId: string }) { const { dashboardStore } = useStore(); @@ -19,46 +20,32 @@ function Header({ history, siteId }: { history: any; siteId: string }) { }; return ( - <> -
+
-
+ {/* dashboardStore.updateKey('sort', { by: value.value })}*/} + {/*/>*/}
-
- - dashboardStore.updateKey('filter', { - ...dashboardStore.filter, - showMine: !dashboardStore.filter.showMine, - }) - } - /> -