feat(ui) - cards - fixes and ui improvements

This commit is contained in:
Shekar Siri 2023-01-03 18:09:25 +01:00
parent 1f9f78ca0f
commit ae080a0add
8 changed files with 44 additions and 26 deletions

View file

@ -10,8 +10,8 @@ function AddCardModal(props: Props) {
return ( return (
<> <>
<Modal.Header title="Add Card" /> <Modal.Header title="Add Card" />
<Modal.Content className="p-0"> <Modal.Content className="px-3 pb-6">
<MetricTypeList siteId={props.siteId} dashboardId={props.dashboardId} /> <MetricTypeList siteId={props.siteId} dashboardId={parseInt(props.dashboardId)} />
</Modal.Content> </Modal.Content>
</> </>
); );

View file

@ -3,7 +3,8 @@ import { Icon, Checkbox, Tooltip } from 'UI';
import { checkForRecent } from 'App/date'; import { checkForRecent } from 'App/date';
import { withRouter, RouteComponentProps } from 'react-router-dom'; import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withSiteId } from 'App/routes'; import { withSiteId } from 'App/routes';
import { TYPES, TIMESERIES, TABLE, CLICKMAP, FUNNEL, ERRORS, RESOURCE_MONITORING } from 'App/constants/card'; import { TYPES } from 'App/constants/card';
import cn from 'classnames';
interface Props extends RouteComponentProps { interface Props extends RouteComponentProps {
metric: any; metric: any;
@ -32,7 +33,10 @@ function MetricTypeIcon({ type }: any) {
function MetricListItem(props: Props) { function MetricListItem(props: Props) {
const { metric, history, siteId, selected, toggleSelection = () => {}, disableSelection = false } = props; const { metric, history, siteId, selected, toggleSelection = () => {}, disableSelection = false } = props;
const onItemClick = () => { const onItemClick = (e: React.MouseEvent) => {
if (!disableSelection) {
return toggleSelection(e);
}
const path = withSiteId(`/metrics/${metric.metricId}`, siteId); const path = withSiteId(`/metrics/${metric.metricId}`, siteId);
history.push(path); history.push(path);
}; };
@ -55,7 +59,7 @@ function MetricListItem(props: Props) {
<div className="flex items-center"> <div className="flex items-center">
<MetricTypeIcon type={metric.metricType} /> <MetricTypeIcon type={metric.metricType} />
<div className="link capitalize-first">{metric.name}</div> <div className={ cn("capitalize-first", { "link" : disableSelection })}>{metric.name}</div>
</div> </div>
</div> </div>
<div className="col-span-4">{metric.owner}</div> <div className="col-span-4">{metric.owner}</div>

View file

@ -21,15 +21,16 @@ function MetricTypeItem(props: Props) {
} = props; } = props;
return ( return (
<div <div
className="flex items-start p-4 hover:bg-active-blue cursor-pointer group hover-color-teal" className="rounded color-gray-darkest flex items-start border border-transparent p-4 hover:bg-active-blue hover:!border-active-blue-border cursor-pointer group hover-color-teal"
onClick={onClick} onClick={onClick}
> >
<div className="pr-4 pt-1"> <div className="pr-4 pt-1">
<Icon name={icon} size="20" /> {/* @ts-ignore */}
<Icon name={icon} size="20" color="gray-dark" />
</div> </div>
<div className="flex flex-col items-start text-left"> <div className="flex flex-col items-start text-left">
<div className="text-base group-hover:color-teal">{title}</div> <div className="text-base">{title}</div>
<div className="text-xs">{description}</div> <div className="text-sm color-gray-medium font-normal">{description}</div>
</div> </div>
</div> </div>
); );

View file

@ -50,7 +50,7 @@ function MetricViewHeader() {
</div> </div>
<div className="text-base text-disabled-text flex items-center px-6"> <div className="text-base text-disabled-text flex items-center px-6">
<Icon name="info-circle-fill" className="mr-2" size={16} /> <Icon name="info-circle-fill" className="mr-2" size={16} />
Create custom Metrics to capture key interactions and track KPIs. Create custom Cards to capture key interactions and track KPIs.
</div> </div>
</div> </div>
); );

View file

@ -18,9 +18,9 @@ function GridView(props: Props) {
key={metric.metricId} key={metric.metricId}
widget={metric} widget={metric}
active={selectedList.includes(metric.metricId)} active={selectedList.includes(metric.metricId)}
isTemplate={true} // isTemplate={true}
isWidget={metric.metricType === 'predefined'} isWidget={metric.metricType === 'predefined'}
onClick={() => toggleSelection(parseInt(metric.metricId))} // onClick={() => toggleSelection(parseInt(metric.metricId))}
/> />
</React.Fragment> </React.Fragment>
))} ))}

