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
d3f7e4e2
Commit
d3f7e4e2
authored
Apr 22, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Apr 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always show Notebook option in User menu
Show Notebook option in UserMenu regardless of feature-flag status.
parent
d5dcced6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
48 deletions
+29
-48
UserMenu.js
src/sidebar/components/UserMenu.js
+3
-9
UserMenu-test.js
src/sidebar/components/test/UserMenu-test.js
+26
-39
No files found.
src/sidebar/components/UserMenu.js
View file @
d3f7e4e2
...
...
@@ -45,7 +45,6 @@ function UserMenu({ auth, frameSync, onLogout, settings }) {
const
isThirdParty
=
isThirdPartyUser
(
auth
.
userid
,
defaultAuthority
);
const
service
=
serviceConfig
(
settings
);
const
isNotebookEnabled
=
store
.
isFeatureEnabled
(
'notebook_launch'
);
const
[
isOpen
,
setOpen
]
=
useState
(
false
);
/** @param {keyof import('../../types/config').Service} feature */
...
...
@@ -92,9 +91,9 @@ function UserMenu({ auth, frameSync, onLogout, settings }) {
<
/span
>
);
return
(
//
FIXME: KeyDown handling is temporary for Notebook "easter egg"
//
Allow keyboard shortcut 'n' to open Notebook
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */
<
div
className
=
"UserM
enu"
onKeyDown
=
{
onKeyDown
}
>
<
div
data
-
testid
=
"user-m
enu"
onKeyDown
=
{
onKeyDown
}
>
<
Menu
label
=
{
menuLabel
}
title
=
{
auth
.
displayName
}
...
...
@@ -114,12 +113,7 @@ function UserMenu({ auth, frameSync, onLogout, settings }) {
href
=
{
store
.
getLink
(
'account.settings'
)}
/
>
)}
{
isNotebookEnabled
&&
(
<
MenuItem
label
=
"Open notebook"
onClick
=
{()
=>
onSelectNotebook
()}
/
>
)}
<
MenuItem
label
=
"Open notebook"
onClick
=
{()
=>
onSelectNotebook
()}
/
>
<
/MenuSection
>
{
isLogoutEnabled
&&
(
<
MenuSection
>
...
...
src/sidebar/components/test/UserMenu-test.js
View file @
d3f7e4e2
...
...
@@ -46,7 +46,6 @@ describe('UserMenu', () => {
defaultAuthority
:
sinon
.
stub
().
returns
(
'hypothes.is'
),
focusedGroupId
:
sinon
.
stub
().
returns
(
'mygroup'
),
getLink
:
sinon
.
stub
(),
isFeatureEnabled
:
sinon
.
stub
().
returns
(
false
),
};
$imports
.
$mock
(
mockImportedComponents
());
...
...
@@ -183,50 +182,38 @@ describe('UserMenu', () => {
});
describe
(
'open notebook item'
,
()
=>
{
context
(
'notebook feature is enabled'
,
()
=>
{
it
(
'includes the open notebook item'
,
()
=>
{
fakeStore
.
isFeatureEnabled
.
withArgs
(
'notebook_launch'
).
returns
(
true
);
const
wrapper
=
createUserMenu
();
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
assert
.
isTrue
(
openNotebookItem
.
exists
());
});
it
(
'includes the open notebook item'
,
()
=>
{
const
wrapper
=
createUserMenu
();
it
(
'triggers a message when open-notebook item is clicked'
,
()
=>
{
fakeStore
.
isFeatureEnabled
.
withArgs
(
'notebook_launch'
).
returns
(
true
);
const
wrapper
=
createUserMenu
(
);
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
assert
.
isTrue
(
openNotebookItem
.
exists
()
);
}
);
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
openNotebookItem
.
props
().
onClick
();
assert
.
calledOnce
(
fakeFrameSync
.
notifyHost
);
assert
.
calledWith
(
fakeFrameSync
.
notifyHost
,
'openNotebook'
,
'mygroup'
);
});
it
(
'triggers a message when open-notebook item is clicked'
,
()
=>
{
const
wrapper
=
createUserMenu
();
it
(
'opens the notebook and closes itself when `n` is typed'
,
()
=>
{
const
wrapper
=
createUserMenu
();
// Make the menu "open"
act
(()
=>
{
wrapper
.
find
(
'Menu'
).
props
().
onOpenChanged
(
true
);
});
wrapper
.
update
();
assert
.
isTrue
(
wrapper
.
find
(
'Menu'
).
props
().
open
);
wrapper
.
find
(
'.UserMenu'
).
simulate
(
'keydown'
,
{
key
:
'n'
});
assert
.
calledOnce
(
fakeFrameSync
.
notifyHost
);
assert
.
calledWith
(
fakeFrameSync
.
notifyHost
,
'openNotebook'
,
'mygroup'
);
// Now the menu is "closed" again
assert
.
isFalse
(
wrapper
.
find
(
'Menu'
).
props
().
open
);
});
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
openNotebookItem
.
props
().
onClick
();
assert
.
calledOnce
(
fakeFrameSync
.
notifyHost
);
assert
.
calledWith
(
fakeFrameSync
.
notifyHost
,
'openNotebook'
,
'mygroup'
);
});
context
(
'notebook feature is not enabled'
,
()
=>
{
it
(
'does not include the open notebook item'
,
()
=>
{
fakeStore
.
isFeatureEnabled
.
withArgs
(
'notebook_launch'
).
returns
(
false
);
const
wrapper
=
createUserMenu
();
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
assert
.
isFalse
(
openNotebookItem
.
exists
());
it
(
'opens the notebook and closes itself when `n` is typed'
,
()
=>
{
const
wrapper
=
createUserMenu
();
// Make the menu "open"
act
(()
=>
{
wrapper
.
find
(
'Menu'
).
props
().
onOpenChanged
(
true
);
});
wrapper
.
update
();
assert
.
isTrue
(
wrapper
.
find
(
'Menu'
).
props
().
open
);
wrapper
.
find
(
'[data-testid="user-menu"]'
)
.
simulate
(
'keydown'
,
{
key
:
'n'
});
assert
.
calledOnce
(
fakeFrameSync
.
notifyHost
);
assert
.
calledWith
(
fakeFrameSync
.
notifyHost
,
'openNotebook'
,
'mygroup'
);
// Now the menu is "closed" again
assert
.
isFalse
(
wrapper
.
find
(
'Menu'
).
props
().
open
);
});
});
...
...
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