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
9f41b616
Commit
9f41b616
authored
Jul 30, 2019
by
Lyza Danger Gardner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add edited timestamp to header component
parent
327c061a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
12 deletions
+73
-12
annotation-header.js
src/sidebar/components/annotation-header.js
+22
-6
annotation-header-test.js
src/sidebar/components/test/annotation-header-test.js
+32
-5
annotation-fixtures.js
src/sidebar/test/annotation-fixtures.js
+1
-0
annotation-header.scss
src/styles/sidebar/components/annotation-header.scss
+18
-1
No files found.
src/sidebar/components/annotation-header.js
View file @
9f41b616
...
...
@@ -24,6 +24,9 @@ function AnnotationHeader({
})
{
const
annotationLink
=
annotation
.
links
?
annotation
.
links
.
html
:
''
;
const
replyPluralized
=
!
replyCount
||
replyCount
>
1
?
'replies'
:
'reply'
;
// NB: `created` and `updated` are strings, not `Date`s
const
hasBeenEdited
=
annotation
.
updated
&&
annotation
.
created
!==
annotation
.
updated
;
return
(
<
header
className
=
"annotation-header"
>
...
...
@@ -34,13 +37,26 @@ function AnnotationHeader({
{
replyCount
}
{
replyPluralized
}
<
/a
>
<
/div
>
{
!
isEditing
&&
annotation
.
upd
ated
&&
(
{
!
isEditing
&&
annotation
.
cre
ated
&&
(
<
div
className
=
"annotation-header__timestamp"
>
{
hasBeenEdited
&&
(
<
span
className
=
"annotation-header__timestamp-edited"
>
(
edited
{
' '
}
<
Timestamp
className
=
"annotation-header__timestamp
-link"
className
=
"annotation-header__timestamp-edited
-link"
href
=
{
annotationLink
}
timestamp
=
{
annotation
.
updated
}
/
>
){
' '
}
<
/span
>
)}
<
span
className
=
"annotation-header__timestamp-created"
>
<
Timestamp
className
=
"annotation-header__timestamp-created-link"
href
=
{
annotationLink
}
timestamp
=
{
annotation
.
created
}
/
>
<
/span
>
<
/div
>
)}
<
/div
>
...
...
src/sidebar/components/test/annotation-header-test.js
View file @
9f41b616
...
...
@@ -62,19 +62,46 @@ describe('AnnotationHeader', () => {
);
});
describe
(
'timestamp'
,
()
=>
{
it
(
'should render
a timestamp if annotation has an `upd
ated` value'
,
()
=>
{
describe
(
'timestamp
s
'
,
()
=>
{
it
(
'should render
timestamp container element if annotation has a `cre
ated` value'
,
()
=>
{
const
wrapper
=
createAnnotationHeader
();
const
timestamp
=
wrapper
.
find
(
Timestamp
);
const
timestamp
=
wrapper
.
find
(
'.annotation-header__timestamp'
);
assert
.
isTrue
(
timestamp
.
exists
());
});
it
(
'should not render
a timestamp if annotation does not have an `upd
ated` value'
,
()
=>
{
it
(
'should not render
timestamp container if annotation does not have a `cre
ated` value'
,
()
=>
{
const
wrapper
=
createAnnotationHeader
({
annotation
:
fixtures
.
newAnnotation
(),
});
const
timestamp
=
wrapper
.
find
(
Timestamp
);
const
timestamp
=
wrapper
.
find
(
'.annotation-header__timestamp'
);
assert
.
isFalse
(
timestamp
.
exists
());
});
it
(
'should render edited timestamp if annotation has been edited'
,
()
=>
{
const
annotation
=
fixtures
.
defaultAnnotation
();
annotation
.
updated
=
'2018-05-10T20:18:56.613388+00:00'
;
const
wrapper
=
createAnnotationHeader
({
annotation
:
annotation
,
});
const
timestamp
=
wrapper
.
find
(
Timestamp
)
.
filter
(
'.annotation-header__timestamp-edited-link'
);
assert
.
isTrue
(
timestamp
.
exists
());
});
it
(
'should not render edited timestamp if annotation has not been edited'
,
()
=>
{
// Default annotation's created value is same as updated; as if the annotation
// has not been edited before
const
wrapper
=
createAnnotationHeader
({
annotation
:
fixtures
.
newAnnotation
(),
});
const
timestamp
=
wrapper
.
find
(
Timestamp
)
.
filter
(
'.annotation-header__timestamp-edited-link'
);
assert
.
isFalse
(
timestamp
.
exists
());
});
...
...
src/sidebar/test/annotation-fixtures.js
View file @
9f41b616
...
...
@@ -6,6 +6,7 @@
function
defaultAnnotation
()
{
return
{
id
:
'deadbeef'
,
created
:
'2015-05-10T20:18:56.613388+00:00'
,
document
:
{
title
:
'A special document'
,
},
...
...
src/styles/sidebar/components/annotation-header.scss
View file @
9f41b616
...
...
@@ -10,12 +10,29 @@
align-items
:
baseline
;
}
// Timestamps are right aligned in a flex row
&
__timestamp
{
margin-left
:
auto
;
}
&
__timestamp-
link
{
&
__timestamp-
edited
{
@include
font-small
;
font-style
:
italic
;
color
:
$grey-4
;
}
&
__timestamp-created-link
,
&
__timestamp-edited-link
{
&
:hover
{
text-decoration
:
underline
;
}
}
&
__timestamp-created-link
{
color
:
$grey-5
;
}
&
__timestamp-edited-link
{
color
:
$grey-4
;
}
...
...
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