View file

@ -8,26 +8,28 @@ interface Props {
selectedList: any; selectedList: any;
toggleSelection?: (metricId: any) => void; toggleSelection?: (metricId: any) => void;
toggleAll?: (e: any) => void; toggleAll?: (e: any) => void;
disableSelection?: boolean disableSelection?: boolean;
allSelected?: boolean
} }
function ListView(props: Props) { function ListView(props: Props) {
const { siteId, list, selectedList, toggleSelection, disableSelection = false } = props; const { siteId, list, selectedList, toggleSelection, disableSelection = false, allSelected = false } = props;
return ( return (
<div> <div>
<div className="grid grid-cols-12 py-2 font-medium px-6"> <div className="grid grid-cols-12 py-2 font-medium px-6">
{!disableSelection && ( <div className="col-span-4 flex items-center">
<div className="col-span-4 flex items-center"> {!disableSelection && (
<Checkbox <Checkbox
name="slack" name="slack"
className="mr-4" className="mr-4"
type="checkbox" type="checkbox"
checked={selectedList.length === list.length} checked={allSelected}
// onClick={() => selectedList(list.map((i: any) => i.metricId))} // onClick={() => selectedList(list.map((i: any) => i.metricId))}
onClick={props.toggleAll} onClick={props.toggleAll}
/> />
)}
<span>Title</span> <span>Title</span>
</div> </div>
)}
<div className="col-span-4">Owner</div> <div className="col-span-4">Owner</div>
<div className="col-span-2">Visibility</div> <div className="col-span-2">Visibility</div>
<div className="col-span-2 text-right">Last Modified</div> <div className="col-span-2 text-right">Last Modified</div>

View file

@ -76,6 +76,7 @@ function MetricsList({
list={sliceListPerPage(list, metricStore.page - 1, metricStore.pageSize)} list={sliceListPerPage(list, metricStore.page - 1, metricStore.pageSize)}
selectedList={selectedMetrics} selectedList={selectedMetrics}
toggleSelection={toggleMetricSelection} toggleSelection={toggleMetricSelection}
allSelected={list.length === selectedMetrics.length}
toggleAll={({ target: { checked, name } }) => toggleAll={({ target: { checked, name } }) =>
setSelectedMetrics(checked ? list.map((i: any) => i.metricId) : []) setSelectedMetrics(checked ? list.map((i: any) => i.metricId) : [])
} }
@ -93,7 +94,7 @@ function MetricsList({
<div className="text-disabled-text"> <div className="text-disabled-text">
Showing{' '} Showing{' '}
<span className="font-semibold">{Math.min(list.length, metricStore.pageSize)}</span> out <span className="font-semibold">{Math.min(list.length, metricStore.pageSize)}</span> out
of <span className="font-semibold">{list.length}</span> metrics of <span className="font-semibold">{list.length}</span> cards
</div> </div>
<Pagination <Pagination
page={metricStore.page} page={metricStore.page}

View file

@ -359,4 +359,14 @@ p {
.dev-row { .dev-row {
transition: all 0.5s; transition: all 0.5s;
}
.hover-color-teal:hover {
color: $teal !important;
& div {
color: $teal !important;
}
& svg {
fill: $teal !important;
}
} }