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
8882a070
Commit
8882a070
authored
Jan 12, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve export format titles displayed in listbox
parent
1dd6b004
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
10 deletions
+38
-10
ExportAnnotations.tsx
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
+18
-7
ExportAnnotations-test.js
...bar/components/ShareDialog/test/ExportAnnotations-test.js
+20
-3
No files found.
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
View file @
8882a070
...
...
@@ -34,29 +34,40 @@ export type ExportAnnotationsProps = {
type
ExportFormat
=
{
/** Unique format identifier used also as file extension */
value
:
'json'
|
'csv'
|
'txt'
|
'html'
;
name
:
string
;
/** The title to be displayed in the listbox item */
title
:
string
;
/**
* The title to be displayed in the Select button.
* Falls back to `title` when not provided.
*/
shortTitle
?:
string
;
description
:
string
;
};
const
exportFormats
:
ExportFormat
[]
=
[
{
value
:
'json'
,
nam
e
:
'JSON'
,
titl
e
:
'JSON'
,
description
:
'For import into another Hypothesis group or document'
,
},
{
value
:
'txt'
,
name
:
'Text'
,
title
:
'Plain text (TXT)'
,
shortTitle
:
'Text'
,
description
:
'For import into word processors as plain text'
,
},
{
value
:
'csv'
,
name
:
'CSV'
,
title
:
'Table (CSV)'
,
shortTitle
:
'CSV'
,
description
:
'For import into a spreadsheet'
,
},
{
value
:
'html'
,
name
:
'HTML'
,
title
:
'Rich text (HTML)'
,
shortTitle
:
'HTML'
,
description
:
'For import into word processors as rich text'
,
},
];
...
...
@@ -235,7 +246,7 @@ function ExportAnnotations({
<SelectNext
value={exportFormat}
onChange={setExportFormat}
buttonContent={exportFormat.
nam
e}
buttonContent={exportFormat.
shortTitle ?? exportFormat.titl
e}
data-testid="export-format-select"
right
>
...
...
@@ -246,7 +257,7 @@ function ExportAnnotations({
>
<div className="flex-col gap-y-2">
<div className="font-bold" data-testid="format-name">
{exportFormat.
nam
e}
{exportFormat.
titl
e}
</div>
<div data-testid="format-description">
{exportFormat.description}
...
...
src/sidebar/components/ShareDialog/test/ExportAnnotations-test.js
View file @
8882a070
...
...
@@ -254,20 +254,37 @@ describe('ExportAnnotations', () => {
optionText
(
0
,
'description'
),
'For import into another Hypothesis group or document'
,
);
assert
.
equal
(
optionText
(
1
,
'name'
),
'
Text
'
);
assert
.
equal
(
optionText
(
1
,
'name'
),
'
Plain text (TXT)
'
);
assert
.
equal
(
optionText
(
1
,
'description'
),
'For import into word processors as plain text'
,
);
assert
.
equal
(
optionText
(
2
,
'name'
),
'
CSV
'
);
assert
.
equal
(
optionText
(
2
,
'name'
),
'
Table (CSV)
'
);
assert
.
equal
(
optionText
(
2
,
'description'
),
'For import into a spreadsheet'
);
assert
.
equal
(
optionText
(
3
,
'name'
),
'
HTML
'
);
assert
.
equal
(
optionText
(
3
,
'name'
),
'
Rich text (HTML)
'
);
assert
.
equal
(
optionText
(
3
,
'description'
),
'For import into word processors as rich text'
,
);
});
[
[{
shortTitle
:
'Short'
,
title
:
'Something longer'
},
'Short'
],
[{
title
:
'Something longer'
},
'Something longer'
],
].
forEach
(([
format
,
expectedTitle
])
=>
{
it
(
'displays format short title if defined'
,
async
()
=>
{
const
wrapper
=
createComponent
();
const
getSelect
=
()
=>
waitForElement
(
wrapper
,
'[data-testid="export-format-select"]'
);
const
selectBefore
=
await
getSelect
();
selectBefore
.
props
().
onChange
(
format
);
const
selectAfter
=
await
getSelect
();
assert
.
equal
(
selectAfter
.
prop
(
'buttonContent'
),
expectedTitle
);
});
});
describe
(
'export form submitted'
,
()
=>
{
const
submitExportForm
=
wrapper
=>
wrapper
.
find
(
'[data-testid="export-form"]'
).
simulate
(
'submit'
);
...
...
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