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
fc26c2bd
Commit
fc26c2bd
authored
Mar 21, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 21, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show singular 'update' in notification when there's only one
parent
fe46a6ce
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
11 deletions
+25
-11
pluralize.ts
src/shared/pluralize.ts
+6
-0
pluralize-test.js
src/shared/test/pluralize-test.js
+14
-0
PendingUpdatesNotification.tsx
src/sidebar/components/PendingUpdatesNotification.tsx
+3
-1
ExportAnnotations.tsx
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
+1
-5
SidebarTabs.tsx
src/sidebar/components/SidebarTabs.tsx
+1
-5
No files found.
src/shared/pluralize.ts
0 → 100644
View file @
fc26c2bd
/**
* Naive simple English pluralization
*/
export
function
pluralize
(
count
:
number
,
singular
:
string
,
plural
:
string
)
{
return
count
===
1
?
singular
:
plural
;
}
src/shared/test/pluralize-test.js
0 → 100644
View file @
fc26c2bd
import
{
pluralize
}
from
'../pluralize'
;
describe
(
'pluralize'
,
()
=>
{
[
{
count
:
0
,
expectedResult
:
'people'
},
{
count
:
1
,
expectedResult
:
'person'
},
{
count
:
2
,
expectedResult
:
'people'
},
{
count
:
10
,
expectedResult
:
'people'
},
].
forEach
(({
count
,
expectedResult
})
=>
{
it
(
'returns expected form'
,
()
=>
{
assert
.
equal
(
pluralize
(
count
,
'person'
,
'people'
),
expectedResult
);
});
});
});
src/sidebar/components/PendingUpdatesNotification.tsx
View file @
fc26c2bd
...
@@ -2,6 +2,7 @@ import { Button, DownloadIcon } from '@hypothesis/frontend-shared';
...
@@ -2,6 +2,7 @@ import { Button, DownloadIcon } from '@hypothesis/frontend-shared';
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
'preact/hooks'
;
import
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
'preact/hooks'
;
import
{
pluralize
}
from
'../../shared/pluralize'
;
import
{
useShortcut
}
from
'../../shared/shortcut'
;
import
{
useShortcut
}
from
'../../shared/shortcut'
;
import
{
withServices
}
from
'../service-context'
;
import
{
withServices
}
from
'../service-context'
;
import
type
{
StreamerService
}
from
'../services/streamer'
;
import
type
{
StreamerService
}
from
'../services/streamer'
;
...
@@ -74,7 +75,8 @@ function PendingUpdatesNotification({
...
@@ -74,7 +75,8 @@ function PendingUpdatesNotification({
>
>
{
!
collapsed
&&
(
{
!
collapsed
&&
(
<
span
data
-
testid=
"full-notification"
className=
"whitespace-nowrap"
>
<
span
data
-
testid=
"full-notification"
className=
"whitespace-nowrap"
>
Load
<
span
className=
"font-bold"
>
{
pendingUpdateCount
}
</
span
>
updates
{
' '
}
Load
<
span
className=
"font-bold"
>
{
pendingUpdateCount
}
</
span
>
{
' '
}
{
pluralize
(
pendingUpdateCount
,
'update'
,
'updates'
)
}{
' '
}
<
span
className=
"sr-only"
>
by pressing l
</
span
>
<
span
className=
"sr-only"
>
by pressing l
</
span
>
</
span
>
</
span
>
)
}
)
}
...
...
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
View file @
fc26c2bd
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
import
{
useCallback
,
useId
,
useMemo
,
useState
}
from
'preact/hooks'
;
import
{
useCallback
,
useId
,
useMemo
,
useState
}
from
'preact/hooks'
;
import
{
downloadFile
}
from
'../../../shared/download-file'
;
import
{
downloadFile
}
from
'../../../shared/download-file'
;
import
{
pluralize
}
from
'../../../shared/pluralize'
;
import
type
{
APIAnnotationData
}
from
'../../../types/api'
;
import
type
{
APIAnnotationData
}
from
'../../../types/api'
;
import
{
annotationDisplayName
}
from
'../../helpers/annotation-user'
;
import
{
annotationDisplayName
}
from
'../../helpers/annotation-user'
;
import
type
{
UserAnnotations
}
from
'../../helpers/annotations-by-user'
;
import
type
{
UserAnnotations
}
from
'../../helpers/annotations-by-user'
;
...
@@ -256,11 +257,6 @@ function ExportAnnotations({
...
@@ -256,11 +257,6 @@ function ExportAnnotations({
return
<
LoadingSpinner
/>;
return
<
LoadingSpinner
/>;
}
}
// Naive simple English pluralization
const
pluralize
=
(
count
:
number
,
singular
:
string
,
plural
:
string
)
=>
{
return
count
===
1
?
singular
:
plural
;
};
return
(
return
(
<
form
<
form
className=
"space-y-3"
className=
"space-y-3"
...
...
src/sidebar/components/SidebarTabs.tsx
View file @
fc26c2bd
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
type
{
ComponentChildren
}
from
'preact'
;
import
type
{
ComponentChildren
}
from
'preact'
;
import
{
pluralize
}
from
'../../shared/pluralize'
;
import
type
{
SidebarSettings
}
from
'../../types/config'
;
import
type
{
SidebarSettings
}
from
'../../types/config'
;
import
type
{
TabName
}
from
'../../types/sidebar'
;
import
type
{
TabName
}
from
'../../types/sidebar'
;
import
{
applyTheme
}
from
'../helpers/theme'
;
import
{
applyTheme
}
from
'../helpers/theme'
;
...
@@ -127,11 +128,6 @@ function SidebarTabs({
...
@@ -127,11 +128,6 @@ function SidebarTabs({
const
showNotesUnavailableMessage
=
selectedTab
===
'note'
&&
noteCount
===
0
;
const
showNotesUnavailableMessage
=
selectedTab
===
'note'
&&
noteCount
===
0
;
// Naive simple English pluralization
const
pluralize
=
(
count
:
number
,
singular
:
string
,
plural
:
string
)
=>
{
return
count
===
1
?
singular
:
plural
;
};
const
tabCountsSummaryPieces
=
[];
const
tabCountsSummaryPieces
=
[];
if
(
annotationCount
>
0
)
{
if
(
annotationCount
>
0
)
{
const
term
=
pluralize
(
annotationCount
,
'annotation'
,
'annotations'
);
const
term
=
pluralize
(
annotationCount
,
'annotation'
,
'annotations'
);
...
...
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