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
a8146c9e
Commit
a8146c9e
authored
Jul 25, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jul 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `ShareAnnotationsPanel` => `ShareDialog`
parent
ffa32aa9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
41 deletions
+40
-41
HypothesisApp.tsx
src/sidebar/components/HypothesisApp.tsx
+2
-2
ShareDialog.tsx
src/sidebar/components/ShareDialog/ShareDialog.tsx
+10
-10
index.ts
src/sidebar/components/ShareDialog/index.ts
+1
-0
ShareDialog-test.js
src/sidebar/components/ShareDialog/test/ShareDialog-test.js
+27
-29
No files found.
src/sidebar/components/HypothesisApp.tsx
View file @
a8146c9e
...
@@ -16,7 +16,7 @@ import AnnotationView from './AnnotationView';
...
@@ -16,7 +16,7 @@ import AnnotationView from './AnnotationView';
import
HelpPanel
from
'./HelpPanel'
;
import
HelpPanel
from
'./HelpPanel'
;
import
NotebookView
from
'./NotebookView'
;
import
NotebookView
from
'./NotebookView'
;
import
ProfileView
from
'./ProfileView'
;
import
ProfileView
from
'./ProfileView'
;
import
Share
AnnotationsPanel
from
'./ShareAnnotationsPanel
'
;
import
Share
Dialog
from
'./ShareDialog
'
;
import
SidebarView
from
'./SidebarView'
;
import
SidebarView
from
'./SidebarView'
;
import
StreamView
from
'./StreamView'
;
import
StreamView
from
'./StreamView'
;
import
ToastMessages
from
'./ToastMessages'
;
import
ToastMessages
from
'./ToastMessages'
;
...
@@ -160,7 +160,7 @@ function HypothesisApp({
...
@@ -160,7 +160,7 @@ function HypothesisApp({
<
div
className=
"container"
>
<
div
className=
"container"
>
<
ToastMessages
/>
<
ToastMessages
/>
<
HelpPanel
/>
<
HelpPanel
/>
<
Share
AnnotationsPanel
/>
<
Share
Dialog
/>
{
route
&&
(
{
route
&&
(
<
main
>
<
main
>
...
...
src/sidebar/components/Share
AnnotationsPanel
.tsx
→
src/sidebar/components/Share
Dialog/ShareDialog
.tsx
View file @
a8146c9e
...
@@ -17,13 +17,13 @@ import classnames from 'classnames';
...
@@ -17,13 +17,13 @@ import classnames from 'classnames';
import
type
{
ComponentChildren
,
JSX
}
from
'preact'
;
import
type
{
ComponentChildren
,
JSX
}
from
'preact'
;
import
{
useCallback
,
useState
}
from
'preact/hooks'
;
import
{
useCallback
,
useState
}
from
'preact/hooks'
;
import
{
pageSharingLink
}
from
'../helpers/annotation-sharing'
;
import
{
pageSharingLink
}
from
'../
../
helpers/annotation-sharing'
;
import
{
withServices
}
from
'../service-context'
;
import
{
withServices
}
from
'../
../
service-context'
;
import
type
{
ToastMessengerService
}
from
'../services/toast-messenger'
;
import
type
{
ToastMessengerService
}
from
'../
../
services/toast-messenger'
;
import
{
useSidebarStore
}
from
'../store'
;
import
{
useSidebarStore
}
from
'../
../
store'
;
import
{
copyText
}
from
'../util/copy-to-clipboard'
;
import
{
copyText
}
from
'../
../
util/copy-to-clipboard'
;
import
ShareLinks
from
'./ShareLinks'
;
import
ShareLinks
from
'.
.
/ShareLinks'
;
import
SidebarPanel
from
'./SidebarPanel'
;
import
SidebarPanel
from
'.
.
/SidebarPanel'
;
function
LoadingSpinner
()
{
function
LoadingSpinner
()
{
return
(
return
(
...
@@ -213,7 +213,7 @@ function ExportPanelContent({
...
@@ -213,7 +213,7 @@ function ExportPanelContent({
);
);
}
}
export
type
Share
AnnotationPanel
Props
=
{
export
type
Share
Dialog
Props
=
{
// injected
// injected
toastMessenger
:
ToastMessengerService
;
toastMessenger
:
ToastMessengerService
;
};
};
...
@@ -225,7 +225,7 @@ export type ShareAnnotationPanelProps = {
...
@@ -225,7 +225,7 @@ export type ShareAnnotationPanelProps = {
* are on the current page (as defined by the main frame's URI) and contained
* are on the current page (as defined by the main frame's URI) and contained
* within the app's currently-focused group.
* within the app's currently-focused group.
*/
*/
function
Share
AnnotationsPanel
({
toastMessenger
}:
ShareAnnotationPanel
Props
)
{
function
Share
Dialog
({
toastMessenger
}:
ShareDialog
Props
)
{
const
store
=
useSidebarStore
();
const
store
=
useSidebarStore
();
const
mainFrame
=
store
.
mainFrame
();
const
mainFrame
=
store
.
mainFrame
();
const
focusedGroup
=
store
.
focusedGroup
();
const
focusedGroup
=
store
.
focusedGroup
();
...
@@ -329,4 +329,4 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
...
@@ -329,4 +329,4 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
);
);
}
}
export
default
withServices
(
Share
AnnotationsPanel
,
[
'toastMessenger'
]);
export
default
withServices
(
Share
Dialog
,
[
'toastMessenger'
]);
src/sidebar/components/ShareDialog/index.ts
0 → 100644
View file @
a8146c9e
export
{
default
}
from
'./ShareDialog'
;
src/sidebar/components/
test/ShareAnnotationsPanel
-test.js
→
src/sidebar/components/
ShareDialog/test/ShareDialog
-test.js
View file @
a8146c9e
import
{
mount
}
from
'enzyme'
;
import
{
mount
}
from
'enzyme'
;
import
{
act
}
from
'preact/test-utils'
;
import
{
act
}
from
'preact/test-utils'
;
import
{
checkAccessibility
}
from
'../../../test-util/accessibility'
;
import
{
checkAccessibility
}
from
'../../../
../
test-util/accessibility'
;
import
{
mockImportedComponents
}
from
'../../../test-util/mock-imported-components'
;
import
{
mockImportedComponents
}
from
'../../../
../
test-util/mock-imported-components'
;
import
Share
AnnotationsPanel
from
'../ShareAnnotationsPanel
'
;
import
Share
Dialog
from
'../ShareDialog
'
;
import
{
$imports
}
from
'../Share
AnnotationsPanel
'
;
import
{
$imports
}
from
'../Share
Dialog
'
;
describe
(
'Share
AnnotationsPanel
'
,
()
=>
{
describe
(
'Share
Dialog
'
,
()
=>
{
let
fakeStore
;
let
fakeStore
;
let
fakeBouncerLink
;
let
fakeBouncerLink
;
let
fakePageSharingLink
;
let
fakePageSharingLink
;
...
@@ -19,10 +19,8 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -19,10 +19,8 @@ describe('ShareAnnotationsPanel', () => {
id
:
'testprivate'
,
id
:
'testprivate'
,
};
};
const
createShareAnnotationsPanel
=
props
=>
const
createComponent
=
props
=>
mount
(
mount
(
<
ShareDialog
toastMessenger
=
{
fakeToastMessenger
}
{...
props
}
/>
)
;
<
ShareAnnotationsPanel
toastMessenger
=
{
fakeToastMessenger
}
{...
props
}
/
>
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
fakeBouncerLink
=
'http://hyp.is/go?url=http%3A%2F%2Fwww.example.com'
;
fakeBouncerLink
=
'http://hyp.is/go?url=http%3A%2F%2Fwww.example.com'
;
...
@@ -48,11 +46,11 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -48,11 +46,11 @@ describe('ShareAnnotationsPanel', () => {
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
({
$imports
.
$mock
({
'../store'
:
{
useSidebarStore
:
()
=>
fakeStore
},
'../
../
store'
:
{
useSidebarStore
:
()
=>
fakeStore
},
'../helpers/annotation-sharing'
:
{
'../
../
helpers/annotation-sharing'
:
{
pageSharingLink
:
fakePageSharingLink
,
pageSharingLink
:
fakePageSharingLink
,
},
},
'../util/copy-to-clipboard'
:
fakeCopyToClipboard
,
'../
../
util/copy-to-clipboard'
:
fakeCopyToClipboard
,
});
});
});
});
...
@@ -62,7 +60,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -62,7 +60,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'panel dialog title'
,
()
=>
{
describe
(
'panel dialog title'
,
()
=>
{
it
(
"sets sidebar panel dialog title to include group's name"
,
()
=>
{
it
(
"sets sidebar panel dialog title to include group's name"
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
equal
(
assert
.
equal
(
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
...
@@ -73,7 +71,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -73,7 +71,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'sets a temporary title if focused group not available'
,
()
=>
{
it
(
'sets a temporary title if focused group not available'
,
()
=>
{
fakeStore
.
focusedGroup
=
sinon
.
stub
().
returns
({});
fakeStore
.
focusedGroup
=
sinon
.
stub
().
returns
({});
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
equal
(
assert
.
equal
(
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
'Share Annotations in ...'
'Share Annotations in ...'
...
@@ -85,19 +83,19 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -85,19 +83,19 @@ describe('ShareAnnotationsPanel', () => {
it
(
'does not render share panel content if needed info not available'
,
()
=>
{
it
(
'does not render share panel content if needed info not available'
,
()
=>
{
fakeStore
.
focusedGroup
.
returns
(
undefined
);
fakeStore
.
focusedGroup
.
returns
(
undefined
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isFalse
(
wrapper
.
exists
(
'.ShareAnnotationsPanel'
));
assert
.
isFalse
(
wrapper
.
exists
(
'.ShareAnnotationsPanel'
));
});
});
it
(
'renders a spinner if focused group not available yet'
,
()
=>
{
it
(
'renders a spinner if focused group not available yet'
,
()
=>
{
fakeStore
.
focusedGroup
.
returns
(
undefined
);
fakeStore
.
focusedGroup
.
returns
(
undefined
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isTrue
(
wrapper
.
find
(
'Spinner'
).
exists
());
assert
.
isTrue
(
wrapper
.
find
(
'Spinner'
).
exists
());
});
});
it
(
'renders panel content if needed info available'
,
()
=>
{
it
(
'renders panel content if needed info available'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isFalse
(
wrapper
.
find
(
'Spinner'
).
exists
());
assert
.
isFalse
(
wrapper
.
find
(
'Spinner'
).
exists
());
});
});
});
});
...
@@ -129,7 +127,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -129,7 +127,7 @@ describe('ShareAnnotationsPanel', () => {
id
:
'testid,'
,
id
:
'testid,'
,
});
});
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
match
(
assert
.
match
(
wrapper
.
find
(
'[data-testid="sharing-intro"]'
).
text
(),
wrapper
.
find
(
'[data-testid="sharing-intro"]'
).
text
(),
...
@@ -146,7 +144,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -146,7 +144,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'renders explanatory text about inability to share'
,
()
=>
{
it
(
'renders explanatory text about inability to share'
,
()
=>
{
fakePageSharingLink
.
returns
(
null
);
fakePageSharingLink
.
returns
(
null
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
panelEl
=
wrapper
.
find
(
'[data-testid="no-sharing"]'
);
const
panelEl
=
wrapper
.
find
(
'[data-testid="no-sharing"]'
);
assert
.
include
(
panelEl
.
text
(),
'These annotations cannot be shared'
);
assert
.
include
(
panelEl
.
text
(),
'These annotations cannot be shared'
);
...
@@ -156,7 +154,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -156,7 +154,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'web share link'
,
()
=>
{
describe
(
'web share link'
,
()
=>
{
it
(
'displays web share link in readonly form input'
,
()
=>
{
it
(
'displays web share link in readonly form input'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
inputEl
=
wrapper
.
find
(
'input'
);
const
inputEl
=
wrapper
.
find
(
'input'
);
assert
.
equal
(
inputEl
.
prop
(
'value'
),
fakeBouncerLink
);
assert
.
equal
(
inputEl
.
prop
(
'value'
),
fakeBouncerLink
);
...
@@ -166,7 +164,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -166,7 +164,7 @@ describe('ShareAnnotationsPanel', () => {
context
(
'document URI cannot be shared'
,
()
=>
{
context
(
'document URI cannot be shared'
,
()
=>
{
it
(
'does not render an input field with share link'
,
()
=>
{
it
(
'does not render an input field with share link'
,
()
=>
{
fakePageSharingLink
.
returns
(
null
);
fakePageSharingLink
.
returns
(
null
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
inputEl
=
wrapper
.
find
(
'input'
);
const
inputEl
=
wrapper
.
find
(
'input'
);
assert
.
isFalse
(
inputEl
.
exists
());
assert
.
isFalse
(
inputEl
.
exists
());
...
@@ -175,7 +173,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -175,7 +173,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'copy link to clipboard'
,
()
=>
{
describe
(
'copy link to clipboard'
,
()
=>
{
it
(
'copies link to clipboard when copy button clicked'
,
()
=>
{
it
(
'copies link to clipboard when copy button clicked'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
@@ -183,7 +181,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -183,7 +181,7 @@ describe('ShareAnnotationsPanel', () => {
});
});
it
(
'confirms link copy when successful'
,
()
=>
{
it
(
'confirms link copy when successful'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
@@ -195,7 +193,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -195,7 +193,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'flashes an error if link copying unsuccessful'
,
()
=>
{
it
(
'flashes an error if link copying unsuccessful'
,
()
=>
{
fakeCopyToClipboard
.
copyText
.
throws
();
fakeCopyToClipboard
.
copyText
.
throws
();
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
@@ -206,7 +204,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -206,7 +204,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'tabbed dialog panel'
,
()
=>
{
describe
(
'tabbed dialog panel'
,
()
=>
{
it
(
'does not render a tabbed dialog if export feature flag is not enabled'
,
()
=>
{
it
(
'does not render a tabbed dialog if export feature flag is not enabled'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isFalse
(
wrapper
.
find
(
'TabHeader'
).
exists
());
assert
.
isFalse
(
wrapper
.
find
(
'TabHeader'
).
exists
());
});
});
...
@@ -217,7 +215,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -217,7 +215,7 @@ describe('ShareAnnotationsPanel', () => {
});
});
it
(
'renders a tabbed dialog with share panel active'
,
()
=>
{
it
(
'renders a tabbed dialog with share panel active'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isTrue
(
wrapper
.
find
(
'TabHeader'
).
exists
());
assert
.
isTrue
(
wrapper
.
find
(
'TabHeader'
).
exists
());
assert
.
isTrue
(
assert
.
isTrue
(
...
@@ -229,7 +227,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -229,7 +227,7 @@ describe('ShareAnnotationsPanel', () => {
});
});
it
(
'shows the export tab panel when export tab clicked'
,
()
=>
{
it
(
'shows the export tab panel when export tab clicked'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
shareTabSelector
=
'Tab[aria-controls="share-panel"]'
;
const
shareTabSelector
=
'Tab[aria-controls="share-panel"]'
;
const
exportTabSelector
=
'Tab[aria-controls="export-panel"]'
;
const
exportTabSelector
=
'Tab[aria-controls="export-panel"]'
;
...
@@ -265,7 +263,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -265,7 +263,7 @@ describe('ShareAnnotationsPanel', () => {
});
});
it
(
'shows a loading indicator on the export tab if not ready'
,
()
=>
{
it
(
'shows a loading indicator on the export tab if not ready'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
exportTabSelector
=
'Tab[aria-controls="export-panel"]'
;
const
exportTabSelector
=
'Tab[aria-controls="export-panel"]'
;
fakeStore
.
isLoading
.
returns
(
true
);
fakeStore
.
isLoading
.
returns
(
true
);
...
@@ -293,7 +291,7 @@ describe('ShareAnnotationsPanel', () => {
...
@@ -293,7 +291,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
it
(
'should pass a11y checks'
,
'should pass a11y checks'
,
checkAccessibility
({
checkAccessibility
({
content
:
()
=>
create
ShareAnnotationsPanel
(),
content
:
()
=>
create
Component
(),
})
})
);
);
});
});
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