Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Implement generic filtering and search capabilities #289

Merged
merged 54 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
839acc2
Move data processing to utils
mayan-000 Oct 16, 2023
8129152
Move cookie reshaping to utils
mayan-000 Oct 16, 2023
38194dd
Add sidebar hook and component
mayan-000 Oct 17, 2023
e0a8ac9
Add sidebar data
mayan-000 Oct 17, 2023
9ae70d6
Use sidebar component and component
mayan-000 Oct 17, 2023
e902f20
Update import
mayan-000 Oct 17, 2023
f99d3ed
Move sidebar folder
mayan-000 Oct 17, 2023
781c727
Select first sidebar item by default
mayan-000 Oct 17, 2023
a7abea6
Implement new sidebar in site report component
mayan-000 Oct 17, 2023
198db3f
Move sidebar child out and UI changes
mayan-000 Oct 17, 2023
f6543b8
Put FrameUrls into useMemo
mayan-000 Oct 17, 2023
0aa0e02
Merge branch 'develop' into ref/dashboard-1
mayan-000 Oct 20, 2023
b306228
Merge branch 'develop' into sidebar
mayan-000 Oct 23, 2023
f1d9f20
Change max width for sidebars and css changes
mayan-000 Oct 24, 2023
1e848ed
UI changes
mayan-000 Oct 24, 2023
66c412c
Update icons
mayan-000 Oct 24, 2023
6c20af7
Change message box text
mayan-000 Oct 24, 2023
4af7220
Update unknown frame(s)
mayan-000 Oct 24, 2023
662a990
Merge branch 'ref/dashboard-1' into sidebar
mayan-000 Oct 24, 2023
1feef18
Merge branch 'develop' into ref/dashboard-1
mayan-000 Oct 24, 2023
88798b5
Update icons
mayan-000 Nov 6, 2023
10a8386
Setup input textbox and use in cookie top bar
mayan-000 Nov 6, 2023
84a1d4c
Merge branch 'develop' into sidebar
mayan-000 Nov 8, 2023
0f95326
Merge branch 'develop' into ref/dashboard-1
mayan-000 Nov 8, 2023
0a3d84b
Merge branch 'ref/dashboard-1' into sidebar
mayan-000 Nov 8, 2023
bb843fb
Move sidebar to design-system
mayan-000 Nov 8, 2023
76c7af3
Change sidebar data to obj from arr
mayan-000 Nov 8, 2023
0759119
Add keyboard navigation and move functions to utils
mayan-000 Nov 8, 2023
9e0e5b1
Don't allow autofocus on intial render
mayan-000 Nov 10, 2023
6e87661
Restructure table directory
mayan-000 Nov 13, 2023
b8b5cab
Add filtering and search hooks in table
mayan-000 Nov 13, 2023
c65933d
Add Chips and filter sidebar and modified props
mayan-000 Nov 13, 2023
a1a6717
Add Top bar view
mayan-000 Nov 14, 2023
7bc5ad6
Update folder names
mayan-000 Nov 14, 2023
fa07a5b
Update condition when no keys provided
mayan-000 Nov 14, 2023
ab566ba
Move extractCookies into separate file
mayan-000 Nov 14, 2023
e27c560
Update Input -> TextInput
mayan-000 Nov 14, 2023
09f286c
Add test cases
mayan-000 Nov 14, 2023
fb63208
Merge branch 'sidebar-1' into filters
mayan-000 Nov 14, 2023
247c532
Change function param name
mayan-000 Nov 16, 2023
bbdf49e
Remoce jest-dom
mayan-000 Nov 16, 2023
9573560
Change TextInput -> SearchInput
mayan-000 Nov 16, 2023
a997c25
fix:attribute cookie of frame about:blank to unknown frames
ayushnirwal Nov 17, 2023
e5bb9dc
Update unknown frame with constant
mayan-000 Nov 17, 2023
47463ca
Merge branch 'ref/dashboard-1' into sidebar
mayan-000 Nov 20, 2023
d661140
Export sidebar
mayan-000 Nov 20, 2023
2b1eb74
Refactor util and callback
mayan-000 Nov 20, 2023
8a55ba0
Merge branch 'develop' into ref/dashboard-1
mayan-000 Nov 20, 2023
a1a62bb
Merge branch 'ref/dashboard-1' into sidebar
mayan-000 Nov 23, 2023
607552b
Merge branch 'sidebar' into sidebar-1
mayan-000 Nov 23, 2023
1ac9980
Merge branch 'sidebar-1' into filters
mayan-000 Nov 23, 2023
1a433fb
chore: merge develop and resolve conflicts
ayushnirwal Dec 11, 2023
abf88a7
fix:remove unintended style change
ayushnirwal Dec 11, 2023
29a3978
fix:add types and other minor changes
ayushnirwal Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
## Privacy Sandbox API
* Update `RWS` submission steps text https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/229
* Fix: opaque origin error when using in https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/235
* Refactor: Make functional components in landing page non-collapsible https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/232
* Refactor: Make functional components in landing page non-collapsible https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/232
11,921 changes: 2,507 additions & 9,414 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
* External dependencies.
*/
import React, { useEffect } from 'react';
import { PreferenceDataValues } from '@ps-analysis-tool/common';
import { PreferenceDataValues, noop } from '@ps-analysis-tool/common';

