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

Add alert for failed sidebar injection in extension console #4208

Merged
merged 8 commits into from
Sep 6, 2022

Conversation

mnholtz
Copy link
Collaborator

@mnholtz mnholtz commented Aug 31, 2022

What does this PR do?

Discussion

Outstanding issues:

  • Double-clicking/clicking the toolbar icon n times will produce n alerts displayed back-to-back after closing them
  • Why is there so much whitespace above the alert title?

Demo

Screen Shot 2022-09-02 at 3 25 25 PM

Screen.Recording.2022-09-02.at.3.22.41.PM.mov

Checklist

  • Add tests (not sure what to test here D:)
  • Designate a primary reviewer @fregante

Copy link
Contributor

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Double-clicking/clicking the toolbar icon n times will produce n alerts displayed back-to-back after closing them

Not preventable, but with regular notifications this isn't a big issue anymore.

Why is there so much whitespace above the alert title?

I think their UI expects an icon to appear but it doesn't actually pick it up. Also unfixable (other than displaying our own UI or just using notifications)

src/background/browserAction.ts Outdated Show resolved Hide resolved
src/background/browserAction.ts Outdated Show resolved Hide resolved
src/background/browserAction.ts Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2022

Codecov Report

Merging #4208 (90f5d75) into main (cd258ef) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #4208      +/-   ##
==========================================
- Coverage   48.46%   48.44%   -0.03%     
==========================================
  Files         876      878       +2     
  Lines       26073    26085      +12     
  Branches     5376     5379       +3     
==========================================
  Hits        12636    12636              
- Misses      12518    12530      +12     
  Partials      919      919              
Impacted Files Coverage Δ
src/background/browserAction.ts 0.00% <0.00%> (ø)
src/options/messenger/api.ts 0.00% <0.00%> (ø)
src/options/messenger/registration.ts 0.00% <0.00%> (ø)
src/options/options.tsx 0.00% <0.00%> (ø)
src/utils.ts 62.45% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

if (url.startsWith(optionsPage)) {
const keyboardShortcut = isMac() ? "Cmd+Opt+C" : "Ctrl+Shift+C";
notify.info(
{ tabId: tab.id, page: "any" },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fregante Is "any" ok here? Ran into an issue where the message would get "forwarded" if page was not specified.

Copy link
Contributor

Choose a reason for hiding this comment

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

Try page: "/options.html" but it should work even without it 🤔

"Any" broadcasts the message to all chrome-extension:// pages and the tabId is currently ignored. This means even the background page will get the message and throw an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed we never received tabId-only messages outside the content script so it's not supported:

We still need to change this or else tabId is ignored. I tried this and it works:

Suggested change
{ tabId: tab.id, page: "any" },
{ tabId: tab.id, page: "/options.html" },

@mnholtz mnholtz requested a review from fregante September 2, 2022 22:24
@mnholtz mnholtz marked this pull request as ready for review September 2, 2022 22:25
Copy link
Contributor

@fregante fregante left a comment

Choose a reason for hiding this comment

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

LGTM, except a couple of issues

`PixieBrix Tip 💜\n If you want to create a new blueprint, first navigate to the page you want to modify, then open PixieBrix in the DevTools (${keyboardShortcut}).`
);
}

// The URL might not be available in certain circumstances. This silences these
// cases and just treats them as "not allowed on this page"
await toggleSidebar(tab.id, String(tab.url));
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment should be moved to the first line of the function + url can be used here.

{ tabId: tab.id, page: "any" },
`PixieBrix Tip 💜\n If you want to create a new blueprint, first navigate to the page you want to modify, then open PixieBrix in the DevTools (${keyboardShortcut}).`
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We need a return here because no further action is necessary

@fregante
Copy link
Contributor

fregante commented Sep 3, 2022

  • I applied the suggested changes
  • extracted the message to facilitate future copy updates
  • avoided duplicate notifications by supplying a notification ID

text

@mnholtz mnholtz merged commit 3389ba6 into main Sep 6, 2022
@mnholtz mnholtz deleted the feature/4179_options_page_alert branch September 6, 2022 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add alert for failed sidebar injection on the options page
4 participants