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
3bf039a0
Commit
3bf039a0
authored
Nov 14, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Nov 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `AnnotationActionBar` to TS
parent
2c4c0786
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
AnnotationActionBar.tsx
src/sidebar/components/Annotation/AnnotationActionBar.tsx
+18
-19
No files found.
src/sidebar/components/Annotation/AnnotationActionBar.
js
→
src/sidebar/components/Annotation/AnnotationActionBar.
tsx
View file @
3bf039a0
...
@@ -8,6 +8,9 @@ import {
...
@@ -8,6 +8,9 @@ import {
}
from
'@hypothesis/frontend-shared/lib/next'
;
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
{
confirm
}
from
'../../../shared/prompts'
;
import
{
confirm
}
from
'../../../shared/prompts'
;
import
type
{
SavedAnnotation
}
from
'../../../types/api'
;
import
type
{
SidebarSettings
}
from
'../../../types/config'
;
import
{
serviceConfig
}
from
'../../config/service-config'
;
import
{
serviceConfig
}
from
'../../config/service-config'
;
import
{
annotationRole
}
from
'../../helpers/annotation-metadata'
;
import
{
annotationRole
}
from
'../../helpers/annotation-metadata'
;
import
{
import
{
...
@@ -16,26 +19,13 @@ import {
...
@@ -16,26 +19,13 @@ import {
}
from
'../../helpers/annotation-sharing'
;
}
from
'../../helpers/annotation-sharing'
;
import
{
isPrivate
,
permits
}
from
'../../helpers/permissions'
;
import
{
isPrivate
,
permits
}
from
'../../helpers/permissions'
;
import
{
withServices
}
from
'../../service-context'
;
import
{
withServices
}
from
'../../service-context'
;
import
type
{
AnnotationsService
}
from
'../../services/annotations'
;
import
type
{
ToastMessengerService
}
from
'../../services/toast-messenger'
;
import
{
useSidebarStore
}
from
'../../store'
;
import
{
useSidebarStore
}
from
'../../store'
;
import
AnnotationShareControl
from
'./AnnotationShareControl'
;
import
AnnotationShareControl
from
'./AnnotationShareControl'
;
/**
function
flaggingEnabled
(
settings
:
SidebarSettings
)
{
* @typedef {import("../../../types/api").SavedAnnotation} SavedAnnotation
* @typedef {import('../../../types/config').SidebarSettings} SidebarSettings
*/
/**
* @typedef AnnotationActionBarProps
* @prop {SavedAnnotation} annotation - The annotation in question
* @prop {() => void} onReply - Callbacks for when action buttons are clicked/tapped
* @prop {import('../../services/annotations').AnnotationsService} annotationsService
* @prop {SidebarSettings} settings
* @prop {import('../../services/toast-messenger').ToastMessengerService} toastMessenger
*/
/** @param {SidebarSettings} settings */
function
flaggingEnabled
(
settings
)
{
const
service
=
serviceConfig
(
settings
);
const
service
=
serviceConfig
(
settings
);
if
(
service
?.
allowFlagging
===
false
)
{
if
(
service
?.
allowFlagging
===
false
)
{
return
false
;
return
false
;
...
@@ -43,6 +33,16 @@ function flaggingEnabled(settings) {
...
@@ -43,6 +33,16 @@ function flaggingEnabled(settings) {
return
true
;
return
true
;
}
}
export
type
AnnotationActionBarProps
=
{
annotation
:
SavedAnnotation
;
onReply
:
()
=>
void
;
// injected
annotationsService
:
AnnotationsService
;
settings
:
SidebarSettings
;
toastMessenger
:
ToastMessengerService
;
};
/**
/**
* A collection of buttons in the footer area of an annotation that take
* A collection of buttons in the footer area of an annotation that take
* actions on the annotation.
* actions on the annotation.
...
@@ -55,15 +55,14 @@ function AnnotationActionBar({
...
@@ -55,15 +55,14 @@ function AnnotationActionBar({
onReply
,
onReply
,
settings
,
settings
,
toastMessenger
,
toastMessenger
,
})
{
}
:
AnnotationActionBarProps
)
{
const
store
=
useSidebarStore
();
const
store
=
useSidebarStore
();
const
userProfile
=
store
.
profile
();
const
userProfile
=
store
.
profile
();
const
annotationGroup
=
store
.
getGroup
(
annotation
.
group
);
const
annotationGroup
=
store
.
getGroup
(
annotation
.
group
);
const
isLoggedIn
=
store
.
isLoggedIn
();
const
isLoggedIn
=
store
.
isLoggedIn
();
// Is the current user allowed to take the given `action` on this annotation?
// Is the current user allowed to take the given `action` on this annotation?
/** @param {'update'|'delete'} action */
const
userIsAuthorizedTo
=
(
action
:
'update'
|
'delete'
)
=>
{
const
userIsAuthorizedTo
=
action
=>
{
return
permits
(
annotation
.
permissions
,
action
,
userProfile
.
userid
);
return
permits
(
annotation
.
permissions
,
action
,
userProfile
.
userid
);
};
};
...
...
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