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';
import
HelpPanel
from
'./HelpPanel'
;
import
NotebookView
from
'./NotebookView'
;
import
ProfileView
from
'./ProfileView'
;
import
Share
AnnotationsPanel
from
'./ShareAnnotationsPanel
'
;
import
Share
Dialog
from
'./ShareDialog
'
;
import
SidebarView
from
'./SidebarView'
;
import
StreamView
from
'./StreamView'
;
import
ToastMessages
from
'./ToastMessages'
;
...
...
@@ -160,7 +160,7 @@ function HypothesisApp({
<
div
className=
"container"
>
<
ToastMessages
/>
<
HelpPanel
/>
<
Share
AnnotationsPanel
/>
<
Share
Dialog
/>
{
route
&&
(
<
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';
import
type
{
ComponentChildren
,
JSX
}
from
'preact'
;
import
{
useCallback
,
useState
}
from
'preact/hooks'
;
import
{
pageSharingLink
}
from
'../helpers/annotation-sharing'
;
import
{
withServices
}
from
'../service-context'
;
import
type
{
ToastMessengerService
}
from
'../services/toast-messenger'
;
import
{
useSidebarStore
}
from
'../store'
;
import
{
copyText
}
from
'../util/copy-to-clipboard'
;
import
ShareLinks
from
'./ShareLinks'
;
import
SidebarPanel
from
'./SidebarPanel'
;
import
{
pageSharingLink
}
from
'../
../
helpers/annotation-sharing'
;
import
{
withServices
}
from
'../
../
service-context'
;
import
type
{
ToastMessengerService
}
from
'../
../
services/toast-messenger'
;
import
{
useSidebarStore
}
from
'../
../
store'
;
import
{
copyText
}
from
'../
../
util/copy-to-clipboard'
;
import
ShareLinks
from
'.
.
/ShareLinks'
;
import
SidebarPanel
from
'.
.
/SidebarPanel'
;
function
LoadingSpinner
()
{
return
(
...
...
@@ -213,7 +213,7 @@ function ExportPanelContent({
);
}
export
type
Share
AnnotationPanel
Props
=
{
export
type
Share
Dialog
Props
=
{
// injected
toastMessenger
:
ToastMessengerService
;
};
...
...
@@ -225,7 +225,7 @@ export type ShareAnnotationPanelProps = {
* are on the current page (as defined by the main frame's URI) and contained
* within the app's currently-focused group.
*/
function
Share
AnnotationsPanel
({
toastMessenger
}:
ShareAnnotationPanel
Props
)
{
function
Share
Dialog
({
toastMessenger
}:
ShareDialog
Props
)
{
const
store
=
useSidebarStore
();
const
mainFrame
=
store
.
mainFrame
();
const
focusedGroup
=
store
.
focusedGroup
();
...
...
@@ -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
{
act
}
from
'preact/test-utils'
;
import
{
checkAccessibility
}
from
'../../../test-util/accessibility'
;
import
{
mockImportedComponents
}
from
'../../../test-util/mock-imported-components'
;
import
Share
AnnotationsPanel
from
'../ShareAnnotationsPanel
'
;
import
{
$imports
}
from
'../Share
AnnotationsPanel
'
;
import
{
checkAccessibility
}
from
'../../../
../
test-util/accessibility'
;
import
{
mockImportedComponents
}
from
'../../../
../
test-util/mock-imported-components'
;
import
Share
Dialog
from
'../ShareDialog
'
;
import
{
$imports
}
from
'../Share
Dialog
'
;
describe
(
'Share
AnnotationsPanel
'
,
()
=>
{
describe
(
'Share
Dialog
'
,
()
=>
{
let
fakeStore
;
let
fakeBouncerLink
;
let
fakePageSharingLink
;
...
...
@@ -19,10 +19,8 @@ describe('ShareAnnotationsPanel', () => {
id
:
'testprivate'
,
};
const
createShareAnnotationsPanel
=
props
=>
mount
(
<
ShareAnnotationsPanel
toastMessenger
=
{
fakeToastMessenger
}
{...
props
}
/
>
);
const
createComponent
=
props
=>
mount
(
<
ShareDialog
toastMessenger
=
{
fakeToastMessenger
}
{...
props
}
/>
)
;
beforeEach
(()
=>
{
fakeBouncerLink
=
'http://hyp.is/go?url=http%3A%2F%2Fwww.example.com'
;
...
...
@@ -48,11 +46,11 @@ describe('ShareAnnotationsPanel', () => {
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
({
'../store'
:
{
useSidebarStore
:
()
=>
fakeStore
},
'../helpers/annotation-sharing'
:
{
'../
../
store'
:
{
useSidebarStore
:
()
=>
fakeStore
},
'../
../
helpers/annotation-sharing'
:
{
pageSharingLink
:
fakePageSharingLink
,
},
'../util/copy-to-clipboard'
:
fakeCopyToClipboard
,
'../
../
util/copy-to-clipboard'
:
fakeCopyToClipboard
,
});
});
...
...
@@ -62,7 +60,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'panel dialog title'
,
()
=>
{
it
(
"sets sidebar panel dialog title to include group's name"
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
equal
(
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
...
...
@@ -73,7 +71,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'sets a temporary title if focused group not available'
,
()
=>
{
fakeStore
.
focusedGroup
=
sinon
.
stub
().
returns
({});
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
equal
(
wrapper
.
find
(
'SidebarPanel'
).
prop
(
'title'
),
'Share Annotations in ...'
...
...
@@ -85,19 +83,19 @@ describe('ShareAnnotationsPanel', () => {
it
(
'does not render share panel content if needed info not available'
,
()
=>
{
fakeStore
.
focusedGroup
.
returns
(
undefined
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isFalse
(
wrapper
.
exists
(
'.ShareAnnotationsPanel'
));
});
it
(
'renders a spinner if focused group not available yet'
,
()
=>
{
fakeStore
.
focusedGroup
.
returns
(
undefined
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isTrue
(
wrapper
.
find
(
'Spinner'
).
exists
());
});
it
(
'renders panel content if needed info available'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
isFalse
(
wrapper
.
find
(
'Spinner'
).
exists
());
});
});
...
...
@@ -129,7 +127,7 @@ describe('ShareAnnotationsPanel', () => {
id
:
'testid,'
,
});
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
assert
.
match
(
wrapper
.
find
(
'[data-testid="sharing-intro"]'
).
text
(),
...
...
@@ -146,7 +144,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'renders explanatory text about inability to share'
,
()
=>
{
fakePageSharingLink
.
returns
(
null
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
panelEl
=
wrapper
.
find
(
'[data-testid="no-sharing"]'
);
assert
.
include
(
panelEl
.
text
(),
'These annotations cannot be shared'
);
...
...
@@ -156,7 +154,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'web share link'
,
()
=>
{
it
(
'displays web share link in readonly form input'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
inputEl
=
wrapper
.
find
(
'input'
);
assert
.
equal
(
inputEl
.
prop
(
'value'
),
fakeBouncerLink
);
...
...
@@ -166,7 +164,7 @@ describe('ShareAnnotationsPanel', () => {
context
(
'document URI cannot be shared'
,
()
=>
{
it
(
'does not render an input field with share link'
,
()
=>
{
fakePageSharingLink
.
returns
(
null
);
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
const
inputEl
=
wrapper
.
find
(
'input'
);
assert
.
isFalse
(
inputEl
.
exists
());
...
...
@@ -175,7 +173,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'copy link to clipboard'
,
()
=>
{
it
(
'copies link to clipboard when copy button clicked'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
...
@@ -183,7 +181,7 @@ describe('ShareAnnotationsPanel', () => {
});
it
(
'confirms link copy when successful'
,
()
=>
{
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
...
@@ -195,7 +193,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'flashes an error if link copying unsuccessful'
,
()
=>
{
fakeCopyToClipboard
.
copyText
.
throws
();
const
wrapper
=
create
ShareAnnotationsPanel
();
const
wrapper
=
create
Component
();
wrapper
.
find
(
'IconButton'
).
props
().
onClick
();
...
...
@@ -206,7 +204,7 @@ describe('ShareAnnotationsPanel', () => {
describe
(
'tabbed dialog panel'
,
()
=>
{
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
());
});
...
...
@@ -217,7 +215,7 @@ describe('ShareAnnotationsPanel', () => {
});
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
(
...
...
@@ -229,7 +227,7 @@ describe('ShareAnnotationsPanel', () => {
});
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
exportTabSelector
=
'Tab[aria-controls="export-panel"]'
;
...
...
@@ -265,7 +263,7 @@ describe('ShareAnnotationsPanel', () => {
});
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"]'
;
fakeStore
.
isLoading
.
returns
(
true
);
...
...
@@ -293,7 +291,7 @@ describe('ShareAnnotationsPanel', () => {
it
(
'should pass a11y checks'
,
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