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
9a14ed89
Commit
9a14ed89
authored
Apr 08, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove export_formats feature flag
parent
a04c4e1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
67 deletions
+42
-67
ExportAnnotations.tsx
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
+32
-39
ExportAnnotations-test.js
...bar/components/ShareDialog/test/ExportAnnotations-test.js
+10
-28
No files found.
src/sidebar/components/ShareDialog/ExportAnnotations.tsx
View file @
9a14ed89
...
@@ -130,7 +130,6 @@ function ExportAnnotations({
...
@@ -130,7 +130,6 @@ function ExportAnnotations({
[
allAnnotationsOption
,
selectedUserId
,
userList
],
[
allAnnotationsOption
,
selectedUserId
,
userList
],
);
);
const
exportFormatsEnabled
=
store
.
isFeatureEnabled
(
'export_formats'
);
const
[
exportFormat
,
setExportFormat
]
=
useState
(
exportFormats
[
0
]);
const
[
exportFormat
,
setExportFormat
]
=
useState
(
exportFormats
[
0
]);
const
fileInputId
=
useId
();
const
fileInputId
=
useId
();
...
@@ -325,35 +324,31 @@ function ExportAnnotations({
...
@@ -325,35 +324,31 @@ function ExportAnnotations({
required
required
maxLength=
{
250
}
maxLength=
{
250
}
/>
/>
{
exportFormatsEnabled
&&
(
<
div
className=
"grow-0 ml-2 min-w-[5rem]"
>
<
div
className=
"grow-0 ml-2 min-w-[5rem]"
>
<
SelectNext
<
SelectNext
value=
{
exportFormat
}
value=
{
exportFormat
}
onChange=
{
setExportFormat
}
onChange=
{
setExportFormat
}
buttonContent=
{
exportFormat
.
shortTitle
??
exportFormat
.
title
}
buttonContent=
{
data
-
testid=
"export-format-select"
exportFormat
.
shortTitle
??
exportFormat
.
title
right
}
>
data
-
testid=
"export-format-select"
{
exportFormats
.
map
(
exportFormat
=>
(
right
<
SelectNext
.
Option
>
key=
{
exportFormat
.
value
}
{
exportFormats
.
map
(
exportFormat
=>
(
value=
{
exportFormat
}
<
SelectNext
.
Option
>
key=
{
exportFormat
.
value
}
<
div
className=
"flex-col gap-y-2"
>
value=
{
exportFormat
}
<
div
className=
"font-bold"
data
-
testid=
"format-name"
>
>
{
exportFormat
.
title
}
<
div
className=
"flex-col gap-y-2"
>
</
div
>
<
div
className=
"font-bold"
data
-
testid=
"format-name"
>
<
div
data
-
testid=
"format-description"
>
{
exportFormat
.
title
}
{
exportFormat
.
description
}
</
div
>
<
div
data
-
testid=
"format-description"
>
{
exportFormat
.
description
}
</
div
>
</
div
>
</
div
>
</
SelectNext
.
Option
>
</
div
>
))
}
</
SelectNext
.
Option
>
</
SelectNext
>
))
}
</
div
>
</
SelectNext
>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</>
</>
...
@@ -370,16 +365,14 @@ function ExportAnnotations({
...
@@ -370,16 +365,14 @@ function ExportAnnotations({
</
p
>
</
p
>
)
}
)
}
<
CardActions
>
<
CardActions
>
{
exportFormatsEnabled
&&
(
<
Button
<
Button
data
-
testid=
"copy-button"
data
-
testid=
"copy-button"
icon=
{
CopyIcon
}
icon=
{
CopyIcon
}
onClick=
{
copyAnnotationsExport
}
onClick=
{
copyAnnotationsExport
}
disabled=
{
exportableAnnotations
.
length
===
0
}
disabled=
{
exportableAnnotations
.
length
===
0
}
>
>
Copy to clipboard
Copy to clipboard
</
Button
>
</
Button
>
)
}
<
Button
<
Button
data
-
testid=
"export-button"
data
-
testid=
"export-button"
variant=
"primary"
variant=
"primary"
...
...
src/sidebar/components/ShareDialog/test/ExportAnnotations-test.js
View file @
9a14ed89
...
@@ -232,20 +232,14 @@ describe('ExportAnnotations', () => {
...
@@ -232,20 +232,14 @@ describe('ExportAnnotations', () => {
assert
.
equal
(
input
.
prop
(
'defaultValue'
),
'suggested-filename'
);
assert
.
equal
(
input
.
prop
(
'defaultValue'
),
'suggested-filename'
);
});
});
[
it
(
'displays format selector'
,
async
()
=>
{
{
exportFormatsEnabled
:
true
,
expectedAmountOfSelects
:
2
},
const
wrapper
=
createComponent
();
{
exportFormatsEnabled
:
false
,
expectedAmountOfSelects
:
1
},
const
select
=
await
waitForElement
(
].
forEach
(({
exportFormatsEnabled
,
expectedAmountOfSelects
})
=>
{
wrapper
,
it
(
'displays format selector when feature is enabled'
,
async
()
=>
{
'[data-testid="export-format-select"]'
,
fakeStore
.
isFeatureEnabled
.
callsFake
(
);
ff
=>
exportFormatsEnabled
||
ff
!==
'export_formats'
,
);
const
wrapper
=
createComponent
();
const
selects
=
await
waitForElement
(
wrapper
,
SelectNext
);
assert
.
equal
(
selects
.
length
,
expectedAmountOfSelects
);
assert
.
isDefined
(
select
);
});
});
});
it
(
'lists supported export formats'
,
async
()
=>
{
it
(
'lists supported export formats'
,
async
()
=>
{
...
@@ -464,18 +458,9 @@ describe('ExportAnnotations', () => {
...
@@ -464,18 +458,9 @@ describe('ExportAnnotations', () => {
});
});
context
(
'when copying annotations export to clipboard'
,
()
=>
{
context
(
'when copying annotations export to clipboard'
,
()
=>
{
[
true
,
false
].
forEach
(
exportFormatsEnabled
=>
{
it
(
'displays copy button'
,
()
=>
{
it
(
'displays copy button if `export_formats` FF is enabled'
,
()
=>
{
const
wrapper
=
createComponent
();
fakeStore
.
isFeatureEnabled
.
callsFake
(
ff
=>
assert
.
isTrue
(
wrapper
.
exists
(
'[data-testid="copy-button"]'
));
ff
===
'export_formats'
?
exportFormatsEnabled
:
true
,
);
const
wrapper
=
createComponent
();
assert
.
equal
(
wrapper
.
exists
(
'[data-testid="copy-button"]'
),
exportFormatsEnabled
,
);
});
});
});
[
[
...
@@ -515,8 +500,6 @@ describe('ExportAnnotations', () => {
...
@@ -515,8 +500,6 @@ describe('ExportAnnotations', () => {
getExpectedInvokedContentBuilder
,
getExpectedInvokedContentBuilder
,
})
=>
{
})
=>
{
it
(
'copies export content as rich or plain text depending on format'
,
async
()
=>
{
it
(
'copies export content as rich or plain text depending on format'
,
async
()
=>
{
fakeStore
.
isFeatureEnabled
.
callsFake
(
ff
=>
ff
===
'export_formats'
);
const
wrapper
=
createComponent
();
const
wrapper
=
createComponent
();
const
copyButton
=
wrapper
.
find
(
'button[data-testid="copy-button"]'
);
const
copyButton
=
wrapper
.
find
(
'button[data-testid="copy-button"]'
);
...
@@ -541,7 +524,6 @@ describe('ExportAnnotations', () => {
...
@@ -541,7 +524,6 @@ describe('ExportAnnotations', () => {
);
);
it
(
'adds error toast message when copying annotations fails'
,
async
()
=>
{
it
(
'adds error toast message when copying annotations fails'
,
async
()
=>
{
fakeStore
.
isFeatureEnabled
.
callsFake
(
ff
=>
ff
===
'export_formats'
);
fakeCopyPlainText
.
rejects
(
new
Error
(
'Something failed'
));
fakeCopyPlainText
.
rejects
(
new
Error
(
'Something failed'
));
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