/**
* Internal dependencies.
*/
import ColumnListItem from './columnListItem';
import type { TableOutput } from '../useTable';
import { noop } from '../../../utils';
import type { TableOutput } from '../../useTable';

interface ColumnListProps {
table: TableOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import classNames from 'classnames';
/**
* Internal dependencies.
*/
import type { TableColumn } from '../useTable';
import { TableColumn } from '../../useTable';

interface ColumnListItemProps {
column: TableColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
*/
import React, { useEffect, useRef, useState } from 'react';
import classNames from 'classnames';
import { type PreferenceDataValues } from '@ps-analysis-tool/common';
import { noop, type PreferenceDataValues } from '@ps-analysis-tool/common';
import { createPortal } from 'react-dom';

/**
* Internal dependencies.
*/
import ColumnList from './columnList';
import type { TableOutput } from '../useTable';
import { noop } from '../../../utils';
import { TableOutput } from '../../useTable';

interface ColumnMenuProps {
table: TableOutput;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* External dependencies.
*/
import React from 'react';

/**
* Internal dependencies.
*/
import { ClearIcon } from '../../../../../icons';

interface ChipProps {
filterTitle: string;
value: string;
toggleFilterSelection: () => void;
}

const Chip = ({ filterTitle, value, toggleFilterSelection }: ChipProps) => {
return (
<div className="flex items-center px-2 rounded-sm bg-gainsboro dark:bg-charleston-green mx-1 h-4">
<span className="block whitespace-nowrap text-onyx dark:text-manatee">
{filterTitle + ': ' + value}
</span>
<button
onClick={toggleFilterSelection}
className="w-1.5 h-1.5 text-gray-600 hover:text-gray-800 focus:outline-none ml-1"
>
<ClearIcon className="text-mischka" />
</button>
</div>
);
};

export default Chip;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* External dependencies.
*/
import React from 'react';

/**
* Internal dependencies.
*/
import Chip from './chip';
import type { TableFilter, TableOutput } from '../../../useTable';

interface ChipListProps {
selectedFilters: TableFilter;
toggleFilterSelection: TableOutput['toggleFilterSelection'];
}

const ChipList = ({
selectedFilters,
toggleFilterSelection,
}: ChipListProps) => (
<div className="flex flex-nowrap max-w-full">
{Object.entries(selectedFilters).map(([filterKey, filter]) => {
return Object.keys(filter.filterValues || {}).map((filterValue) => (
<Chip
key={filterValue}
filterTitle={filter.title}
value={filterValue}
toggleFilterSelection={() => {
toggleFilterSelection(filterKey, filterValue);
}}
/>
));
})}
</div>
);

export default ChipList;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* External dependencies.
*/
import React from 'react';

/**
* Internal dependencies.
*/
import ChipList from './chipList';
import { StopIcon } from '../../../../../icons';
import type { TableFilter, TableOutput } from '../../../useTable';

interface ChipsBarProps {
selectedFilters: TableFilter;
toggleFilterSelection: TableOutput['toggleFilterSelection'];
resetFilters: TableOutput['resetFilters'];
}

const ChipsBar = ({
selectedFilters,
toggleFilterSelection,
resetFilters,
}: ChipsBarProps) => {
return (
<div
className={`${
Object.keys(selectedFilters).length === 0 && 'hidden'
} w-full h-[25px] py-1 px-2 flex items-center overflow-x-scroll no-scrollbar bg-anti-flash-white dark:bg-raisin-black border-b border-gray-300 dark:border-quartz`}
>
{Object.keys(selectedFilters).length > 1 && (
<a
href="#"
className="h-full flex items-center text-link text-xs whitespace-nowrap"
onClick={resetFilters}
>
<StopIcon className="text-gray min-w-[14px] min-h-[14px]" />
<span className="ml-1 mr-1 dark:text-bright-gray bg-transparent">
Clear all
</span>
<div className="w-[1px] bg-gainsboro dark:bg-quartz h-[20px]"></div>
</a>
)}
<ChipList
selectedFilters={selectedFilters}
toggleFilterSelection={toggleFilterSelection}
/>
</div>
);
};

export default ChipsBar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* External dependencies.
*/
import React from 'react';

/**
* Internal dependencies.
*/
import ListItem from './listItem';
import type { TableFilter, TableOutput } from '../../useTable';

interface FiltersSidebarProps {
filters: TableFilter;
toggleFilterSelection: TableOutput['toggleFilterSelection'];
}

const FiltersSidebar = ({
filters,
toggleFilterSelection,
}: FiltersSidebarProps) => {
if (!Object.keys(filters).length) {
return null;
}

return (
<div className="h-full overflow-auto p-3">
<ul>
{Object.entries(filters)
.filter(([, filter]) =>
Boolean(Object.keys(filter.filterValues || {}).length)
)
.map(([filterKey, filter]) => (
<ListItem
key={filterKey}
filter={filter}
filterKey={filterKey}
toggleFilterSelection={toggleFilterSelection}
/>
))}
</ul>
</div>
);
};

export default FiltersSidebar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* External dependencies.
*/
import React, { useState } from 'react';
import {
ArrowDown,
InfoIcon,
TableFilter,
TableOutput,
} from '@ps-analysis-tool/design-system';

/**
* Internal dependencies.
*/
import SubList from './subList';

interface ListItemProps {
filter: TableFilter[keyof TableFilter];
filterKey: string;
toggleFilterSelection: TableOutput['toggleFilterSelection'];
}

const ListItem = ({
filter,
filterKey,
toggleFilterSelection,
}: ListItemProps) => {
const [isExpanded, setExpanded] = useState<boolean>(false);
const [showSubList, setShowSubList] = useState<boolean>(false);

const toggleShowMore = () => {
setExpanded(!isExpanded);
};

const toggleSubList = () => {
setShowSubList(!showSubList);
};

return (
<li className="py-[3px]">
<div className="flex gap-2 items-center">
<a
href="#"
className="flex items-center text-asteriod-black dark:text-bright-gray"
onClick={toggleSubList}
>
<span className={showSubList ? '' : '-rotate-90'}>
<ArrowDown />
</span>
<p className="ml-1 leading-normal font-semi-thick">{filter.title}</p>
</a>
{filter.description && (
<p title={filter.description}>
<InfoIcon />
</p>
)}
</div>
{showSubList && (
<>
<SubList
filterValues={filter.filterValues}
filterKey={filterKey}
toggleFilterSelection={toggleFilterSelection}
isExpanded={isExpanded}
/>
{Number(Object.keys(filter.filterValues || {}).length) > 4 && (
<a
onClick={toggleShowMore}
className="text-md text-link ml-2 mt-1 block text-royal-blue dark:text-medium-persian-blue"
href="#"
>
{isExpanded ? 'Show Less' : 'Show More'}
</a>
)}
</>
)}
</li>
);
};

export default ListItem;
Loading
Loading