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
2f6b57bc
Commit
2f6b57bc
authored
Jan 22, 2024
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement very basic pluralization for tab count message
parent
701d921b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
SelectionTabs.tsx
src/sidebar/components/SelectionTabs.tsx
+11
-3
SelectionTabs-test.js
src/sidebar/components/test/SelectionTabs-test.js
+8
-0
No files found.
src/sidebar/components/SelectionTabs.tsx
View file @
2f6b57bc
...
@@ -125,15 +125,23 @@ function SelectionTabs({
...
@@ -125,15 +125,23 @@ function SelectionTabs({
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
)
{
tabCountsSummaryPieces
.
push
(
`
${
annotationCount
}
annotations`
);
const
term
=
pluralize
(
annotationCount
,
'annotation'
,
'annotations'
);
tabCountsSummaryPieces
.
push
(
`
${
annotationCount
}
${
term
}
`
);
}
}
if
(
noteCount
>
0
)
{
if
(
noteCount
>
0
)
{
tabCountsSummaryPieces
.
push
(
`
${
noteCount
}
notes`
);
const
term
=
pluralize
(
noteCount
,
'note'
,
'notes'
);
tabCountsSummaryPieces
.
push
(
`
${
noteCount
}
${
term
}
`
);
}
}
if
(
orphanCount
>
0
)
{
if
(
orphanCount
>
0
)
{
tabCountsSummaryPieces
.
push
(
`
${
orphanCount
}
orphans`
);
const
term
=
pluralize
(
noteCount
,
'orphan'
,
'orphans'
);
tabCountsSummaryPieces
.
push
(
`
${
orphanCount
}
${
term
}
`
);
}
}
const
tabCountsSummary
=
tabCountsSummaryPieces
.
join
(
', '
);
const
tabCountsSummary
=
tabCountsSummaryPieces
.
join
(
', '
);
...
...
src/sidebar/components/test/SelectionTabs-test.js
View file @
2f6b57bc
...
@@ -340,6 +340,14 @@ describe('SelectionTabs', () => {
...
@@ -340,6 +340,14 @@ describe('SelectionTabs', () => {
},
},
message
:
'2 annotations, 3 notes, 4 orphans'
,
message
:
'2 annotations, 3 notes, 4 orphans'
,
},
},
{
tabCounts
:
{
annotation
:
1
,
note
:
1
,
orphan
:
1
,
},
message
:
'1 annotation, 1 note, 1 orphan'
,
},
].
forEach
(({
tabCounts
,
message
})
=>
{
].
forEach
(({
tabCounts
,
message
})
=>
{
it
(
'reports annotation count to screen readers'
,
()
=>
{
it
(
'reports annotation count to screen readers'
,
()
=>
{
const
wrapper
=
createComponent
({
const
wrapper
=
createComponent
({
...
...
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