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
91cc9775
Commit
91cc9775
authored
Dec 14, 2023
by
Alejandro Celaya
Committed by
Robert Knight
Dec 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove usage of import/export feature flags
parent
b3a2f138
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
167 deletions
+76
-167
HypothesisApp.tsx
src/sidebar/components/HypothesisApp.tsx
+1
-12
ShareDialog.tsx
src/sidebar/components/ShareDialog/ShareDialog.tsx
+64
-82
ShareDialog-test.js
src/sidebar/components/ShareDialog/test/ShareDialog-test.js
+2
-32
TopBar.tsx
src/sidebar/components/TopBar.tsx
+9
-14
HypothesisApp-test.js
src/sidebar/components/test/HypothesisApp-test.js
+0
-17
TopBar-test.js
src/sidebar/components/test/TopBar-test.js
+0
-10
No files found.
src/sidebar/components/HypothesisApp.tsx
View file @
91cc9775
...
@@ -65,10 +65,6 @@ function HypothesisApp({
...
@@ -65,10 +65,6 @@ function HypothesisApp({
},
[
isSidebar
,
profile
,
settings
,
store
]);
},
[
isSidebar
,
profile
,
settings
,
store
]);
const
isThirdParty
=
isThirdPartyService
(
settings
);
const
isThirdParty
=
isThirdPartyService
(
settings
);
const
exportAnnotations
=
store
.
isFeatureEnabled
(
'export_annotations'
);
const
importAnnotations
=
store
.
isFeatureEnabled
(
'import_annotations'
);
const
showShareButton
=
!
isThirdParty
||
exportAnnotations
||
importAnnotations
;
const
searchPanelEnabled
=
store
.
isFeatureEnabled
(
'search_panel'
);
const
searchPanelEnabled
=
store
.
isFeatureEnabled
(
'search_panel'
);
...
@@ -165,20 +161,13 @@ function HypothesisApp({
...
@@ -165,20 +161,13 @@ function HypothesisApp({
onSignUp=
{
signUp
}
onSignUp=
{
signUp
}
onLogout=
{
logout
}
onLogout=
{
logout
}
isSidebar=
{
isSidebar
}
isSidebar=
{
isSidebar
}
showShareButton=
{
showShareButton
}
/>
/>
)
}
)
}
<
div
className=
"container"
>
<
div
className=
"container"
>
<
ToastMessages
/>
<
ToastMessages
/>
<
HelpPanel
/>
<
HelpPanel
/>
{
searchPanelEnabled
&&
<
SearchPanel
/>
}
{
searchPanelEnabled
&&
<
SearchPanel
/>
}
{
showShareButton
&&
(
<
ShareDialog
shareTab=
{
!
isThirdParty
}
/>
<
ShareDialog
shareTab=
{
!
isThirdParty
}
exportTab=
{
exportAnnotations
}
importTab=
{
importAnnotations
}
/>
)
}
{
route
&&
(
{
route
&&
(
<
main
>
<
main
>
...
...
src/sidebar/components/ShareDialog/ShareDialog.tsx
View file @
91cc9775
...
@@ -13,10 +13,6 @@ import ShareAnnotations from './ShareAnnotations';
...
@@ -13,10 +13,6 @@ import ShareAnnotations from './ShareAnnotations';
export
type
ShareDialogProps
=
{
export
type
ShareDialogProps
=
{
/** If true, the share tab will be rendered. Defaults to false */
/** If true, the share tab will be rendered. Defaults to false */
shareTab
?:
boolean
;
shareTab
?:
boolean
;
/** If true, the export tab will be rendered. Defaults to false */
exportTab
?:
boolean
;
/** If true, the import tab will be rendered. Defaults to false */
importTab
?:
boolean
;
};
};
/**
/**
...
@@ -24,32 +20,25 @@ export type ShareDialogProps = {
...
@@ -24,32 +20,25 @@ export type ShareDialogProps = {
* - If provided tabs include `export` or `import`, will show a tabbed interface
* - If provided tabs include `export` or `import`, will show a tabbed interface
* - Else, shows a single "Share annotations" interface
* - Else, shows a single "Share annotations" interface
*/
*/
export
default
function
ShareDialog
({
export
default
function
ShareDialog
({
shareTab
}:
ShareDialogProps
)
{
shareTab
,
exportTab
,
importTab
,
}:
ShareDialogProps
)
{
const
store
=
useSidebarStore
();
const
store
=
useSidebarStore
();
const
focusedGroup
=
store
.
focusedGroup
();
const
focusedGroup
=
store
.
focusedGroup
();
const
groupName
=
(
focusedGroup
&&
focusedGroup
.
name
)
||
'...'
;
const
groupName
=
(
focusedGroup
&&
focusedGroup
.
name
)
||
'...'
;
const
panelTitle
=
`Share Annotations in
${
groupName
}
`
;
const
panelTitle
=
`Share Annotations in
${
groupName
}
`
;
const
tabbedDialog
=
exportTab
||
importTab
;
// Determine initial selected tab, based on the first tab that will be displayed
// Determine initial selected tab, based on the first tab that will be displayed
const
initialTab
=
shareTab
?
'share'
:
exportTab
?
'export'
:
'im
port'
;
const
initialTab
=
shareTab
?
'share'
:
'ex
port'
;
const
[
selectedTab
,
setSelectedTab
]
=
useState
<
'share'
|
'export'
|
'import'
>
(
const
[
selectedTab
,
setSelectedTab
]
=
useState
<
'share'
|
'export'
|
'import'
>
(
initialTab
,
initialTab
,
);
);
const
isFirstTabSelected
=
tabbedDialog
&&
selectedTab
===
initialTab
;
const
isFirstTabSelected
=
selectedTab
===
initialTab
;
return
(
return
(
<
SidebarPanel
<
SidebarPanel
title=
{
panelTitle
}
title=
{
panelTitle
}
panelName=
"shareGroupAnnotations"
panelName=
"shareGroupAnnotations"
variant=
{
tabbedDialog
?
'custom'
:
'panel'
}
variant=
"custom"
>
>
{
tabbedDialog
&&
(
<>
<
TabHeader
>
<
TabHeader
>
{
shareTab
&&
(
{
shareTab
&&
(
<
Tab
<
Tab
...
@@ -63,7 +52,6 @@ export default function ShareDialog({
...
@@ -63,7 +52,6 @@ export default function ShareDialog({
Share
Share
</
Tab
>
</
Tab
>
)
}
)
}
{
exportTab
&&
(
<
Tab
<
Tab
id=
"export-panel-tab"
id=
"export-panel-tab"
aria
-
controls=
"export-panel"
aria
-
controls=
"export-panel"
...
@@ -74,8 +62,6 @@ export default function ShareDialog({
...
@@ -74,8 +62,6 @@ export default function ShareDialog({
>
>
Export
Export
</
Tab
>
</
Tab
>
)
}
{
importTab
&&
(
<
Tab
<
Tab
id=
"import-panel-tab"
id=
"import-panel-tab"
aria
-
controls=
"import-panel"
aria
-
controls=
"import-panel"
...
@@ -86,7 +72,6 @@ export default function ShareDialog({
...
@@ -86,7 +72,6 @@ export default function ShareDialog({
>
>
Import
Import
</
Tab
>
</
Tab
>
)
}
</
TabHeader
>
</
TabHeader
>
<
Card
classes=
{
classnames
({
'rounded-tl-none'
:
isFirstTabSelected
})
}
>
<
Card
classes=
{
classnames
({
'rounded-tl-none'
:
isFirstTabSelected
})
}
>
<
TabPanel
<
TabPanel
...
@@ -114,9 +99,6 @@ export default function ShareDialog({
...
@@ -114,9 +99,6 @@ export default function ShareDialog({
<
ImportAnnotations
/>
<
ImportAnnotations
/>
</
TabPanel
>
</
TabPanel
>
</
Card
>
</
Card
>
</>
)
}
{
shareTab
&&
!
tabbedDialog
&&
<
ShareAnnotations
/>
}
</
SidebarPanel
>
</
SidebarPanel
>
);
);
}
}
src/sidebar/components/ShareDialog/test/ShareDialog-test.js
View file @
91cc9775
...
@@ -18,7 +18,7 @@ describe('ShareDialog', () => {
...
@@ -18,7 +18,7 @@ describe('ShareDialog', () => {
};
};
const
createComponent
=
(
props
=
{})
=>
const
createComponent
=
(
props
=
{})
=>
mount
(
<
ShareDialog
shareTab
exportTab
importTab
{...
props
}
/>
)
;
mount
(
<
ShareDialog
shareTab
{...
props
}
/>
)
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
fakeStore
=
{
fakeStore
=
{
...
@@ -73,25 +73,6 @@ describe('ShareDialog', () => {
...
@@ -73,25 +73,6 @@ describe('ShareDialog', () => {
return
wrapper
.
find
(
'TabPanel'
).
filter
({
active
:
true
});
return
wrapper
.
find
(
'TabPanel'
).
filter
({
active
:
true
});
}
}
it
(
'does not render a tabbed dialog if only share tab is provided'
,
()
=>
{
const
wrapper
=
createComponent
({
exportTab
:
false
,
importTab
:
false
});
assert
.
isFalse
(
wrapper
.
find
(
'TabHeader'
).
exists
());
});
[{
importTab
:
false
},
{
exportTab
:
false
},
{}].
forEach
(
props
=>
{
it
(
`renders a tabbed dialog when more than one tab is provided`
,
()
=>
{
const
wrapper
=
createComponent
(
props
);
assert
.
isTrue
(
wrapper
.
find
(
'TabHeader'
).
exists
());
assert
.
isTrue
(
wrapper
.
find
(
Tab
).
filter
(
'[aria-controls="share-panel"]'
).
props
()
.
selected
,
);
assert
.
isTrue
(
wrapper
.
find
(
'TabPanel[id="share-panel"]'
).
props
().
active
);
});
});
it
(
'shows correct tab panel when each tab is clicked'
,
()
=>
{
it
(
'shows correct tab panel when each tab is clicked'
,
()
=>
{
const
wrapper
=
createComponent
();
const
wrapper
=
createComponent
();
...
@@ -111,22 +92,11 @@ describe('ShareDialog', () => {
...
@@ -111,22 +92,11 @@ describe('ShareDialog', () => {
assert
.
equal
(
activeTabPanel
(
wrapper
).
props
().
id
,
'share-panel'
);
assert
.
equal
(
activeTabPanel
(
wrapper
).
props
().
id
,
'share-panel'
);
});
});
it
(
'renders empty if no tabs should be displayed'
,
()
=>
{
const
wrapper
=
createComponent
({
shareTab
:
false
,
exportTab
:
false
,
importTab
:
false
,
});
assert
.
isFalse
(
wrapper
.
exists
(
'TabHeader'
));
assert
.
isFalse
(
wrapper
.
exists
(
'ShareAnnotations'
));
});
describe
(
'a11y'
,
()
=>
{
describe
(
'a11y'
,
()
=>
{
it
(
it
(
'should pass a11y checks'
,
'should pass a11y checks'
,
checkAccessibility
({
checkAccessibility
({
content
:
()
=>
<
ShareDialog
shareTab
exportTab
importTab
/>
,
content
:
()
=>
<
ShareDialog
shareTab
/>
,
}),
}),
);
);
});
});
...
...
src/sidebar/components/TopBar.tsx
View file @
91cc9775
...
@@ -17,8 +17,6 @@ import SearchIconButton from './search/SearchIconButton';
...
@@ -17,8 +17,6 @@ import SearchIconButton from './search/SearchIconButton';
import
StreamSearchInput
from
'./search/StreamSearchInput'
;
import
StreamSearchInput
from
'./search/StreamSearchInput'
;
export
type
TopBarProps
=
{
export
type
TopBarProps
=
{
showShareButton
:
boolean
;
/** Flag indicating whether the app is in a sidebar context */
/** Flag indicating whether the app is in a sidebar context */
isSidebar
:
boolean
;
isSidebar
:
boolean
;
...
@@ -47,7 +45,6 @@ function TopBar({
...
@@ -47,7 +45,6 @@ function TopBar({
onSignUp
,
onSignUp
,
frameSync
,
frameSync
,
settings
,
settings
,
showShareButton
,
}:
TopBarProps
)
{
}:
TopBarProps
)
{
const
loginLinkStyle
=
applyTheme
([
'accentColor'
],
settings
);
const
loginLinkStyle
=
applyTheme
([
'accentColor'
],
settings
);
...
@@ -108,7 +105,6 @@ function TopBar({
...
@@ -108,7 +105,6 @@ function TopBar({
)
}
)
}
{
searchPanelEnabled
&&
<
SearchIconButton
/>
}
{
searchPanelEnabled
&&
<
SearchIconButton
/>
}
<
SortMenu
/>
<
SortMenu
/>
{
showShareButton
&&
(
<
PressableIconButton
<
PressableIconButton
icon=
{
ShareIcon
}
icon=
{
ShareIcon
}
expanded=
{
isAnnotationsPanelOpen
}
expanded=
{
isAnnotationsPanelOpen
}
...
@@ -118,7 +114,6 @@ function TopBar({
...
@@ -118,7 +114,6 @@ function TopBar({
title=
"Share annotations on this page"
title=
"Share annotations on this page"
data
-
testid=
"share-icon-button"
data
-
testid=
"share-icon-button"
/>
/>
)
}
</>
</>
)
}
)
}
<
PressableIconButton
<
PressableIconButton
...
...
src/sidebar/components/test/HypothesisApp-test.js
View file @
91cc9775
...
@@ -408,23 +408,6 @@ describe('HypothesisApp', () => {
...
@@ -408,23 +408,6 @@ describe('HypothesisApp', () => {
});
});
});
});
context
(
'when there are no sharing tabs to show'
,
()
=>
{
beforeEach
(()
=>
{
fakeStore
.
isFeatureEnabled
.
returns
(
false
);
fakeIsThirdPartyService
.
returns
(
true
);
});
it
(
'does not render ShareDialog'
,
()
=>
{
const
wrapper
=
createComponent
();
assert
.
isFalse
(
wrapper
.
exists
(
'ShareDialog'
));
});
it
(
'disables share button in TopBar'
,
()
=>
{
const
wrapper
=
createComponent
();
assert
.
isFalse
(
wrapper
.
find
(
'TopBar'
).
prop
(
'showShareButton'
));
});
});
describe
(
'search panel'
,
()
=>
{
describe
(
'search panel'
,
()
=>
{
[
true
,
false
].
forEach
(
searchPanelEnabled
=>
{
[
true
,
false
].
forEach
(
searchPanelEnabled
=>
{
it
(
'renders SearchPanel when feature is enabled'
,
()
=>
{
it
(
'renders SearchPanel when feature is enabled'
,
()
=>
{
...
...
src/sidebar/components/test/TopBar-test.js
View file @
91cc9775
...
@@ -65,7 +65,6 @@ describe('TopBar', () => {
...
@@ -65,7 +65,6 @@ describe('TopBar', () => {
isSidebar
=
{
true
}
isSidebar
=
{
true
}
settings
=
{
fakeSettings
}
settings
=
{
fakeSettings
}
streamer
=
{
fakeStreamer
}
streamer
=
{
fakeStreamer
}
showShareButton
{...
props
}
{...
props
}
/>
,
/>
,
);
);
...
@@ -159,15 +158,6 @@ describe('TopBar', () => {
...
@@ -159,15 +158,6 @@ describe('TopBar', () => {
});
});
});
});
context
(
'when showShareButton is false'
,
()
=>
{
it
(
"doesn't show the share annotations button"
,
()
=>
{
const
wrapper
=
createTopBar
({
showShareButton
:
false
});
assert
.
isFalse
(
wrapper
.
exists
(
'[title="Share annotations on this page"]'
),
);
});
});
it
(
'toggles the share annotations panel when "Share" is clicked'
,
()
=>
{
it
(
'toggles the share annotations panel when "Share" is clicked'
,
()
=>
{
const
wrapper
=
createTopBar
();
const
wrapper
=
createTopBar
();
const
shareButton
=
getButton
(
wrapper
,
'share-icon-button'
);
const
shareButton
=
getButton
(
wrapper
,
'share-icon-button'
);
...
...
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