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
ce586351
Commit
ce586351
authored
Apr 06, 2017
by
Sean Hammond
Committed by
GitHub
Apr 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #343 from hypothesis/first-party-flagging
Enable first-party users to flag annotations
parents
7c3ba4ce
ced25535
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
3 deletions
+55
-3
annotation.js
src/sidebar/components/annotation.js
+7
-0
annotation-test.js
src/sidebar/components/test/annotation-test.js
+37
-2
annotation.html
src/sidebar/templates/annotation.html
+1
-1
annotation-fixtures.js
src/sidebar/test/annotation-fixtures.js
+10
-0
No files found.
src/sidebar/components/annotation.js
View file @
ce586351
...
@@ -482,6 +482,13 @@ function AnnotationController(
...
@@ -482,6 +482,13 @@ function AnnotationController(
return
vm
.
annotation
.
hidden
;
return
vm
.
annotation
.
hidden
;
};
};
vm
.
canFlag
=
function
()
{
if
(
persona
.
isThirdPartyUser
(
vm
.
annotation
.
user
,
settings
.
authDomain
))
{
return
true
;
}
return
features
.
flagEnabled
(
'flag_action'
);
};
vm
.
isFlagged
=
function
()
{
vm
.
isFlagged
=
function
()
{
return
vm
.
annotation
.
flagged
;
return
vm
.
annotation
.
flagged
;
};
};
...
...
src/sidebar/components/test/annotation-test.js
View file @
ce586351
...
@@ -83,6 +83,7 @@ describe('annotation', function() {
...
@@ -83,6 +83,7 @@ describe('annotation', function() {
var
fakeAnnotationMapper
;
var
fakeAnnotationMapper
;
var
fakeAnnotationUI
;
var
fakeAnnotationUI
;
var
fakeDrafts
;
var
fakeDrafts
;
var
fakeFeatures
;
var
fakeFlash
;
var
fakeFlash
;
var
fakeGroups
;
var
fakeGroups
;
var
fakePermissions
;
var
fakePermissions
;
...
@@ -154,7 +155,7 @@ describe('annotation', function() {
...
@@ -154,7 +155,7 @@ describe('annotation', function() {
get
:
sandbox
.
stub
(),
get
:
sandbox
.
stub
(),
};
};
var
fakeFeatures
=
{
fakeFeatures
=
{
flagEnabled
:
sandbox
.
stub
().
returns
(
true
),
flagEnabled
:
sandbox
.
stub
().
returns
(
true
),
};
};
...
@@ -194,7 +195,8 @@ describe('annotation', function() {
...
@@ -194,7 +195,8 @@ describe('annotation', function() {
};
};
fakeSettings
=
{
fakeSettings
=
{
authDomain
:
'example.com'
,
// "localhost" is the host used by 'first party' annotation fixtures
authDomain
:
'localhost'
,
};
};
fakeStore
=
{
fakeStore
=
{
...
@@ -763,6 +765,24 @@ describe('annotation', function() {
...
@@ -763,6 +765,24 @@ describe('annotation', function() {
});
});
});
});
describe
(
'#canFlag'
,
function
()
{
it
(
'returns true if the user is a third-party user'
,
function
()
{
var
ann
=
fixtures
.
thirdPartyAnnotation
();
var
controller
=
createDirective
(
ann
).
controller
;
assert
.
isTrue
(
controller
.
canFlag
());
});
it
(
'returns the value of the `flag_action` feature flag'
,
function
()
{
var
controller
=
createDirective
().
controller
;
fakeFeatures
.
flagEnabled
.
returns
(
false
);
assert
.
equal
(
controller
.
canFlag
(),
false
);
fakeFeatures
.
flagEnabled
.
returns
(
true
);
assert
.
equal
(
controller
.
canFlag
(),
true
);
});
});
describe
(
'saving a new annotation'
,
function
()
{
describe
(
'saving a new annotation'
,
function
()
{
var
annotation
;
var
annotation
;
...
@@ -1006,5 +1026,20 @@ describe('annotation', function() {
...
@@ -1006,5 +1026,20 @@ describe('annotation', function() {
},
},
});
});
});
});
it
(
'flags the annotation when the user clicks the "Flag" button'
,
function
()
{
fakeAnnotationMapper
.
flagAnnotation
.
returns
(
Promise
.
resolve
());
var
el
=
createDirective
().
element
;
var
flagBtn
=
el
[
0
].
querySelector
(
'button[aria-label="Flag"]'
);
flagBtn
.
click
();
assert
.
called
(
fakeAnnotationMapper
.
flagAnnotation
);
});
it
(
'highlights the "Flag" button if the annotation is flagged'
,
function
()
{
var
ann
=
Object
.
assign
(
fixtures
.
defaultAnnotation
(),
{
flagged
:
true
});
var
el
=
createDirective
(
ann
).
element
;
var
flaggedBtn
=
el
[
0
].
querySelector
(
'button[aria-label="Annotation has been flagged"]'
);
assert
.
ok
(
flaggedBtn
);
});
});
});
});
});
src/sidebar/templates/annotation.html
View file @
ce586351
...
@@ -188,7 +188,7 @@
...
@@ -188,7 +188,7 @@
on-close=
"vm.showShareDialog = false"
>
on-close=
"vm.showShareDialog = false"
>
</annotation-share-dialog>
</annotation-share-dialog>
</span>
</span>
<span
ng-if=
"vm.
isThirdPartyUser
()"
>
<span
ng-if=
"vm.
canFlag
()"
>
<button
class=
"btn btn-clean annotation-action-btn"
<button
class=
"btn btn-clean annotation-action-btn"
ng-if=
"!vm.isFlagged()"
ng-if=
"!vm.isFlagged()"
ng-click=
"vm.flag()"
ng-click=
"vm.flag()"
...
...
src/sidebar/test/annotation-fixtures.js
View file @
ce586351
...
@@ -16,6 +16,15 @@ function defaultAnnotation() {
...
@@ -16,6 +16,15 @@ function defaultAnnotation() {
};
};
}
}
/**
* Return a fake annotation created by a third-party user.
*/
function
thirdPartyAnnotation
()
{
return
Object
.
assign
(
defaultAnnotation
(),
{
user
:
'acct:ben@publisher.org'
,
});
}
/**
/**
* Return a fake public annotation with the basic properties filled in.
* Return a fake public annotation with the basic properties filled in.
*/
*/
...
@@ -171,4 +180,5 @@ module.exports = {
...
@@ -171,4 +180,5 @@ module.exports = {
oldHighlight
:
oldHighlight
,
oldHighlight
:
oldHighlight
,
oldPageNote
:
oldPageNote
,
oldPageNote
:
oldPageNote
,
oldReply
:
oldReply
,
oldReply
:
oldReply
,
thirdPartyAnnotation
:
thirdPartyAnnotation
,
};
};
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