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
4c4c017d
Commit
4c4c017d
authored
Aug 29, 2023
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable group switch and logout during import
Fixes
https://github.com/hypothesis/client/issues/5774
parent
261d0cd8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
GroupList.tsx
src/sidebar/components/GroupList/GroupList.tsx
+4
-0
GroupList-test.js
src/sidebar/components/GroupList/test/GroupList-test.js
+8
-0
UserMenu.tsx
src/sidebar/components/UserMenu.tsx
+13
-3
UserMenu-test.js
src/sidebar/components/test/UserMenu-test.js
+15
-0
No files found.
src/sidebar/components/GroupList/GroupList.tsx
View file @
4c4c017d
...
...
@@ -40,6 +40,9 @@ function GroupList({ settings }: GroupListProps) {
const
focusedGroup
=
store
.
focusedGroup
();
const
userid
=
store
.
profile
().
userid
;
// Prevent changing groups during an import
const
disabled
=
store
.
importsPending
()
>
0
;
const
myGroupsSorted
=
useMemo
(
()
=>
groupsByOrganization
(
myGroups
),
[
myGroups
],
...
...
@@ -117,6 +120,7 @@ function GroupList({ settings }: GroupListProps) {
<
Menu
align=
"left"
contentClass=
"min-w-[250px]"
disabled=
{
disabled
}
label=
{
label
}
onOpenChanged=
{
()
=>
setExpandedGroup
(
null
)
}
title=
{
menuTitle
}
...
...
src/sidebar/components/GroupList/test/GroupList-test.js
View file @
4c4c017d
...
...
@@ -50,6 +50,7 @@ describe('GroupList', () => {
getLink
:
sinon
.
stub
().
returns
(
''
),
getMyGroups
:
sinon
.
stub
().
returns
([]),
focusedGroup
:
sinon
.
stub
().
returns
(
testGroup
),
importsPending
:
sinon
.
stub
().
returns
(
0
),
profile
:
sinon
.
stub
().
returns
({
userid
:
null
}),
};
fakeServiceConfig
=
sinon
.
stub
().
returns
(
null
);
...
...
@@ -72,6 +73,13 @@ describe('GroupList', () => {
assert
.
equal
(
menu
.
props
().
title
,
'Select group (now viewing: Test group)'
);
});
it
(
'disables menu if imports are in progress'
,
()
=>
{
fakeStore
.
importsPending
.
returns
(
1
);
const
wrapper
=
createGroupList
();
const
menu
=
wrapper
.
find
(
'Menu'
);
assert
.
isTrue
(
menu
.
prop
(
'disabled'
));
});
it
(
'adds descriptive label text if no currently-focused group'
,
()
=>
{
fakeStore
.
focusedGroup
.
returns
(
undefined
);
const
wrapper
=
createGroupList
();
...
...
src/sidebar/components/UserMenu.tsx
View file @
4c4c017d
...
...
@@ -42,8 +42,14 @@ function UserMenu({ frameSync, onLogout, settings }: UserMenuProps) {
const
isSelectableProfile
=
!
isThirdParty
||
serviceSupports
(
'onProfileRequestProvided'
);
const
isLogoutEnabled
=
// Is logging out generally possible for the current user?
const
logoutAvailable
=
!
isThirdParty
||
serviceSupports
(
'onLogoutRequestProvided'
);
// Is logging out possible right now?
const
logoutDisabled
=
store
.
importsPending
()
>
0
;
const
isProfileEnabled
=
store
.
isFeatureEnabled
(
'client_user_profile'
);
const
onSelectNotebook
=
()
=>
{
...
...
@@ -104,9 +110,13 @@ function UserMenu({ frameSync, onLogout, settings }: UserMenuProps) {
)
}
<
MenuItem
label=
"Open notebook"
onClick=
{
()
=>
onSelectNotebook
()
}
/>
</
MenuSection
>
{
isLogoutEnabled
&&
(
{
logoutAvailable
&&
(
<
MenuSection
>
<
MenuItem
label=
"Log out"
onClick=
{
onLogout
}
/>
<
MenuItem
isDisabled=
{
logoutDisabled
}
label=
"Log out"
onClick=
{
onLogout
}
/>
</
MenuSection
>
)
}
</
Menu
>
...
...
src/sidebar/components/test/UserMenu-test.js
View file @
4c4c017d
...
...
@@ -48,6 +48,7 @@ describe('UserMenu', () => {
focusedGroupId
:
sinon
.
stub
().
returns
(
'mygroup'
),
getLink
:
sinon
.
stub
(),
profile
:
sinon
.
stub
().
returns
(
fakeProfile
),
importsPending
:
sinon
.
stub
().
returns
(
0
),
isFeatureEnabled
:
fakeIsFeatureEnabled
,
};
...
...
@@ -296,6 +297,20 @@ describe('UserMenu', () => {
});
describe
(
'log out menu item'
,
()
=>
{
it
(
'is disabled if an import is in progress'
,
()
=>
{
fakeStore
.
importsPending
.
returns
(
1
);
const
wrapper
=
createUserMenu
();
let
logOutMenuItem
=
findMenuItem
(
wrapper
,
'Log out'
);
assert
.
isTrue
(
logOutMenuItem
.
prop
(
'isDisabled'
));
fakeStore
.
importsPending
.
returns
(
0
);
wrapper
.
setProps
({});
logOutMenuItem
=
findMenuItem
(
wrapper
,
'Log out'
);
assert
.
isFalse
(
logOutMenuItem
.
prop
(
'isDisabled'
));
});
const
tests
=
[
{
it
:
'should be present for first-party user if no service configured'
,
...
...
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