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
0facdc30
Commit
0facdc30
authored
Jan 19, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `ModerationBanner` to TS
parent
72dc229d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
ModerationBanner.tsx
src/sidebar/components/ModerationBanner.tsx
+20
-21
No files found.
src/sidebar/components/ModerationBanner.
js
→
src/sidebar/components/ModerationBanner.
tsx
View file @
0facdc30
...
...
@@ -5,30 +5,31 @@ import {
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
classnames
from
'classnames'
;
import
type
{
Annotation
}
from
'../../types/api'
;
import
type
{
APIService
}
from
'../services/api'
;
import
type
{
ToastMessengerService
}
from
'../services/toast-messenger'
;
import
{
useSidebarStore
}
from
'../store'
;
import
*
as
annotationMetadata
from
'../helpers/annotation-metadata'
;
import
{
withServices
}
from
'../service-context'
;
/**
* @typedef {import('../../types/api').Annotation} Annotation
*/
export
type
ModerationBannerProps
=
{
annotation
:
Annotation
;
/**
* @typedef ModerationBannerProps
* @prop {Annotation} annotation -
* The annotation object for this banner. This contains state about the flag count
* or its hidden value.
* @prop {import('../services/api').APIService} api
* @prop {import('../services/toast-messenger').ToastMessengerService} toastMessenger
*/
// injected
api
:
APIService
;
toastMessenger
:
ToastMessengerService
;
};
/**
* Banner allows moderators to hide/unhide the flagged
* annotation from other users.
*
* @param {ModerationBannerProps} props
* Banner allows moderators to hide/unhide the flagged annotation from other
* users.
*/
function
ModerationBanner
({
annotation
,
api
,
toastMessenger
})
{
function
ModerationBanner
({
annotation
,
api
,
toastMessenger
,
}:
ModerationBannerProps
)
{
const
store
=
useSidebarStore
();
const
flagCount
=
annotationMetadata
.
flagCount
(
annotation
);
...
...
@@ -39,7 +40,7 @@ function ModerationBanner({ annotation, api, toastMessenger }) {
* Hide an annotation from non-moderator users.
*/
const
hideAnnotation
=
()
=>
{
const
id
=
/** @type {string} */
(
annotation
.
id
)
;
const
id
=
annotation
.
id
!
;
api
.
annotation
.
hide
({
id
})
.
then
(()
=>
{
...
...
@@ -54,7 +55,7 @@ function ModerationBanner({ annotation, api, toastMessenger }) {
* Un-hide an annotation from non-moderator users.
*/
const
unhideAnnotation
=
()
=>
{
const
id
=
/** @type {string} */
(
annotation
.
id
)
;
const
id
=
annotation
.
id
!
;
api
.
annotation
.
unhide
({
id
})
.
then
(()
=>
{
...
...
@@ -72,9 +73,7 @@ function ModerationBanner({ annotation, api, toastMessenger }) {
<
div
className=
{
classnames
(
'flex gap-x-3 bg-grey-1 text-color-text font-semibold'
,
// Vertical margins should ultimately be handled by the parent, but
// until we can refactor outer components (e.g. `ThreadCard`), this
// component manages its own bottom margin
// FIXME: Refactor margins: where possible manage them in a parent
'mb-2 '
,
{
// For top-level annotations, use negative margins to "break out" of
...
...
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