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
71bb4cc4
Commit
71bb4cc4
authored
Jan 17, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure selected user is live updated on export pannel
parent
b06d0d16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
ExportAnnotations.tsx
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
+22
-10
ExportAnnotations-test.js
...bar/components/ShareDialog/test/ExportAnnotations-test.js
+6
-11
No files found.
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
View file @
71bb4cc4
...
...
@@ -116,10 +116,17 @@ function ExportAnnotations({
}),
[
exportableAnnotations
],
);
const
[
selectedUser
,
setSelectedUser
]
=
useState
(
// Try to preselect current user
userList
.
find
(
userInfo
=>
userInfo
.
userid
===
currentUser
)
??
// Try to preselect current user
const
[
selectedUserId
,
setSelectedUserId
]
=
useState
(
currentUser
);
// Re-compute selectedUserAnnotations if:
// - `userList` changes: This means annotations where created/deleted/updated
// - `selectedUserId` changes: This means user was manually changed
const
selectedUserAnnotations
=
useMemo
(
()
=>
userList
.
find
(
user
=>
user
.
userid
===
selectedUserId
)
??
allAnnotationsOption
,
[
allAnnotationsOption
,
selectedUserId
,
userList
],
);
const
exportFormatsEnabled
=
store
.
isFeatureEnabled
(
'export_formats'
);
...
...
@@ -143,7 +150,7 @@ function ExportAnnotations({
const
buildExportContent
=
useCallback
(
(
format
:
ExportFormat
[
'value'
]):
string
=>
{
const
annotationsToExport
=
selectedUser
?.
annotations
??
exportableAnnotations
;
selectedUser
Annotations
?.
annotations
??
exportableAnnotations
;
switch
(
format
)
{
case
'json'
:
{
const
data
=
annotationsExporter
.
buildJSONExportContent
(
...
...
@@ -194,7 +201,7 @@ function ExportAnnotations({
exportableAnnotations
,
group
?.
name
,
profile
,
selectedUser
?.
annotations
,
selectedUser
Annotations
?.
annotations
,
],
);
const
exportAnnotations
=
useCallback
(
...
...
@@ -270,21 +277,26 @@ function ExportAnnotations({
Select which user{"'"}s annotations to export:
</label>
<SelectNext
value={selectedUser}
onChange={setSelectedUser}
value={selectedUser
Id
}
onChange={setSelectedUser
Id
}
buttonId={userSelectId}
buttonContent={
<UserAnnotationsListItem userAnnotations={selectedUser} />
<UserAnnotationsListItem
userAnnotations={selectedUserAnnotations}
/>
}
data-testid="user-select"
>
<SelectNext.Option value={
allAnnotationsOption
}>
<SelectNext.Option value={
undefined
}>
<UserAnnotationsListItem
userAnnotations={allAnnotationsOption}
/>
</SelectNext.Option>
{userList.map(userInfo => (
<SelectNext.Option key={userInfo.userid} value={userInfo}>
<SelectNext.Option
key={userInfo.userid}
value={userInfo.userid}
>
<UserAnnotationsListItem userAnnotations={userInfo} />
</SelectNext.Option>
))}
...
...
src/sidebar/components/ShareDialog/test/ExportAnnotations-test.js
View file @
71bb4cc4
...
...
@@ -210,11 +210,12 @@ describe('ExportAnnotations', () => {
assert
.
equal
(
users
.
length
,
userEntries
.
length
);
for
(
const
[
i
,
entry
]
of
userEntries
.
entries
())
{
const
value
=
users
.
at
(
i
).
prop
(
'value'
);
const
user
=
users
.
at
(
i
);
const
value
=
user
.
prop
(
'value'
);
const
text
=
user
.
text
();
assert
.
equal
(
value
.
userid
,
entry
.
userid
);
assert
.
equal
(
value
.
displayName
,
entry
.
displayName
);
assert
.
equal
(
value
.
annotations
.
length
,
entry
.
annotationsCount
);
assert
.
equal
(
value
,
entry
.
userid
);
assert
.
equal
(
text
,
`
${
entry
.
displayName
}${
entry
.
annotationsCount
}
`
);
}
});
});
...
...
@@ -376,14 +377,8 @@ describe('ExportAnnotations', () => {
// Select the user whose annotations we want to export
const
userList
=
await
waitForTestId
(
wrapper
,
'user-select'
);
const
option
=
userList
.
find
(
SelectNext
.
Option
)
.
filterWhere
(
option
=>
option
.
prop
(
'value'
).
userid
===
'acct:john@example.com'
,
)
.
first
();
act
(()
=>
{
userList
.
prop
(
'onChange'
)(
option
.
prop
(
'value'
)
);
userList
.
prop
(
'onChange'
)(
'acct:john@example.com'
);
});
wrapper
.
update
();
...
...
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