Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Add 'Install the browser extension' alert + animation #14399

Merged
merged 14 commits into from
Oct 8, 2020

Conversation

tjkandala
Copy link
Contributor

@tjkandala tjkandala commented Oct 5, 2020

Implements #14196.

TODO:

  • - Add alert
  • - CSS for animations
  • - Display different alert depending on browser
  • - Integration tests
  • - Snapshots for new components

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #14399 into tj/code-host-popup will increase coverage by 3.25%.
The diff coverage is 84.50%.

@@                  Coverage Diff                   @@
##           tj/code-host-popup   #14399      +/-   ##
======================================================
+ Coverage               50.25%   53.51%   +3.25%     
======================================================
  Files                    1528     1402     -126     
  Lines                   77627    74292    -3335     
  Branches                 6916     5455    -1461     
======================================================
+ Hits                    39014    39758     +744     
+ Misses                  34963    30926    -4037     
+ Partials                 3650     3608      -42     
Flag Coverage Δ
#go 52.21% <ø> (+<0.01%) ⬆️
#integration 31.26% <78.87%> (+0.15%) ⬆️
#storybook 18.15% <58.46%> (+0.10%) ⬆️
#typescript 57.26% <84.50%> (+11.78%) ⬆️
#unit 54.56% <ø> (+23.33%) ⬆️
Impacted Files Coverage Δ
web/src/nav/GlobalNavbar.tsx 94.59% <ø> (-0.15%) ⬇️
web/src/nav/NavLinks.tsx 91.66% <ø> (-4.17%) ⬇️
web/src/routes.tsx 44.00% <ø> (ø)
web/src/nav/UserNavItem.tsx 82.25% <82.25%> (+6.39%) ⬆️
web/src/Layout.tsx 90.69% <100.00%> (+2.89%) ⬆️
web/src/repo/RepoContainer.tsx 77.31% <100.00%> (+0.72%) ⬆️
web/src/user/UserAvatar.tsx 90.90% <100.00%> (+0.90%) ⬆️
web/src/enterprise/productSubscription/helpers.ts 0.00% <0.00%> (-100.00%) ⬇️
web/src/extensions/ExtensionPermissionModal.tsx 16.66% <0.00%> (-83.34%) ⬇️
web/src/search/FilterChip.tsx 0.00% <0.00%> (-76.00%) ⬇️
... and 306 more

web/src/nav/UserNavItem.tsx Outdated Show resolved Hide resolved
@tjkandala tjkandala requested review from a team and removed request for a team October 5, 2020 00:21
@tjkandala
Copy link
Contributor Author

extanim

I added a small timeout after the 5th hover to prevent layout shift before the user has a chance to read hover content.

@AlicjaSuska I temporarily implemented only the timing portion of the background animation for user avatars. How should the animation look when the avatar isn't set?

I noticed that it took a lot of steps to enable the popover after it's dismissed, so I added some functions to the Window object to make this PR easier to play with:

  • onExtensionAlertDismissed: Triggers the tooltip + avatar animation
  • showExtensionAlert: Displays alert

@felixfbecker
Copy link
Contributor

That layout shift seems bad, I'm worried that it would cause the alert to be perceived as annoying and be clicked away. This of course was only caused by the change to count the hovers instead of just counting days, where it would only appear on page load. I think we can have the best of both worlds by not showing the alert immediately, but only storing the hover count and only showing the alert on a page load/initial render.

@sourcegraph sourcegraph deleted a comment from felixfbecker Oct 6, 2020
@tjkandala
Copy link
Contributor Author

Animation w/ default icon (no profile picture set)
Animation w/ profile picture

@tjkandala tjkandala marked this pull request as ready for review October 6, 2020 22:53
}

localStorage.setItem(HOVER_COUNT_KEY, count.toString(10))
}, [])

// DEBUG
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove after design review

Comment on lines 171 to 176
// DEBUG
useEffect(() => {
// eslint-disable-next-line
;(window as any).onExtensionAlertDismissed = onExtensionAlertDismissed
}, [onExtensionAlertDismissed])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove after design review

Comment on lines 266 to +268
await driver.page.goto(`${driver.sourcegraphBaseUrl}/github.com/sourcegraph/test/-/blob/test.ts`)
// TODO
await driver.page.evaluate(HOVER_COUNT_KEY => localStorage.removeItem(HOVER_COUNT_KEY), HOVER_COUNT_KEY)
await driver.page.reload()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to clear localStorage before each test? Clearing it in page.evaluateOnNewDocument would break this test, since that would run on reload. There may be a solution with request interception.

Fwiw, the test still passed every time I ran it without reloading after clearing localStorage. I just want to eliminate any possibility of flakiness.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is all I can think of - would ensure 100% reproducability:

beforeEach(async () => {
  await driver.page.evaluate(() => localStorage.clear())
})

@tjkandala tjkandala requested review from AlicjaSuska and a team October 8, 2020 01:59
@tjkandala tjkandala linked an issue Oct 8, 2020 that may be closed by this pull request
@AlicjaSuska
Copy link
Contributor

@tjkandala

@felixfbecker
Copy link
Contributor

@tjkandala the build is broken on this, could you fix?

@tjkandala tjkandala merged this pull request into tj/code-host-popup Oct 8, 2020
@tjkandala tjkandala deleted the tj/install-alert branch October 8, 2020 22:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'Install the browser extension' alert, remove the popup
3 participants