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
286be9cc
Commit
286be9cc
authored
Aug 13, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Aug 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `forcedVisible` deal only in `$tag`s
Update `forcedVisible` to use only `$tag` values, not `id`s.
parent
be332973
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
27 deletions
+89
-27
threads-test.js
src/sidebar/services/test/threads-test.js
+52
-18
threads.js
src/sidebar/services/threads.js
+2
-2
build-thread.js
src/sidebar/util/build-thread.js
+10
-7
build-thread-test.js
src/sidebar/util/test/build-thread-test.js
+25
-0
No files found.
src/sidebar/services/test/threads-test.js
View file @
286be9cc
...
@@ -2,33 +2,61 @@ import threadsService from '../threads';
...
@@ -2,33 +2,61 @@ import threadsService from '../threads';
const
NESTED_THREADS
=
{
const
NESTED_THREADS
=
{
id
:
'top'
,
id
:
'top'
,
annotation
:
{
$tag
:
'top-tag'
},
children
:
[
children
:
[
{
{
id
:
'1'
,
id
:
'1'
,
annotation
:
{
$tag
:
'1-tag'
},
children
:
[
children
:
[
{
id
:
'1a'
,
children
:
[{
id
:
'1ai'
,
children
:
[]
}]
},
{
{
id
:
'1b'
,
children
:
[],
visible
:
true
},
id
:
'1a'
,
annotation
:
{
$tag
:
'1a-tag'
},
children
:
[
{
annotation
:
{
$tag
:
'1ai-tag'
},
id
:
'1ai'
,
children
:
[]
},
],
},
{
id
:
'1b'
,
annotation
:
{
$tag
:
'1b-tag'
},
children
:
[],
visible
:
true
,
},
{
{
id
:
'1c'
,
id
:
'1c'
,
children
:
[{
id
:
'1ci'
,
children
:
[],
visible
:
false
}],
annotation
:
{
$tag
:
'1c-tag'
},
children
:
[
{
id
:
'1ci'
,
annotation
:
{
$tag
:
'1ci-tag'
},
children
:
[],
visible
:
false
,
},
],
},
},
],
],
},
},
{
{
id
:
'2'
,
id
:
'2'
,
annotation
:
{
$tag
:
'2-tag'
},
children
:
[
children
:
[
{
id
:
'2a'
,
children
:
[]
},
{
id
:
'2a'
,
annotation
:
{
$tag
:
'2a-tag'
},
children
:
[]
},
{
{
id
:
'2b'
,
id
:
'2b'
,
children
:
[
children
:
[
{
id
:
'2bi'
,
children
:
[],
visible
:
true
},
{
{
id
:
'2bii'
,
children
:
[]
},
id
:
'2bi'
,
annotation
:
{
$tag
:
'2bi-tag'
},
children
:
[],
visible
:
true
,
},
{
id
:
'2bii'
,
annotation
:
{
$tag
:
'2bii-tag'
},
children
:
[]
},
],
],
},
},
],
],
},
},
{
{
id
:
'3'
,
id
:
'3'
,
annotation
:
{
$tag
:
'3-tag'
},
children
:
[],
children
:
[],
},
},
],
],
...
@@ -49,17 +77,17 @@ describe('threadsService', function () {
...
@@ -49,17 +77,17 @@ describe('threadsService', function () {
let
nonVisibleThreadIds
;
let
nonVisibleThreadIds
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
nonVisibleThreadIds
=
[
nonVisibleThreadIds
=
[
'top'
,
'top
-tag
'
,
'1'
,
'1
-tag
'
,
'2'
,
'2
-tag
'
,
'3'
,
'3
-tag
'
,
'1a'
,
'1a
-tag
'
,
'1c'
,
'1c
-tag
'
,
'2a'
,
'2a
-tag
'
,
'2b'
,
//'2b-tag', Not visible, but also does not have an annotation
'1ai'
,
'1ai
-tag
'
,
'1ci'
,
'1ci
-tag
'
,
'2bii'
,
'2bii
-tag
'
,
];
];
});
});
it
(
'should set the thread and its children force-visible in the store'
,
()
=>
{
it
(
'should set the thread and its children force-visible in the store'
,
()
=>
{
...
@@ -81,7 +109,13 @@ describe('threadsService', function () {
...
@@ -81,7 +109,13 @@ describe('threadsService', function () {
for
(
let
i
=
0
;
i
<
fakeStore
.
setForcedVisible
.
callCount
;
i
++
)
{
for
(
let
i
=
0
;
i
<
fakeStore
.
setForcedVisible
.
callCount
;
i
++
)
{
calledWithThreadIds
.
push
(
fakeStore
.
setForcedVisible
.
getCall
(
i
).
args
[
0
]);
calledWithThreadIds
.
push
(
fakeStore
.
setForcedVisible
.
getCall
(
i
).
args
[
0
]);
}
}
assert
.
deepEqual
(
calledWithThreadIds
,
[
'1ai'
,
'1a'
,
'1ci'
,
'1c'
,
'1'
]);
assert
.
deepEqual
(
calledWithThreadIds
,
[
'1ai-tag'
,
'1a-tag'
,
'1ci-tag'
,
'1c-tag'
,
'1-tag'
,
]);
});
});
});
});
});
});
src/sidebar/services/threads.js
View file @
286be9cc
...
@@ -16,8 +16,8 @@ export default function threadsService(store) {
...
@@ -16,8 +16,8 @@ export default function threadsService(store) {
thread
.
children
.
forEach
(
child
=>
{
thread
.
children
.
forEach
(
child
=>
{
forceVisible
(
child
);
forceVisible
(
child
);
});
});
if
(
!
thread
.
visible
)
{
if
(
!
thread
.
visible
&&
thread
.
annotation
)
{
store
.
setForcedVisible
(
thread
.
id
,
true
);
store
.
setForcedVisible
(
thread
.
annotation
.
$tag
,
true
);
}
}
}
}
...
...
src/sidebar/util/build-thread.js
View file @
286be9cc
...
@@ -259,7 +259,7 @@ function hasVisibleChildren(thread) {
...
@@ -259,7 +259,7 @@ function hasVisibleChildren(thread) {
* @typedef Options
* @typedef Options
* @prop {string[]} [selected] - List of currently-selected annotation ids, from
* @prop {string[]} [selected] - List of currently-selected annotation ids, from
* the data store
* the data store
* @prop {string[]} [forcedVisible] - List of
id
s of annotations that have
* @prop {string[]} [forcedVisible] - List of
$tag
s of annotations that have
* been explicitly expanded by the user, even if they don't
* been explicitly expanded by the user, even if they don't
* match current filters
* match current filters
* @prop {(a: Annotation) => boolean} [filterFn] - Predicate function that
* @prop {(a: Annotation) => boolean} [filterFn] - Predicate function that
...
@@ -326,11 +326,14 @@ export default function buildThread(annotations, options) {
...
@@ -326,11 +326,14 @@ export default function buildThread(annotations, options) {
if
(
hasSelection
)
{
if
(
hasSelection
)
{
// Remove threads (annotations) that are not selected or
// Remove threads (annotations) that are not selected or
// are not forced-visible
// are not forced-visible
thread
.
children
=
thread
.
children
.
filter
(
thread
.
children
=
thread
.
children
.
filter
(
child
=>
{
child
=>
const
isSelected
=
opts
.
selected
.
includes
(
child
.
id
);
opts
.
selected
.
indexOf
(
child
.
id
)
!==
-
1
||
const
isForcedVisible
=
opts
.
forcedVisible
.
indexOf
(
child
.
id
)
!==
-
1
hasForcedVisible
&&
);
child
.
annotation
&&
opts
.
forcedVisible
.
includes
(
child
.
annotation
.
$tag
);
return
isSelected
||
isForcedVisible
;
});
}
}
if
(
threadsFiltered
)
{
if
(
threadsFiltered
)
{
...
@@ -347,7 +350,7 @@ export default function buildThread(annotations, options) {
...
@@ -347,7 +350,7 @@ export default function buildThread(annotations, options) {
}
else
if
(
annotationsFiltered
)
{
}
else
if
(
annotationsFiltered
)
{
if
(
if
(
hasForcedVisible
&&
hasForcedVisible
&&
opts
.
forcedVisible
.
in
dexOf
(
annotationId
(
thread
.
annotation
))
!==
-
1
opts
.
forcedVisible
.
in
cludes
(
thread
.
annotation
.
$tag
)
)
{
)
{
// This annotation may or may not match the filter, but we should
// This annotation may or may not match the filter, but we should
// make sure it is visible because it has been forced visible by user
// make sure it is visible because it has been forced visible by user
...
...
src/sidebar/util/test/build-thread-test.js
View file @
286be9cc
...
@@ -6,15 +6,18 @@ const SIMPLE_FIXTURE = [
...
@@ -6,15 +6,18 @@ const SIMPLE_FIXTURE = [
{
{
id
:
'1'
,
id
:
'1'
,
text
:
'first annotation'
,
text
:
'first annotation'
,
$tag
:
'1'
,
references
:
[],
references
:
[],
},
},
{
{
id
:
'2'
,
id
:
'2'
,
$tag
:
'2'
,
text
:
'second annotation'
,
text
:
'second annotation'
,
references
:
[],
references
:
[],
},
},
{
{
id
:
'3'
,
id
:
'3'
,
$tag
:
'3'
,
text
:
'third annotation'
,
text
:
'third annotation'
,
references
:
[
1
],
references
:
[
1
],
},
},
...
@@ -366,6 +369,28 @@ describe('sidebar/util/build-thread', function () {
...
@@ -366,6 +369,28 @@ describe('sidebar/util/build-thread', function () {
},
},
]);
]);
});
});
it
(
'shows forced-visible annotations, also'
,
function
()
{
const
thread
=
createThread
(
SIMPLE_FIXTURE
,
{
selected
:
[
'1'
],
forcedVisible
:
[
'2'
],
});
assert
.
deepEqual
(
thread
,
[
{
annotation
:
SIMPLE_FIXTURE
[
0
],
children
:
[
{
annotation
:
SIMPLE_FIXTURE
[
2
],
children
:
[],
},
],
},
{
annotation
:
SIMPLE_FIXTURE
[
1
],
children
:
[],
},
]);
});
});
});
describe
(
'thread filtering'
,
function
()
{
describe
(
'thread filtering'
,
function
()
{
...
...
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