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
6f571e9f
Commit
6f571e9f
authored
Jun 20, 2019
by
Hannah Stepanek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace clearSelection w/ store.clearSelection
Use clearSelection from the store instead of from sidebar-content.
parent
83851021
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
69 deletions
+21
-69
search-status-bar.js
src/sidebar/components/search-status-bar.js
+4
-1
sidebar-content.js
src/sidebar/components/sidebar-content.js
+0
-16
search-status-bar-test.js
src/sidebar/components/test/search-status-bar-test.js
+1
-0
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+0
-42
thread-list-test.js
src/sidebar/components/test/thread-list-test.js
+8
-4
thread-list.js
src/sidebar/components/thread-list.js
+8
-4
sidebar-content.html
src/sidebar/templates/sidebar-content.html
+0
-2
No files found.
src/sidebar/components/search-status-bar.js
View file @
6f571e9f
...
@@ -45,13 +45,16 @@ function SearchStatusBarController(store, rootThread) {
...
@@ -45,13 +45,16 @@ function SearchStatusBarController(store, rootThread) {
this
.
filterActive
=
function
()
{
this
.
filterActive
=
function
()
{
return
!!
store
.
getState
().
filterQuery
;
return
!!
store
.
getState
().
filterQuery
;
};
};
this
.
onClearSelection
=
function
()
{
store
.
clearSelection
();
};
}
}
module
.
exports
=
{
module
.
exports
=
{
controller
:
SearchStatusBarController
,
controller
:
SearchStatusBarController
,
controllerAs
:
'vm'
,
controllerAs
:
'vm'
,
bindings
:
{
bindings
:
{
onClearSelection
:
'&'
,
selectedTab
:
'<'
,
selectedTab
:
'<'
,
totalAnnotations
:
'<'
,
totalAnnotations
:
'<'
,
totalNotes
:
'<'
,
totalNotes
:
'<'
,
...
...
src/sidebar/components/sidebar-content.js
View file @
6f571e9f
...
@@ -4,7 +4,6 @@ const SearchClient = require('../search-client');
...
@@ -4,7 +4,6 @@ const SearchClient = require('../search-client');
const
events
=
require
(
'../events'
);
const
events
=
require
(
'../events'
);
const
isThirdPartyService
=
require
(
'../util/is-third-party-service'
);
const
isThirdPartyService
=
require
(
'../util/is-third-party-service'
);
const
tabs
=
require
(
'../tabs'
);
const
tabs
=
require
(
'../tabs'
);
const
uiConstants
=
require
(
'../ui-constants'
);
/**
/**
* Returns the group ID of the first annotation in `results` whose
* Returns the group ID of the first annotation in `results` whose
...
@@ -315,21 +314,6 @@ function SidebarContentController(
...
@@ -315,21 +314,6 @@ function SidebarContentController(
!
this
.
isLoading
()
&&
!!
selectedID
&&
store
.
annotationExists
(
selectedID
)
!
this
.
isLoading
()
&&
!!
selectedID
&&
store
.
annotationExists
(
selectedID
)
);
);
};
};
this
.
clearSelection
=
function
()
{
let
selectedTab
=
store
.
getState
().
selectedTab
;
if
(
!
store
.
getState
().
selectedTab
||
store
.
getState
().
selectedTab
===
uiConstants
.
TAB_ORPHANS
)
{
selectedTab
=
uiConstants
.
TAB_ANNOTATIONS
;
}
store
.
clearSelectedAnnotations
();
store
.
selectTab
(
selectedTab
);
store
.
clearDirectLinkedGroupFetchFailed
();
store
.
clearDirectLinkedIds
();
};
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
src/sidebar/components/test/search-status-bar-test.js
View file @
6f571e9f
...
@@ -24,6 +24,7 @@ describe('searchStatusBar', () => {
...
@@ -24,6 +24,7 @@ describe('searchStatusBar', () => {
clearSelectedAnnotations
:
sinon
.
stub
(),
clearSelectedAnnotations
:
sinon
.
stub
(),
clearDirectLinkedGroupFetchFailed
:
sinon
.
stub
(),
clearDirectLinkedGroupFetchFailed
:
sinon
.
stub
(),
clearDirectLinkedIds
:
sinon
.
stub
(),
clearDirectLinkedIds
:
sinon
.
stub
(),
clearSelection
:
sinon
.
stub
(),
};
};
angular
.
mock
.
module
(
'app'
,
{
angular
.
mock
.
module
(
'app'
,
{
store
:
fakeStore
,
store
:
fakeStore
,
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
6f571e9f
...
@@ -5,7 +5,6 @@ const EventEmitter = require('tiny-emitter');
...
@@ -5,7 +5,6 @@ const EventEmitter = require('tiny-emitter');
const
events
=
require
(
'../../events'
);
const
events
=
require
(
'../../events'
);
const
sidebarContent
=
require
(
'../sidebar-content'
);
const
sidebarContent
=
require
(
'../sidebar-content'
);
const
uiConstants
=
require
(
'../../ui-constants'
);
const
util
=
require
(
'../../directive/test/util'
);
const
util
=
require
(
'../../directive/test/util'
);
let
searchClients
;
let
searchClients
;
...
@@ -187,47 +186,6 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -187,47 +186,6 @@ describe('sidebar.components.sidebar-content', function() {
return
sandbox
.
restore
();
return
sandbox
.
restore
();
});
});
describe
(
'clearSelection'
,
()
=>
{
it
(
'sets selectedTab to Annotations tab if selectedTab is null'
,
()
=>
{
store
.
selectTab
(
uiConstants
.
TAB_ORPHANS
);
$scope
.
$digest
();
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'sets selectedTab to Annotations tab if selectedTab is set to orphans'
,
()
=>
{
store
.
selectTab
(
uiConstants
.
TAB_ORPHANS
);
$scope
.
$digest
();
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'clears selected annotations'
,
()
=>
{
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedAnnotationMap
,
null
);
assert
.
equal
(
store
.
getState
().
filterQuery
,
null
);
});
it
(
'clears the directLinkedGroupFetchFailed state'
,
()
=>
{
store
.
setDirectLinkedGroupFetchFailed
();
ctrl
.
clearSelection
();
assert
.
isFalse
(
store
.
getState
().
directLinkedGroupFetchFailed
);
});
it
(
'clears the direct linked IDs in the store'
,
()
=>
{
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
directLinkedAnnotationId
,
null
);
assert
.
equal
(
store
.
getState
().
directLinkedGroupId
,
null
);
});
});
describe
(
'showSelectedTabs'
,
()
=>
{
describe
(
'showSelectedTabs'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
setFrames
([{
uri
:
'http://www.example.com'
}]);
setFrames
([{
uri
:
'http://www.example.com'
}]);
...
...
src/sidebar/components/test/thread-list-test.js
View file @
6f571e9f
...
@@ -45,6 +45,7 @@ const threadFixtures = immutable({
...
@@ -45,6 +45,7 @@ const threadFixtures = immutable({
});
});
let
fakeVirtualThread
;
let
fakeVirtualThread
;
let
fakeStore
;
const
fakeSettings
=
{};
const
fakeSettings
=
{};
class
FakeVirtualThreadList
extends
EventEmitter
{
class
FakeVirtualThreadList
extends
EventEmitter
{
...
@@ -86,7 +87,6 @@ describe('threadList', function() {
...
@@ -86,7 +87,6 @@ describe('threadList', function() {
function
createThreadList
(
inputs
)
{
function
createThreadList
(
inputs
)
{
const
defaultInputs
=
{
const
defaultInputs
=
{
thread
:
threadFixtures
.
thread
,
thread
:
threadFixtures
.
thread
,
onClearSelection
:
sinon
.
stub
(),
onForceVisible
:
sinon
.
stub
(),
onForceVisible
:
sinon
.
stub
(),
onFocus
:
sinon
.
stub
(),
onFocus
:
sinon
.
stub
(),
onSelect
:
sinon
.
stub
(),
onSelect
:
sinon
.
stub
(),
...
@@ -126,6 +126,10 @@ describe('threadList', function() {
...
@@ -126,6 +126,10 @@ describe('threadList', function() {
}
}
before
(
function
()
{
before
(
function
()
{
fakeStore
=
{
clearSelection
:
sinon
.
stub
(),
};
angular
.
module
(
'app'
,
[]).
component
(
'threadList'
,
threadList
);
angular
.
module
(
'app'
,
[]).
component
(
'threadList'
,
threadList
);
});
});
...
@@ -133,6 +137,7 @@ describe('threadList', function() {
...
@@ -133,6 +137,7 @@ describe('threadList', function() {
angular
.
mock
.
module
(
'app'
,
{
angular
.
mock
.
module
(
'app'
,
{
VirtualThreadList
:
FakeVirtualThreadList
,
VirtualThreadList
:
FakeVirtualThreadList
,
settings
:
fakeSettings
,
settings
:
fakeSettings
,
store
:
fakeStore
,
});
});
threadListContainers
=
[];
threadListContainers
=
[];
});
});
...
@@ -201,13 +206,12 @@ describe('threadList', function() {
...
@@ -201,13 +206,12 @@ describe('threadList', function() {
});
});
it
(
'clears the selection'
,
function
()
{
it
(
'clears the selection'
,
function
()
{
const
inputs
=
{
onClearSelection
:
sinon
.
stub
()
};
const
element
=
createThreadList
();
const
element
=
createThreadList
(
inputs
);
element
.
scope
.
$broadcast
(
element
.
scope
.
$broadcast
(
events
.
BEFORE_ANNOTATION_CREATED
,
events
.
BEFORE_ANNOTATION_CREATED
,
annotFixtures
.
annotation
annotFixtures
.
annotation
);
);
assert
.
called
(
inputs
.
onC
learSelection
);
assert
.
called
(
fakeStore
.
c
learSelection
);
});
});
});
});
...
...
src/sidebar/components/thread-list.js
View file @
6f571e9f
...
@@ -49,7 +49,13 @@ const virtualThreadOptions = {
...
@@ -49,7 +49,13 @@ const virtualThreadOptions = {
};
};
// @ngInject
// @ngInject
function
ThreadListController
(
$element
,
$scope
,
settings
,
VirtualThreadList
)
{
function
ThreadListController
(
$element
,
$scope
,
settings
,
store
,
VirtualThreadList
)
{
// `visibleThreads` keeps track of the subset of all threads matching the
// `visibleThreads` keeps track of the subset of all threads matching the
// current filters which are in or near the viewport and the view then renders
// current filters which are in or near the viewport and the view then renders
// only those threads, using placeholders above and below the visible threads
// only those threads, using placeholders above and below the visible threads
...
@@ -162,7 +168,7 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) {
...
@@ -162,7 +168,7 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) {
if
(
annotation
.
$highlight
||
metadata
.
isReply
(
annotation
))
{
if
(
annotation
.
$highlight
||
metadata
.
isReply
(
annotation
))
{
return
;
return
;
}
}
s
elf
.
onC
learSelection
();
s
tore
.
c
learSelection
();
scrollIntoView
(
annotation
.
$tag
);
scrollIntoView
(
annotation
.
$tag
);
});
});
...
@@ -191,8 +197,6 @@ module.exports = {
...
@@ -191,8 +197,6 @@ module.exports = {
onSelect
:
'&'
,
onSelect
:
'&'
,
/** Called when a user toggles the expansion state of an annotation thread. */
/** Called when a user toggles the expansion state of an annotation thread. */
onChangeCollapsed
:
'&'
,
onChangeCollapsed
:
'&'
,
/** Called to clear the current selection. */
onClearSelection
:
'&'
,
},
},
template
:
require
(
'../templates/thread-list.html'
),
template
:
require
(
'../templates/thread-list.html'
),
};
};
src/sidebar/templates/sidebar-content.html
View file @
6f571e9f
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
<search-status-bar
<search-status-bar
ng-show=
"!vm.isLoading()"
ng-show=
"!vm.isLoading()"
on-clear-selection=
"vm.clearSelection()"
selected-tab=
"vm.selectedTab"
selected-tab=
"vm.selectedTab"
total-annotations=
"vm.totalAnnotations"
total-annotations=
"vm.totalAnnotations"
total-notes=
"vm.totalNotes"
>
total-notes=
"vm.totalNotes"
>
...
@@ -40,7 +39,6 @@
...
@@ -40,7 +39,6 @@
<thread-list
<thread-list
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-clear-selection=
"vm.clearSelection()"
on-focus=
"vm.focus(annotation)"
on-focus=
"vm.focus(annotation)"
on-select=
"vm.scrollTo(annotation)"
on-select=
"vm.scrollTo(annotation)"
show-document-info=
"false"
show-document-info=
"false"
...
...
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