Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a UI path for sharing when a page's or annotation's URI is not web-accessible #2874

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

lyzadanger
Copy link
Contributor

There has been some (understandable) ongoing confusion around share links for single annotations or sets of annotations that pertain to a URI that is not available on the web. Specifically, it's confusing if one annotates a local PDF and then attempts to share a single annotation or a set of annotations on that PDF. Before these changes, the application would happily cook up a bouncer (sharing) link for you, but that link wouldn't do anything useful.

This PR replaces #2871

With these changes...

These changes create a new UI path for both "share this page's annotations" and "share this annotation" when the page's URI or the annotation's URI (respectively) are not web-accessible.

When the page's URI is not web-accessible, using the share-this-page's-annotations button will now result in:

image

When an annotation's URI is not web-accessible, using the share-this-annotation button will now result in:

image

The link provided, as explained, will go to the single-annotation view.

The "panel" that the share-this-annotation content shows up in has been slightly widened—from 20em to 24em (with a max-width of 85vw to keep it from getting ungainly on narrow viewports). This accommodates the longer text needed to explain the not-available-in-context wording without risking that this panel on the first annotation in the list could overlap the top bar.

I manually tested that:

  • When built into the local extension, local PDF files appropriately get the new, unshareable treatment.
  • When built into the local extension, web-hosted PDF files still allow sharing correctly.

Fixes #2786

@klemay
Copy link
Contributor

klemay commented Jan 8, 2021

@lyzadanger nice & elegant solution, IMO! kudos!

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI changes look good. I left a few comments in the implementation. In particular:

  • It may be worth combining the pageSharingLink and isShareableURI functions
  • Should we still show the social media share links if the link is an HTML rather than in-context link?
  • What should the panel show if the document URI is not known yet (eg. because it is a PDF that is still loading)?

@@ -95,7 +98,7 @@ function ShareAnnotationsPanel({ analytics, toastMessenger }) {
) : (
<span>
Anyone using this link may view the annotations in the group{' '}
<em>{focusedGroup.name}</em>.
<em>{focusedGroup?.name}</em>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ? isn't needed any more.

src/sidebar/components/share-annotations-panel.js Outdated Show resolved Hide resolved
src/sidebar/components/share-annotations-panel.js Outdated Show resolved Hide resolved
src/sidebar/components/annotation-share-control.js Outdated Show resolved Hide resolved
src/sidebar/util/annotation-sharing.js Show resolved Hide resolved
src/styles/mixins/molecules.scss Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 12, 2021

Codecov Report

Merging #2874 (14ef85f) into master (bdb5a47) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2874   +/-   ##
=======================================
  Coverage   97.74%   97.75%           
=======================================
  Files         206      207    +1     
  Lines        7677     7693   +16     
  Branches     1694     1705   +11     
=======================================
+ Hits         7504     7520   +16     
  Misses        173      173           
Impacted Files Coverage Δ
src/sidebar/components/annotation-action-bar.js 100.00% <100.00%> (ø)
src/sidebar/components/annotation-share-control.js 100.00% <100.00%> (ø)
src/sidebar/components/share-annotations-panel.js 100.00% <100.00%> (ø)
src/sidebar/util/annotation-sharing.js 100.00% <100.00%> (ø)
src/sidebar/util/typing.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdb5a47...14ef85f. Read the comment docs.

@lyzadanger
Copy link
Contributor Author

@robertknight I've addressed this round of changes, involving:

  • Change in logic/state structure in ShareAnnotationsPanel. It had become convoluted and wonky in part because I was doing some back-bends to avoid typechecking complaints;
  • Relatedly, there is a new utility module with a notNull helper for places where typing is missing some clues about context
  • Pushed some logic about isShareableURI into getPageSharingLink as you suggested
  • Made isShareableURI case-insensitive
  • ShareAnnotationsPanel will now show a spinner while loading

image

@@ -59,55 +58,70 @@ function ShareAnnotationsPanel({ analytics, toastMessenger }) {
title={panelTitle}
panelName={uiConstants.PANEL_SHARE_ANNOTATIONS}
>
{focusedGroup && mainFrame && (
{!sharingReady && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope the states are more clear now. There is one top-level branch now: "is shiz loaded enough yet?" and one secondary branch when the answer is "yes": "Do we have a valid share URI?"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. If it gets significantly more complex in future that it might help to factor out a helper component in the same module.

@@ -19,4 +19,12 @@
&__icon-button {
@include buttons.button--input;
}

// FIXME: Centralize styling of different sizes of Spinner in a reusable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this: spinner sizing is a function of font sizing, as it is in ems (which is fine). At some point we should encapsulate some patterns here so that we have the right small set of defined spinner sizes. The spinner at the panel's font size was too small.

@lyzadanger
Copy link
Contributor Author

@robertknight I should point out two things that have not been addressed:

  • Pulling out analytics code
  • Showing sharing links when using the html link

Trying to bound the scope of this work, but if you feel passionately on either of these, let me know.

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few minor comments.

src/sidebar/components/annotation-action-bar.js Outdated Show resolved Hide resolved
src/sidebar/components/annotation-share-control.js Outdated Show resolved Hide resolved
@@ -59,55 +58,70 @@ function ShareAnnotationsPanel({ analytics, toastMessenger }) {
title={panelTitle}
panelName={uiConstants.PANEL_SHARE_ANNOTATIONS}
>
{focusedGroup && mainFrame && (
{!sharingReady && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. If it gets significantly more complex in future that it might help to factor out a helper component in the same module.

src/sidebar/util/annotation-sharing.js Outdated Show resolved Hide resolved
assert.isUndefined(sharingUtil.annotationSharingLink(fakeAnnotation));
});

it('returns `undefined` if no links on annotation', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this ever actually happen with the API or will it always set links but possibly leave the object empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know offhand.

src/sidebar/util/test/annotation-sharing-test.js Outdated Show resolved Hide resolved
src/sidebar/util/typing.js Outdated Show resolved Hide resolved
Add a typing utility module with a helper function to "cast" the input
so that TS understands that it is not null/undefined. This is useful
in situations where logic would prevent a reference from being empty
but TS can't follow that logic.
In both the share-this-annotation and share-this-page's-annotations
components, provide a UI path for when the annotation's URI or the
page's URI (respectively) are not web-available. That is, to be
"shareable in context", the URI in question needs to have an
`http:` or `https:` protocol.

For "share this page's annotations" when the page is not web-accessible,
explain why the page's annotations can't be shared in context and don't
provide a sharing link, as it won't work.

For "share this annotation," when the annotation's URI (document) isn't
web-accessible, provide some explanatory text about how it can't be
shared in-context, but provide a link to the single-annotation view,
when available.

These changes are intended to avoid confusion when users try to share an
annotation or a set of annotations that have been made on a local
(e.g. PDF) document.

Some SCSS patterns have also been adjusted to accommodate more flexible
styling of the share-single-annotation panel. The width of the compact
panel pattern has been increased slightly so that the new wording
variant for not-shareable-in-context single annotations doesn't risk
taking up too much vertical space.

Fixes #2786
@lyzadanger lyzadanger merged commit 53b3321 into master Jan 13, 2021
@lyzadanger lyzadanger deleted the local-sharing branch January 13, 2021 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Share panel generates invalid hyp.is / bouncer links for local PDF files
3 participants