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
8e1700fa
Commit
8e1700fa
authored
Jul 30, 2019
by
Kyle Keating
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add focused user mode for speed grader
parent
59dbd146
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
7 deletions
+65
-7
focused-mode-header.js
src/sidebar/components/focused-mode-header.js
+24
-0
sidebar-content.js
src/sidebar/components/sidebar-content.js
+8
-1
host-config.js
src/sidebar/host-config.js
+6
-0
index.js
src/sidebar/index.js
+4
-0
root-thread.js
src/sidebar/services/root-thread.js
+8
-4
search-filter.js
src/sidebar/services/search-filter.js
+2
-2
selection.js
src/sidebar/store/modules/selection.js
+2
-0
sidebar-content.html
src/sidebar/templates/sidebar-content.html
+4
-0
focused-mode-header.scss
src/styles/sidebar/components/focused-mode-header.scss
+6
-0
sidebar.scss
src/styles/sidebar/sidebar.scss
+1
-0
No files found.
src/sidebar/components/focused-mode-header.js
0 → 100644
View file @
8e1700fa
'use strict'
;
const
{
createElement
}
=
require
(
'preact'
);
const
propTypes
=
require
(
'prop-types'
);
const
{
withServices
}
=
require
(
'../util/service-context'
);
function
FocusedModeHeader
({
settings
})
{
return
(
<
div
className
=
"focused-mode-header"
>
Showing
annotations
by
{
' '
}
<
span
className
=
"focused-mode-header__user"
>
{
settings
.
focusedUser
}
<
/span
>
<
/div
>
);
}
FocusedModeHeader
.
propTypes
=
{
// Injected services.
settings
:
propTypes
.
object
.
isRequired
,
};
FocusedModeHeader
.
injectedProps
=
[
'settings'
];
module
.
exports
=
withServices
(
FocusedModeHeader
);
src/sidebar/components/sidebar-content.js
View file @
8e1700fa
...
...
@@ -125,6 +125,10 @@ function SidebarContentController(
true
);
this
.
showFocusedHeader
=
()
=>
{
return
store
.
getState
().
focusedMode
;
};
this
.
showSelectedTabs
=
function
()
{
if
(
this
.
selectedAnnotationUnavailable
()
||
...
...
@@ -132,8 +136,11 @@ function SidebarContentController(
store
.
getState
().
filterQuery
)
{
return
false
;
}
}
else
if
(
store
.
getState
().
focusedMode
)
{
return
false
;
}
else
{
return
true
;
}
};
this
.
setCollapsed
=
function
(
id
,
collapsed
)
{
...
...
src/sidebar/host-config.js
View file @
8e1700fa
...
...
@@ -10,6 +10,9 @@ function hostPageConfig(window) {
const
configJSON
=
queryString
.
parse
(
window
.
location
.
search
).
config
;
const
config
=
JSON
.
parse
(
configJSON
||
'{}'
);
// temp: hack to force user
config
.
focusedUser
=
'kyle'
;
// Known configuration parameters which we will import from the host page.
// Note that since the host page is untrusted code, the filtering needs to
// be done here.
...
...
@@ -38,6 +41,9 @@ function hostPageConfig(window) {
// This should be removed once new note button is enabled for everybody.
'enableExperimentalNewNoteButton'
,
// Forces the sidebar to filter annotations to a single user.
'focusedUser'
,
// Fetch config from a parent frame.
'requestConfigFromFrame'
,
...
...
src/sidebar/index.js
View file @
8e1700fa
...
...
@@ -180,6 +180,10 @@ function startAngularApp(config) {
'searchStatusBar'
,
wrapReactComponent
(
require
(
'./components/search-status-bar'
))
)
.
component
(
'focusedModeHeader'
,
wrapReactComponent
(
require
(
'./components/focused-mode-header'
))
)
.
component
(
'selectionTabs'
,
wrapReactComponent
(
require
(
'./components/selection-tabs'
))
...
...
src/sidebar/services/root-thread.js
View file @
8e1700fa
...
...
@@ -39,7 +39,7 @@ const sortFns = {
* The root thread is then displayed by viewer.html
*/
// @ngInject
function
RootThread
(
$rootScope
,
store
,
searchFilter
,
viewFilter
)
{
function
RootThread
(
$rootScope
,
s
ettings
,
s
tore
,
searchFilter
,
viewFilter
)
{
/**
* Build the root conversation thread from the given UI state.
*
...
...
@@ -50,15 +50,19 @@ function RootThread($rootScope, store, searchFilter, viewFilter) {
const
sortFn
=
sortFns
[
state
.
sortKey
];
let
filterFn
;
if
(
state
.
filterQuery
)
{
const
filters
=
searchFilter
.
generateFacetedFilter
(
state
.
filterQuery
);
if
(
state
.
filterQuery
||
state
.
focusedMode
)
{
const
filters
=
searchFilter
.
generateFacetedFilter
(
state
.
filterQuery
,
settings
.
focusedUser
);
filterFn
=
function
(
annot
)
{
return
viewFilter
.
filter
([
annot
],
filters
).
length
>
0
;
};
}
let
threadFilterFn
;
if
(
state
.
isSidebar
&&
!
state
.
filterQuery
)
{
const
hasFilters
=
state
.
filterQuery
||
state
.
focusedMode
;
if
(
state
.
isSidebar
&&
!
hasFilters
)
{
threadFilterFn
=
function
(
thread
)
{
if
(
!
thread
.
annotation
)
{
return
false
;
...
...
src/sidebar/services/search-filter.js
View file @
8e1700fa
...
...
@@ -129,7 +129,7 @@ function toObject(searchtext) {
* @param {string} searchtext
* @return {Object}
*/
function
generateFacetedFilter
(
searchtext
)
{
function
generateFacetedFilter
(
searchtext
,
focusedUser
)
{
let
terms
;
const
any
=
[];
const
quote
=
[];
...
...
@@ -138,7 +138,7 @@ function generateFacetedFilter(searchtext) {
const
tag
=
[];
const
text
=
[];
const
uri
=
[];
const
user
=
[];
const
user
=
focusedUser
?
[
focusedUser
]
:
[];
if
(
searchtext
)
{
terms
=
tokenize
(
searchtext
);
...
...
src/sidebar/store/modules/selection.js
View file @
8e1700fa
...
...
@@ -113,6 +113,8 @@ function init(settings) {
selectedTab
:
TAB_DEFAULT
,
focusedMode
:
!!
settings
.
focusedUser
,
// Key by which annotations are currently sorted.
sortKey
:
TAB_SORTKEY_DEFAULT
[
TAB_DEFAULT
],
// Keys by which annotations can be sorted.
...
...
src/sidebar/templates/sidebar-content.html
View file @
8e1700fa
<focused-mode-header
ng-if=
"vm.showFocusedHeader()"
>
</focused-mode-header>
<selection-tabs
ng-if=
"vm.showSelectedTabs()"
is-loading=
"vm.isLoading()"
>
...
...
src/styles/sidebar/components/focused-mode-header.scss
0 → 100644
View file @
8e1700fa
.focused-mode-header
{
padding
:
5px
;
.focused-mode-header__user
{
font-weight
:
800
;
}
}
src/styles/sidebar/sidebar.scss
View file @
8e1700fa
...
...
@@ -27,6 +27,7 @@ $base-line-height: 20px;
@import
'./components/annotation-thread'
;
@import
'./components/annotation-user'
;
@import
'./components/excerpt'
;
@import
'./components/focused-mode-header'
;
@import
'./components/group-list'
;
@import
'./components/group-list-item'
;
@import
'./components/help-panel'
;
...
...
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