Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
f85345d2
Commit
f85345d2
authored
Sep 29, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Oct 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update shared components in filter-select lists
parent
32074657
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
+13
-10
FilterSelect.js
src/sidebar/components/FilterSelect.js
+4
-4
NotebookFilters.js
src/sidebar/components/NotebookFilters.js
+3
-1
FilterSelect-test.js
src/sidebar/components/test/FilterSelect-test.js
+4
-4
NotebookFilters-test.js
src/sidebar/components/test/NotebookFilters-test.js
+2
-1
No files found.
src/sidebar/components/FilterSelect.js
View file @
f85345d2
import
{
Icon
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
Menu
from
'./Menu'
;
...
...
@@ -6,12 +5,13 @@ import MenuItem from './MenuItem';
/**
* @typedef {import('../store/modules/filters').FilterOption} FilterOption
* @typedef {import('@hypothesis/frontend-shared/lib/types').IconComponent} IconComponent
*/
/**
* @typedef FilterSelectProps
* @prop {FilterOption} defaultOption
* @prop {
string
} [icon]
* @prop {
IconComponent
} [icon]
* @prop {(selectedFilter: FilterOption) => void} onSelect
* @prop {FilterOption[]} options
* @prop {FilterOption} [selectedOption]
...
...
@@ -26,7 +26,7 @@ import MenuItem from './MenuItem';
*/
function
FilterSelect
({
defaultOption
,
icon
,
icon
:
Icon
,
onSelect
,
options
,
selectedOption
,
...
...
@@ -43,7 +43,7 @@ function FilterSelect({
'text-color-text font-bold text-lg'
)}
>
{
icon
&&
<
Icon
name
=
{
icon
}
classes
=
"w-4 h-4"
/>
}
{
Icon
&&
<
Icon
className
=
"w-4 h-4"
/>
}
{
selected
.
display
}
<
/span
>
);
...
...
src/sidebar/components/NotebookFilters.js
View file @
f85345d2
import
{
ProfileIcon
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
{
useSidebarStore
}
from
'../store'
;
import
{
useUserFilterOptions
}
from
'./hooks/use-filter-options'
;
...
...
@@ -19,7 +21,7 @@ function NotebookFilters() {
return
(
<
FilterSelect
defaultOption
=
{{
value
:
''
,
display
:
'Everybody'
}}
icon
=
"profile"
icon
=
{
ProfileIcon
}
onSelect
=
{
userFilter
=>
store
.
setFilter
(
'user'
,
userFilter
)}
options
=
{
userFilterOptions
}
selectedOption
=
{
userFilter
}
...
...
src/sidebar/components/test/FilterSelect-test.js
View file @
f85345d2
import
{
ProfileIcon
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
{
mount
}
from
'enzyme'
;
import
FilterSelect
,
{
$imports
}
from
'../FilterSelect'
;
...
...
@@ -61,13 +62,12 @@ describe('FilterSelect', () => {
});
it
(
'should render provided icon and selected option in label'
,
()
=>
{
const
wrapper
=
createComponent
({
icon
:
'profile'
});
const
wrapper
=
createComponent
({
icon
:
ProfileIcon
});
const
label
=
mount
(
wrapper
.
find
(
'Menu'
).
props
().
label
);
const
icon
=
label
.
find
(
'Icon'
);
const
icon
=
label
.
find
(
'
Profile
Icon'
);
assert
.
isTrue
(
icon
.
exists
());
assert
.
equal
(
icon
.
props
().
name
,
'profile'
);
// Default option should be selected as we didn't indicate a selected option
assert
.
include
(
label
.
text
(),
'all'
);
});
...
...
@@ -104,7 +104,7 @@ describe('FilterSelect', () => {
content
:
()
=>
{
$imports
.
$restore
();
return
createComponent
({
icon
:
'profile'
,
icon
:
ProfileIcon
,
title
:
'Select something'
,
selectedOption
:
{
value
:
'twovalue'
,
display
:
'Two Value'
},
});
...
...
src/sidebar/components/test/NotebookFilters-test.js
View file @
f85345d2
import
{
ProfileIcon
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
{
mount
}
from
'enzyme'
;
import
NotebookFilters
from
'../NotebookFilters'
;
...
...
@@ -47,7 +48,7 @@ describe('NotebookFilters', () => {
value
:
'oneuser'
,
});
assert
.
deepEqual
(
props
.
defaultOption
,
{
value
:
''
,
display
:
'Everybody'
});
assert
.
equal
(
props
.
icon
,
'profile'
);
assert
.
equal
(
props
.
icon
,
ProfileIcon
);
assert
.
equal
(
props
.
title
,
'Filter by user'
);
assert
.
equal
(
props
.
options
.
length
,
1
);
assert
.
isUndefined
(
props
.
selectedOption
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment