Skip to content

Commit 8aee24f

Browse files
committed
Add share annotation control in moderation queue
1 parent c615572 commit 8aee24f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

h/static/scripts/group-forms/components/AnnotationCard.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
AnnotationGroupInfo,
3+
AnnotationShareControl,
34
AnnotationTimestamps,
45
AnnotationUser,
56
MarkdownView,
@@ -12,7 +13,7 @@ import {
1213
Link,
1314
} from '@hypothesis/frontend-shared';
1415
import classnames from 'classnames';
15-
import { useContext } from 'preact/hooks';
16+
import { useContext, useMemo } from 'preact/hooks';
1617

1718
import { Config } from '../config';
1819
import { quote, username } from '../utils/annotation-metadata';
@@ -29,6 +30,17 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
2930
annotation.user_info?.display_name ??
3031
username(annotation.user) ??
3132
annotation.user;
33+
const group = useMemo(
34+
() =>
35+
config.context.group && {
36+
type: config.context.group.type,
37+
name: config.context.group.name,
38+
links: {
39+
html: config.context.group.link,
40+
},
41+
},
42+
[config.context.group],
43+
);
3244

3345
return (
3446
<article>
@@ -48,17 +60,9 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
4860
annotationUpdated={annotation.updated}
4961
/>
5062
</div>
51-
{config.context.group && (
63+
{group && (
5264
<div className="flex gap-x-1 items-baseline flex-wrap-reverse">
53-
<AnnotationGroupInfo
54-
group={{
55-
type: config.context.group.type,
56-
name: config.context.group.name,
57-
links: {
58-
html: config.context.group.link,
59-
},
60-
}}
61-
/>
65+
<AnnotationGroupInfo group={group} />
6266
<AnnotationDocument annotation={annotation} />
6367
</div>
6468
)}
@@ -98,7 +102,7 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
98102

99103
<footer className="flex items-center justify-between">
100104
<div />
101-
<div className="flex items-center gap-3">
105+
<div className="flex items-center gap-1">
102106
<Link
103107
variant="text-light"
104108
href={annotation.links.incontext}
@@ -109,6 +113,7 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
109113
>
110114
<ExternalIcon />
111115
</Link>
116+
<AnnotationShareControl annotation={annotation} group={group} />
112117
</div>
113118
</footer>
114119
</CardContent>

0 commit comments

Comments
 (0)