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
cd7dbf51
Commit
cd7dbf51
authored
Jul 16, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jul 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify `focusMode` in `selection` module
- Rename `enabled` to `configured`
parent
1bcc0b06
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
28 deletions
+45
-28
sidebar-content.js
src/sidebar/components/sidebar-content.js
+1
-1
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+2
-2
selection.js
src/sidebar/store/modules/selection.js
+27
-10
selection-test.js
src/sidebar/store/modules/test/selection-test.js
+15
-15
No files found.
src/sidebar/components/sidebar-content.js
View file @
cd7dbf51
...
...
@@ -32,7 +32,7 @@ function SidebarContent({
// Store state values
const
focusedGroupId
=
useStore
(
store
=>
store
.
focusedGroupId
());
const
hasAppliedFilter
=
useStore
(
store
=>
store
.
hasAppliedFilter
());
const
isFocusedMode
=
useStore
(
store
=>
store
.
focusMode
Enabl
ed
());
const
isFocusedMode
=
useStore
(
store
=>
store
.
focusMode
Configur
ed
());
const
isLoading
=
useStore
(
store
=>
store
.
isLoading
());
const
isLoggedIn
=
useStore
(
store
=>
store
.
isLoggedIn
());
const
linkedAnnotationId
=
useStore
(
store
=>
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
cd7dbf51
...
...
@@ -52,7 +52,7 @@ describe('SidebarContent', () => {
directLinkedGroupFetchFailed
:
sinon
.
stub
(),
findAnnotationByID
:
sinon
.
stub
(),
focusedGroupId
:
sinon
.
stub
(),
focusMode
Enabl
ed
:
sinon
.
stub
(),
focusMode
Configur
ed
:
sinon
.
stub
(),
hasAppliedFilter
:
sinon
.
stub
(),
hasFetchedAnnotations
:
sinon
.
stub
(),
hasSidebarOpened
:
sinon
.
stub
(),
...
...
@@ -226,7 +226,7 @@ describe('SidebarContent', () => {
});
it
(
'renders a focused header if in focused mode'
,
()
=>
{
fakeStore
.
focusMode
Enabl
ed
.
returns
(
true
);
fakeStore
.
focusMode
Configur
ed
.
returns
(
true
);
const
wrapper
=
createComponent
();
assert
.
isTrue
(
wrapper
.
find
(
'FocusedModeHeader'
).
exists
());
...
...
src/sidebar/store/modules/selection.js
View file @
cd7dbf51
...
...
@@ -60,6 +60,23 @@ function initialSelection(settings) {
return
selection
;
}
// function initialFocus(settings) {
// const focusConfig = {
// configured: false,
// active: false,
// user: undefined,
// };
//
// if (settings.hasOwnProperty('user')) {
// const focusedUser = {...settings.user};
// if (focusedUser.username && focusedUser.authority) {
// focusConfig.configured = true;
// focusConfig.user = focusedUser;
// }
// }
// return focusConfig;
// }
function
init
(
settings
)
{
return
{
/**
...
...
@@ -96,7 +113,7 @@ function init(settings) {
filterQuery
:
settings
.
query
||
null
,
focusMode
:
{
enabl
ed
:
settings
.
hasOwnProperty
(
'focus'
),
configur
ed
:
settings
.
hasOwnProperty
(
'focus'
),
focused
:
true
,
// Copy over the focus confg from settings object
config
:
{
...(
settings
.
focus
?
settings
.
focus
:
{})
},
...
...
@@ -163,7 +180,7 @@ const update = {
return
{
focusMode
:
{
...
state
.
focusMode
,
enabl
ed
:
false
,
configur
ed
:
false
,
focused
:
false
,
},
};
...
...
@@ -171,7 +188,7 @@ const update = {
return
{
focusMode
:
{
...
state
.
focusMode
,
enabl
ed
:
true
,
configur
ed
:
true
,
focused
:
true
,
config
:
{
user
:
{
...
action
.
user
},
...
...
@@ -464,21 +481,21 @@ function filterQuery(state) {
}
/**
* Do
the config settings indicate that the client should be in a focused mode
?
* Do
es the configuration used by the app contain valid focus-mode configuration
?
*
* @return {boolean}
*/
function
focusMode
Enabl
ed
(
state
)
{
return
state
.
selection
.
focusMode
.
enabl
ed
;
function
focusMode
Configur
ed
(
state
)
{
return
state
.
selection
.
focusMode
.
configur
ed
;
}
/**
* Is a focus mode
enabl
ed, and is it presently applied?
* Is a focus mode
configur
ed, and is it presently applied?
*
* @return {boolean}
*/
function
focusModeFocused
(
state
)
{
return
focusMode
Enabl
ed
(
state
)
&&
state
.
selection
.
focusMode
.
focused
;
return
focusMode
Configur
ed
(
state
)
&&
state
.
selection
.
focusMode
.
focused
;
}
/**
...
...
@@ -507,7 +524,7 @@ function focusModeUserId(state) {
* @return {boolean}
*/
function
focusModeHasUser
(
state
)
{
return
focusMode
Enabl
ed
(
state
)
&&
!!
focusModeUserId
(
state
);
return
focusMode
Configur
ed
(
state
)
&&
!!
focusModeUserId
(
state
);
}
/**
...
...
@@ -592,7 +609,7 @@ export default {
expandedMap
,
filterQuery
,
focusModeFocused
,
focusMode
Enabl
ed
,
focusMode
Configur
ed
,
focusModeHasUser
,
focusModeUserId
,
focusModeUserPrettyName
,
...
...
src/sidebar/store/modules/test/selection-test.js
View file @
cd7dbf51
...
...
@@ -226,7 +226,7 @@ describe('sidebar/store/modules/selection', () => {
assert
.
equal
(
store
.
focusModeUserId
(),
'testuser'
);
assert
.
equal
(
store
.
focusModeUserPrettyName
(),
'Test User'
);
assert
.
equal
(
store
.
focusModeFocused
(),
true
);
assert
.
equal
(
store
.
focusMode
Enabl
ed
(),
true
);
assert
.
equal
(
store
.
focusMode
Configur
ed
(),
true
);
});
// When the LMS app wants the client to disable focus mode it sends a
...
...
@@ -243,7 +243,7 @@ describe('sidebar/store/modules/selection', () => {
displayName
:
undefined
,
});
assert
.
equal
(
store
.
focusModeFocused
(),
false
);
assert
.
equal
(
store
.
focusMode
Enabl
ed
(),
false
);
assert
.
equal
(
store
.
focusMode
Configur
ed
(),
false
);
});
it
(
'clears other applied selections'
,
()
=>
{
...
...
@@ -261,51 +261,51 @@ describe('sidebar/store/modules/selection', () => {
});
describe
(
'setFocusModeFocused()'
,
function
()
{
it
(
'sets the focus mode to
enabl
ed'
,
function
()
{
it
(
'sets the focus mode to
focus
ed'
,
function
()
{
store
.
setFocusModeFocused
(
true
);
assert
.
equal
(
getSelectionState
().
focusMode
.
focused
,
true
);
});
it
(
'sets the focus mode to not
enabl
ed'
,
function
()
{
it
(
'sets the focus mode to not
focus
ed'
,
function
()
{
store
=
createStore
([
selection
],
[{
focus
:
{
user
:
{}
}
}]);
store
.
setFocusModeFocused
(
false
);
assert
.
equal
(
getSelectionState
().
focusMode
.
focused
,
false
);
});
});
describe
(
'focusMode
Enabled()
'
,
function
()
{
describe
(
'focusMode
Configured
'
,
function
()
{
it
(
'should be true when the focus setting is present'
,
function
()
{
store
=
createStore
([
selection
],
[{
focus
:
{
user
:
{}
}
}]);
assert
.
equal
(
store
.
focusMode
Enabl
ed
(),
true
);
assert
.
equal
(
store
.
focusMode
Configur
ed
(),
true
);
});
it
(
'should be false when the focus setting is not present'
,
function
()
{
assert
.
equal
(
store
.
focusMode
Enabl
ed
(),
false
);
assert
.
equal
(
store
.
focusMode
Configur
ed
(),
false
);
});
});
describe
(
'focusModeFocused
()
'
,
function
()
{
it
(
'should return true by default when focus mode is
enabl
ed'
,
function
()
{
describe
(
'focusModeFocused'
,
function
()
{
it
(
'should return true by default when focus mode is
focus
ed'
,
function
()
{
store
=
createStore
([
selection
],
[{
focus
:
{
user
:
{}
}
}]);
assert
.
equal
(
getSelectionState
().
focusMode
.
enabl
ed
,
true
);
assert
.
equal
(
getSelectionState
().
focusMode
.
configur
ed
,
true
);
assert
.
equal
(
getSelectionState
().
focusMode
.
focused
,
true
);
assert
.
equal
(
store
.
focusModeFocused
(),
true
);
});
it
(
'should return false by default when focus mode is not
enabl
ed'
,
function
()
{
assert
.
equal
(
getSelectionState
().
focusMode
.
enabl
ed
,
false
);
it
(
'should return false by default when focus mode is not
focus
ed'
,
function
()
{
assert
.
equal
(
getSelectionState
().
focusMode
.
configur
ed
,
false
);
assert
.
equal
(
getSelectionState
().
focusMode
.
focused
,
true
);
assert
.
equal
(
store
.
focusModeFocused
(),
false
);
});
});
describe
(
'focusModeHasUser()'
,
()
=>
{
it
(
'should return `true` if focus
enabl
ed and valid `user` object present'
,
()
=>
{
it
(
'should return `true` if focus
configur
ed and valid `user` object present'
,
()
=>
{
store
=
createStore
(
[
selection
],
[{
focus
:
{
user
:
{
userid
:
'acct:userid@authority'
}
}
}]
);
assert
.
isTrue
(
store
.
focusModeHasUser
());
});
it
(
'should return `false` if focus
enabl
ed but `user` object invalid'
,
()
=>
{
it
(
'should return `false` if focus
configur
ed but `user` object invalid'
,
()
=>
{
store
=
createStore
(
[
selection
],
[{
focus
:
{
user
:
{
displayName
:
'FakeDisplayName'
}
}
}]
// `userid` is required
...
...
@@ -319,7 +319,7 @@ describe('sidebar/store/modules/selection', () => {
});
describe
(
'focusModeUserPrettyName()'
,
function
()
{
it
(
'returns false by default when focus mode is not
enabl
ed'
,
function
()
{
it
(
'returns false by default when focus mode is not
configur
ed'
,
function
()
{
store
=
createStore
(
[
selection
],
[{
focus
:
{
user
:
{
displayName
:
'FakeDisplayName'
}
}
}]
...
...
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