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
6dad6f3a
Commit
6dad6f3a
authored
Nov 11, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Nov 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert AnnotationTimestamps to TS
parent
92da12dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
+16
-17
AnnotationHeader.tsx
src/sidebar/components/Annotation/AnnotationHeader.tsx
+3
-3
AnnotationTimestamps.tsx
src/sidebar/components/Annotation/AnnotationTimestamps.tsx
+11
-12
AnnotationTimestamps-test.js
...r/components/Annotation/test/AnnotationTimestamps-test.js
+2
-2
No files found.
src/sidebar/components/Annotation/AnnotationHeader.tsx
View file @
6dad6f3a
...
...
@@ -73,7 +73,7 @@ function AnnotationHeader({
// Link (URL) to single-annotation view for this annotation, if it has
// been provided by the service. Note: this property is not currently
// present on third-party annotations.
const
annotationU
rl
=
annotation
.
links
?.
html
||
''
;
const
annotationU
RL
=
annotation
.
links
?.
html
||
''
;
const
showEditedTimestamp
=
useMemo
(()
=>
{
return
hasBeenEdited
(
annotation
)
&&
!
isCollapsedReply
;
...
...
@@ -92,7 +92,7 @@ function AnnotationHeader({
// is a third-party annotation.
// Also, of course, verify that there is a URL to the document (titleLink)
const
documentLink
=
annotationU
rl
&&
documentInfo
.
titleLink
?
documentInfo
.
titleLink
:
''
;
annotationU
RL
&&
documentInfo
.
titleLink
?
documentInfo
.
titleLink
:
''
;
// Show document information on non-sidebar routes, assuming there is a title
// to show, at the least
const
showDocumentInfo
=
...
...
@@ -131,7 +131,7 @@ function AnnotationHeader({
<
AnnotationTimestamps
annotationCreated=
{
annotation
.
created
}
annotationUpdated=
{
annotation
.
updated
}
annotationU
rl=
{
annotationUrl
}
annotationU
RL=
{
annotationURL
}
withEditedTimestamp=
{
showEditedTimestamp
}
/>
</
div
>
...
...
src/sidebar/components/Annotation/AnnotationTimestamps.
js
→
src/sidebar/components/Annotation/AnnotationTimestamps.
tsx
View file @
6dad6f3a
...
...
@@ -7,14 +7,13 @@ import {
formatDate
,
}
from
'../../util/time'
;
/**
* @typedef AnnotationTimestampsProps
* @prop {string} annotationCreated
* @prop {string} annotationUpdated
* @prop {string} [annotationUrl]
* @prop {boolean} [withEditedTimestamp] - Should a timestamp for when this
* annotation was last edited be rendered?
*/
export
type
AnnotationTimestampProps
=
{
annotationCreated
:
string
;
annotationUpdated
:
string
;
annotationURL
?:
string
;
/** Display a relative last-updated timestamp */
withEditedTimestamp
?:
boolean
;
};
/**
* Render textual timestamp information for an annotation. This includes
...
...
@@ -29,9 +28,9 @@ import {
export
default
function
AnnotationTimestamps
({
annotationCreated
,
annotationUpdated
,
annotationU
rl
,
annotationU
RL
,
withEditedTimestamp
,
})
{
}
:
AnnotationTimestampProps
)
{
// "Current" time, used when calculating the relative age of `timestamp`.
const
[
now
,
setNow
]
=
useState
(()
=>
new
Date
());
const
createdDate
=
useMemo
(
...
...
@@ -88,14 +87,14 @@ export default function AnnotationTimestamps({
(
{
editedString
}
)
{
' '
}
</
span
>
)
}
{
annotationU
rl
?
(
{
annotationU
RL
?
(
<
LinkBase
// The light-text hover color is not a standard color for a Link, so
// LinkBase is used here
classes=
"text-color-text-light hover:text-color-text-light hover:underline"
target=
"_blank"
title=
{
created
.
absolute
}
href
=
{
annotationU
rl
}
href=
{
annotationU
RL
}
>
{
created
.
relative
}
</
LinkBase
>
...
...
src/sidebar/components/Annotation/test/AnnotationTimestamps-test.js
View file @
6dad6f3a
...
...
@@ -14,7 +14,7 @@ describe('AnnotationTimestamps', () => {
<
AnnotationTimestamps
annotationCreated
=
"2015-05-10T20:18:56.613388+00:00"
annotationUpdated
=
"2015-05-10T20:18:56.613388+00:00"
annotationU
rl
=
"http://www.example.com"
annotationU
RL
=
"http://www.example.com"
withEditedTimestamp
=
{
false
}
{...
props
}
/
>
...
...
@@ -49,7 +49,7 @@ describe('AnnotationTimestamps', () => {
});
it
(
'renders an unlinked created timestamp if annotation does not have a link'
,
()
=>
{
const
wrapper
=
createComponent
({
annotationU
rl
:
''
});
const
wrapper
=
createComponent
({
annotationU
RL
:
''
});
const
link
=
wrapper
.
find
(
'Link'
);
const
span
=
wrapper
.
find
(
'span[data-testid="timestamp-created"]'
);
...
...
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