|
|
|
|
@ -55,26 +55,15 @@ function renderDropdownFilter(site, history, [key, value], query) {
|
|
|
|
|
return (
|
|
|
|
|
<Menu.Item key={key}>
|
|
|
|
|
<div className="px-3 md:px-4 sm:py-2 py-3 text-sm leading-tight flex items-center justify-between" key={key + value}>
|
|
|
|
|
{shouldLinkToFilterModal(site, key) &&
|
|
|
|
|
<Link
|
|
|
|
|
title={`Edit filter: ${formattedFilters[key]}`}
|
|
|
|
|
to={{ pathname: `/${encodeURIComponent(site.domain)}/filter/${filterGroupForFilter(key)}`, search: window.location.search }}
|
|
|
|
|
className="group flex w-full justify-between items-center"
|
|
|
|
|
style={{ width: 'calc(100% - 1.5rem)' }}
|
|
|
|
|
>
|
|
|
|
|
<span className="inline-block w-full truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
<PencilSquareIcon className="w-4 h-4 ml-1 cursor-pointer group-hover:text-indigo-700 dark:group-hover:text-indigo-500" />
|
|
|
|
|
</Link>
|
|
|
|
|
}
|
|
|
|
|
{!shouldLinkToFilterModal(site, key) &&
|
|
|
|
|
<div
|
|
|
|
|
onClick={(e) => {e.preventDefault()}}
|
|
|
|
|
className="group flex w-full justify-between items-center"
|
|
|
|
|
style={{ width: 'calc(100% - 1.5rem)' }}
|
|
|
|
|
>
|
|
|
|
|
<span className="inline-block w-full truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
<Link
|
|
|
|
|
title={`Edit filter: ${formattedFilters[key]}`}
|
|
|
|
|
to={{ pathname: `/${encodeURIComponent(site.domain)}/filter/${filterGroupForFilter(key)}`, search: window.location.search }}
|
|
|
|
|
className="group flex w-full justify-between items-center"
|
|
|
|
|
style={{ width: 'calc(100% - 1.5rem)' }}
|
|
|
|
|
>
|
|
|
|
|
<span className="inline-block w-full truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
<PencilSquareIcon className="w-4 h-4 ml-1 cursor-pointer group-hover:text-indigo-700 dark:group-hover:text-indigo-500" />
|
|
|
|
|
</Link>
|
|
|
|
|
<b title={`Remove filter: ${formattedFilters[key]}`} className="ml-2 cursor-pointer hover:text-indigo-700 dark:hover:text-indigo-500" onClick={() => removeFilter(key, history, query)}>
|
|
|
|
|
<XMarkIcon className="w-4 h-4" />
|
|
|
|
|
</b>
|
|
|
|
|
@ -83,10 +72,6 @@ function renderDropdownFilter(site, history, [key, value], query) {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shouldLinkToFilterModal(site, key) {
|
|
|
|
|
return key !== 'props' || site.flags.custom_dimension_filter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function filterDropdownOption(site, option) {
|
|
|
|
|
return (
|
|
|
|
|
<Menu.Item key={option}>
|
|
|
|
|
@ -110,7 +95,6 @@ function DropdownContent({ history, site, query, wrapped }) {
|
|
|
|
|
|
|
|
|
|
if (wrapped === 0 || addingFilter) {
|
|
|
|
|
return Object.keys(FILTER_GROUPS)
|
|
|
|
|
.filter((option) => option === 'props' ? site.flags.custom_dimension_filter : true)
|
|
|
|
|
.map((option) => filterDropdownOption(site, option))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -219,16 +203,9 @@ class Filters extends React.Component {
|
|
|
|
|
renderListFilter(history, [key, value], query) {
|
|
|
|
|
return (
|
|
|
|
|
<span key={key} title={value} className="flex bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 shadow text-sm rounded mr-2 items-center">
|
|
|
|
|
{shouldLinkToFilterModal(this.props.site, key) &&
|
|
|
|
|
<Link title={`Edit filter: ${formattedFilters[key]}`} className="flex w-full h-full items-center py-2 pl-3" to={{ pathname: `/${encodeURIComponent(this.props.site.domain)}/filter/${filterGroupForFilter(key)}`, search: window.location.search }}>
|
|
|
|
|
<span className="inline-block max-w-2xs md:max-w-xs truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
}
|
|
|
|
|
{!shouldLinkToFilterModal(this.props.site, key) &&
|
|
|
|
|
<div className="flex w-full h-full items-center py-2 pl-3">
|
|
|
|
|
<span className="inline-block max-w-2xs md:max-w-xs truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
<Link title={`Edit filter: ${formattedFilters[key]}`} className="flex w-full h-full items-center py-2 pl-3" to={{ pathname: `/${encodeURIComponent(this.props.site.domain)}/filter/${filterGroupForFilter(key)}`, search: window.location.search }}>
|
|
|
|
|
<span className="inline-block max-w-2xs md:max-w-xs truncate">{filterText(key, value, query)}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
<span title={`Remove filter: ${formattedFilters[key]}`} className="flex h-full w-full px-2 cursor-pointer hover:text-indigo-700 dark:hover:text-indigo-500 items-center" onClick={() => removeFilter(key, history, query)}>
|
|
|
|
|
<XMarkIcon className="w-4 h-4" />
|
|
|
|
|
</span>
|
|
|
|
|
|