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
09e54144
Unverified
Commit
09e54144
authored
Nov 15, 2017
by
Sean Hammond
Committed by
GitHub
Nov 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #578 from hypothesis/remove-orphans-tab-flag
Remove orphans tab feature flag checks
parents
286dfbc5
093ef18a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
114 deletions
+21
-114
annotation.js
src/sidebar/components/annotation.js
+0
-7
selection-tabs.js
src/sidebar/components/selection-tabs.js
+0
-4
sidebar-content.js
src/sidebar/components/sidebar-content.js
+2
-4
root-thread.js
src/sidebar/root-thread.js
+1
-3
tabs.js
src/sidebar/tabs.js
+7
-31
selection-tabs.html
src/sidebar/templates/selection-tabs.html
+1
-1
root-thread-test.js
src/sidebar/test/root-thread-test.js
+1
-1
tabs-test.js
src/sidebar/test/tabs-test.js
+9
-63
No files found.
src/sidebar/components/annotation.js
View file @
09e54144
...
...
@@ -447,14 +447,7 @@ function AnnotationController(
return
serviceUrl
(
'search.tag'
,
{
tag
:
tag
});
};
// Note: We fetch the feature flag outside the `isOrphan` method to avoid a
// lookup on every $digest cycle
var
indicateOrphans
=
features
.
flagEnabled
(
'orphans_tab'
);
this
.
isOrphan
=
function
()
{
if
(
!
indicateOrphans
)
{
return
false
;
}
if
(
typeof
self
.
annotation
.
$orphan
===
'undefined'
)
{
return
self
.
annotation
.
$anchorTimeout
;
}
...
...
src/sidebar/components/selection-tabs.js
View file @
09e54144
...
...
@@ -19,10 +19,6 @@ module.exports = {
annotationUI
.
selectTab
(
type
);
};
this
.
orphansTabFlagEnabled
=
function
()
{
return
features
.
flagEnabled
(
'orphans_tab'
);
};
this
.
showAnnotationsUnavailableMessage
=
function
()
{
return
this
.
selectedTab
===
this
.
TAB_ANNOTATIONS
&&
this
.
totalAnnotations
===
0
&&
...
...
src/sidebar/components/sidebar-content.js
View file @
09e54144
...
...
@@ -48,8 +48,7 @@ function SidebarContentController(
self
.
rootThread
=
thread
();
self
.
selectedTab
=
state
.
selectedTab
;
var
separateOrphans
=
tabs
.
shouldSeparateOrphans
(
state
);
var
counts
=
tabs
.
counts
(
state
.
annotations
,
separateOrphans
);
var
counts
=
tabs
.
counts
(
state
.
annotations
);
Object
.
assign
(
self
,
{
totalNotes
:
counts
.
notes
,
...
...
@@ -227,8 +226,7 @@ function SidebarContentController(
focusAnnotation
(
selectedAnnot
);
scrollToAnnotation
(
selectedAnnot
);
var
separateOrphans
=
tabs
.
shouldSeparateOrphans
(
annotationUI
.
getState
());
annotationUI
.
selectTab
(
tabs
.
tabForAnnotation
(
selectedAnnot
,
separateOrphans
));
annotationUI
.
selectTab
(
tabs
.
tabForAnnotation
(
selectedAnnot
));
});
// Re-fetch annotations when focused group, logged-in user or connected frames
...
...
src/sidebar/root-thread.js
View file @
09e54144
...
...
@@ -66,9 +66,7 @@ function RootThread($rootScope, annotationUI, drafts, searchFilter, viewFilter)
return
false
;
}
var
separateOrphans
=
tabs
.
shouldSeparateOrphans
(
state
);
return
tabs
.
shouldShowInTab
(
thread
.
annotation
,
state
.
selectedTab
,
separateOrphans
);
return
tabs
.
shouldShowInTab
(
thread
.
annotation
,
state
.
selectedTab
);
};
}
...
...
src/sidebar/tabs.js
View file @
09e54144
...
...
@@ -5,27 +5,15 @@
var
countIf
=
require
(
'./util/array-util'
).
countIf
;
var
metadata
=
require
(
'./annotation-metadata'
);
var
session
=
require
(
'./reducers/session'
);
var
uiConstants
=
require
(
'./ui-constants'
);
/**
* Return true if Annotations and Orphans should be displayed in separate tabs.
*
* @param {object} state - The current application state.
*/
function
shouldSeparateOrphans
(
state
)
{
return
session
.
isFeatureEnabled
(
state
,
'orphans_tab'
);
}
/**
* Return the tab in which an annotation should be displayed.
*
* @param {Annotation} ann
* @param {boolean} separateOrphans - True if orphans should be displayed in a
* separate tab.
*/
function
tabForAnnotation
(
ann
,
separateOrphans
)
{
if
(
metadata
.
isOrphan
(
ann
)
&&
separateOrphans
)
{
function
tabForAnnotation
(
ann
)
{
if
(
metadata
.
isOrphan
(
ann
))
{
return
uiConstants
.
TAB_ORPHANS
;
}
else
if
(
metadata
.
isPageNote
(
ann
))
{
return
uiConstants
.
TAB_NOTES
;
...
...
@@ -39,26 +27,22 @@ function tabForAnnotation(ann, separateOrphans) {
*
* @param {Annotation} ann
* @param {number} tab - The TAB_* value indicating the tab
* @param {boolean} separateOrphans - True if orphans should be separated into
* their own tab.
*/
function
shouldShowInTab
(
ann
,
tab
,
separateOrphans
)
{
if
(
metadata
.
isWaitingToAnchor
(
ann
)
&&
separateOrphans
)
{
function
shouldShowInTab
(
ann
,
tab
)
{
if
(
metadata
.
isWaitingToAnchor
(
ann
))
{
// Until this annotation anchors or fails to anchor, we do not know which
// tab it should be displayed in.
return
false
;
}
return
tabForAnnotation
(
ann
,
separateOrphans
)
===
tab
;
return
tabForAnnotation
(
ann
)
===
tab
;
}
/**
* Return the counts for the headings of different tabs.
*
* @param {Annotation[]} annotations - List of annotations to display
* @param {boolean} separateOrphans - True if orphans should be displayed in a
* separate tab.
*/
function
counts
(
annotations
,
separateOrphans
)
{
function
counts
(
annotations
)
{
var
counts
=
{
notes
:
countIf
(
annotations
,
metadata
.
isPageNote
),
annotations
:
countIf
(
annotations
,
metadata
.
isAnnotation
),
...
...
@@ -66,19 +50,11 @@ function counts(annotations, separateOrphans) {
anchoring
:
countIf
(
annotations
,
metadata
.
isWaitingToAnchor
),
};
if
(
separateOrphans
)
{
return
counts
;
}
else
{
return
Object
.
assign
({},
counts
,
{
annotations
:
counts
.
annotations
+
counts
.
orphans
,
orphans
:
0
,
});
}
return
counts
;
}
module
.
exports
=
{
counts
:
counts
,
shouldSeparateOrphans
:
shouldSeparateOrphans
,
shouldShowInTab
:
shouldShowInTab
,
tabForAnnotation
:
tabForAnnotation
,
};
src/sidebar/templates/selection-tabs.html
View file @
09e54144
...
...
@@ -22,7 +22,7 @@
</span>
</a>
<a
class=
"selection-tabs__type selection-tabs__type--orphan"
ng-if=
"vm.
orphansTabFlagEnabled() && vm.
totalOrphans > 0"
ng-if=
"vm.totalOrphans > 0"
href=
"#"
ng-class=
"{'is-selected': vm.selectedTab === vm.TAB_ORPHANS}"
h-on-touch=
"vm.selectTab(vm.TAB_ORPHANS)"
>
...
...
src/sidebar/test/root-thread-test.js
View file @
09e54144
...
...
@@ -46,7 +46,7 @@ describe('rootThread', function () {
isSidebar
:
true
,
selectedAnnotationMap
:
null
,
session
:
{
features
:
{
'orphans_tab'
:
true
},
features
:
{},
},
sortKey
:
'Location'
,
sortKeysAvailable
:
[
'Location'
],
...
...
src/sidebar/test/tabs-test.js
View file @
09e54144
...
...
@@ -6,31 +6,11 @@ var tabs = require('../tabs');
var
unroll
=
require
(
'../../shared/test/util'
).
unroll
;
describe
(
'tabs'
,
function
()
{
describe
(
'shouldSeparateOrphans'
,
function
()
{
it
(
'returns true if the "orphans_tab" flag is enabled'
,
function
()
{
var
state
=
{
session
:
{
features
:
{
'orphans_tab'
:
true
},
},
};
assert
.
isTrue
(
tabs
.
shouldSeparateOrphans
(
state
));
});
it
(
'returns false if the "orphans_tab" flag is not enabled'
,
function
()
{
var
state
=
{
session
:
{
features
:
{
'orphans_tab'
:
false
},
},
};
assert
.
isFalse
(
tabs
.
shouldSeparateOrphans
(
state
));
});
});
describe
(
'tabForAnnotation'
,
function
()
{
unroll
(
'shows annotation in correct tab'
,
function
(
testCase
)
{
var
ann
=
testCase
.
ann
;
var
expectedTab
=
testCase
.
expectedTab
;
assert
.
equal
(
tabs
.
tabForAnnotation
(
ann
,
true
/* separateOrphans */
),
expectedTab
);
assert
.
equal
(
tabs
.
tabForAnnotation
(
ann
),
expectedTab
);
},
[{
ann
:
fixtures
.
defaultAnnotation
(),
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
...
...
@@ -49,58 +29,33 @@ describe('tabs', function () {
ann
.
$anchorTimeout
=
testCase
.
anchorTimeout
;
ann
.
$orphan
=
testCase
.
orphan
;
assert
.
equal
(
tabs
.
shouldShowInTab
(
ann
,
uiConstants
.
TAB_ANNOTATIONS
,
testCase
.
separateOrphans
),
testCase
.
expectedTab
===
uiConstants
.
TAB_ANNOTATIONS
);
assert
.
equal
(
tabs
.
shouldShowInTab
(
ann
,
uiConstants
.
TAB_ORPHANS
,
testCase
.
separateOrphans
),
testCase
.
expectedTab
===
uiConstants
.
TAB_ORPHANS
);
assert
.
equal
(
tabs
.
shouldShowInTab
(
ann
,
uiConstants
.
TAB_ANNOTATIONS
),
testCase
.
expectedTab
===
uiConstants
.
TAB_ANNOTATIONS
);
assert
.
equal
(
tabs
.
shouldShowInTab
(
ann
,
uiConstants
.
TAB_ORPHANS
),
testCase
.
expectedTab
===
uiConstants
.
TAB_ORPHANS
);
},
[{
// Orphans tab disabled, anchoring in progress.
anchorTimeout
:
false
,
orphan
:
undefined
,
separateOrphans
:
false
,
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},{
// Orphans tab disabled, anchoring succeeded.
anchorTimeout
:
false
,
orphan
:
false
,
separateOrphans
:
false
,
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},{
// Orphans tab disabled, anchoring failed
anchorTimeout
:
false
,
orphan
:
true
,
separateOrphans
:
false
,
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},{
// Orphans tab enabled, anchoring in progress.
// Anchoring in progress.
anchorTimeout
:
false
,
orphan
:
undefined
,
separateOrphans
:
true
,
expectedTab
:
null
,
},{
//
Orphans tab enabled, a
nchoring succeeded.
//
A
nchoring succeeded.
anchorTimeout
:
false
,
orphan
:
false
,
separateOrphans
:
true
,
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},{
//
Orphans tab enabled, a
nchoring failed.
//
A
nchoring failed.
anchorTimeout
:
false
,
orphan
:
true
,
separateOrphans
:
true
,
expectedTab
:
uiConstants
.
TAB_ORPHANS
,
},{
//
Orphans tab enabled, a
nchoring timed out.
//
A
nchoring timed out.
anchorTimeout
:
true
,
orphan
:
undefined
,
separateOrphans
:
true
,
expectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},{
//
Orphans tab enabled, a
nchoring initially timed out but eventually
//
A
nchoring initially timed out but eventually
// failed.
anchorTimeout
:
true
,
orphan
:
true
,
separateOrphans
:
true
,
expectedTab
:
uiConstants
.
TAB_ORPHANS
,
}]);
});
...
...
@@ -109,16 +64,7 @@ describe('tabs', function () {
var
annotation
=
Object
.
assign
(
fixtures
.
defaultAnnotation
(),
{
$orphan
:
false
});
var
orphan
=
Object
.
assign
(
fixtures
.
defaultAnnotation
(),
{
$orphan
:
true
});
it
(
'counts Annotations and Orphans together when the Orphans tab is not enabled'
,
function
()
{
assert
.
deepEqual
(
tabs
.
counts
([
annotation
,
orphan
],
false
),
{
anchoring
:
0
,
annotations
:
2
,
notes
:
0
,
orphans
:
0
,
});
});
it
(
'counts Annotations and Orphans separately when the Orphans tab is enabled'
,
function
()
{
it
(
'counts Annotations and Orphans separately'
,
function
()
{
assert
.
deepEqual
(
tabs
.
counts
([
annotation
,
orphan
],
true
),
{
anchoring
:
0
,
annotations
:
1
,
...
...
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