diff --git a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx index 6be30c7b5..7661d58cc 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx @@ -30,6 +30,8 @@ function DashboardList({ siteId }: { siteId: string }) { title: 'Title', dataIndex: 'name', width: '25%', + sorter: (a, b) => a.name?.localeCompare(b.name), + sortDirections: ['ascend', 'descend'], render: (t) =>
{t}
, }, { diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx index e365d8bae..f4c1bdf92 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx @@ -17,7 +17,7 @@ import { WEB_VITALS } from 'App/constants/card'; import { FilterKey } from 'Types/filter/filterType'; -import { Activity, BarChart, TableCellsMerge, TrendingUp } from 'lucide-react'; +import { Activity, BarChart, TableCellsMerge, SearchSlash, TrendingUp } from 'lucide-react'; import WebVital from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/WebVital'; import ByIssues from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByIssues'; import InsightsExample from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/InsightsExample'; @@ -46,7 +46,7 @@ export const CARD_CATEGORIES = [ { key: CARD_CATEGORY.PRODUCT_ANALYTICS, label: 'Product Analytics', icon: TrendingUp, types: [USER_PATH, ERRORS] }, { key: CARD_CATEGORY.PERFORMANCE_MONITORING, label: 'Performance Monitoring', icon: Activity, types: [TIMESERIES] }, { key: CARD_CATEGORY.WEB_ANALYTICS, label: 'Web Analytics', icon: BarChart, types: [TABLE] }, - { key: CARD_CATEGORY.ERROR_TRACKING, label: 'Errors Tracking', icon: TableCellsMerge, types: [WEB_VITALS] }, + { key: CARD_CATEGORY.ERROR_TRACKING, label: 'Errors Tracking', icon: SearchSlash, types: [WEB_VITALS] }, { key: CARD_CATEGORY.WEB_VITALS, label: 'Web Vitals', icon: TableCellsMerge, types: [WEB_VITALS] } ]; diff --git a/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx b/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx index 4071f1f55..bc0f5b2e0 100644 --- a/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx +++ b/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; -import { Icon, Checkbox, confirm, Modal } from 'UI'; -import { Dropdown, Button, Input, Tooltip } from 'antd'; -import { checkForRecent } from 'App/date'; +import { Icon } from 'UI'; +import { Tooltip, Modal, Input, Button, Dropdown, Menu, Tag } from 'antd'; +import { UserOutlined, UserAddOutlined, TeamOutlined, LockOutlined, EditOutlined, DeleteOutlined, MoreOutlined } from '@ant-design/icons'; import { withRouter, RouteComponentProps } from 'react-router-dom'; import { withSiteId } from 'App/routes'; import { TYPES } from 'App/constants/card'; @@ -16,6 +16,7 @@ interface Props extends RouteComponentProps { selected?: boolean; toggleSelection?: any; disableSelection?: boolean; + renderColumn: string; } function MetricTypeIcon({ type }: any) { @@ -28,21 +29,21 @@ function MetricTypeIcon({ type }: any) { return ( {card.title}}>
- {card.icon && } + {card.icon && }
); } -function MetricListItem(props: Props) { - const { - metric, - history, - siteId, - selected, - toggleSelection = () => {}, - disableSelection = false, - } = props; +const MetricListItem: React.FC = ({ + metric, + siteId, + history, + selected, + toggleSelection = () => {}, + disableSelection = false, + renderColumn +}) => { const { metricStore } = useStore(); const [isEdit, setIsEdit] = useState(false); const [newName, setNewName] = useState(metric.name); @@ -57,111 +58,103 @@ function MetricListItem(props: Props) { const onMenuClick = async ({ key }: { key: string }) => { if (key === 'delete') { - if (await confirm({ - header: 'Confirm', - confirmButton: 'Yes, delete', - confirmation: `Are you sure you want to permanently delete this card?` - })) { - await metricStore.delete(metric) - // toast.success('Card deleted'); - } + Modal.confirm({ + title: 'Confirm', + content: 'Are you sure you want to permanently delete this card?', + okText: 'Yes, delete', + cancelText: 'No', + onOk: async () => { + await metricStore.delete(metric); + }, + }); } if (key === 'rename') { setIsEdit(true); } - } + }; + const onRename = async () => { try { metric.updateKey('name', newName); await metricStore.save(metric); - void metricStore.fetchList() - setIsEdit(false) + metricStore.fetchList(); + setIsEdit(false); } catch (e) { - console.log(e) + console.log(e); toast.error('Failed to rename card'); - }} + } + }; - return ( - <> - setIsEdit(false)}> - Rename Card - - setNewName(e.target.value)} - /> - - - - - - - -
-
- {!disableSelection && ( - - )} - -
- -
{metric.name}
-
-
-
{metric.owner}
-
-
- - {metric.isPublic ? 'Team' : 'Private'} -
-
-
- {metric.lastModified && checkForRecent(metric.lastModified, 'LLL dd, yyyy, hh:mm a')} -
-
e.stopPropagation()}> - , - }, - { - label: "Delete", - key: "delete", - icon: - } - ], - onClick: onMenuClick, - }}> -
- -
-
-
-
- + const renderModal = () => ( + setIsEdit(false)} + footer={[ + , + , + ]} + > + setNewName(e.target.value)} + /> + ); -} + + switch (renderColumn) { + case 'title': + return ( + <> +
+ +
{metric.name}
+
+ {renderModal()} + + ); + case 'owner': + return
{metric.owner}
; + case 'visibility': + return ( +
+ + {metric.isPublic ? : } + {metric.isPublic ? 'Team' : 'Private'} + +
+ ); + case 'lastModified': + return new Date(metric.lastModified).toLocaleString(); + case 'options': + return ( + <> + + }> + Rename + + }> + Delete + + + } + trigger={['click']} + > +