Skip to content

feat: replaced download icon with cloud icon#708

Merged
ivelin merged 9 commits intoambianic:masterfrom
vickywane:update/connection-icon
Sep 3, 2021
Merged

feat: replaced download icon with cloud icon#708
ivelin merged 9 commits intoambianic:masterfrom
vickywane:update/connection-icon

Conversation

@vickywane
Copy link
Contributor

@vickywane vickywane commented Aug 22, 2021

Purpose

This pull request will fix this issue here.

Approach

New code within this pull request changes the download-off icon to a cloud-off icon to better depict the connection status of the PWA to an edge device

Resolved TODOs within this pull request

  • Implement color coding of the new icon
  • Write sufficient unit tests based on the connection status

Merge Checklist

  • The code change is tested and works locally.
  • The user and dev documentation is up to date.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

@gitpod-io
Copy link

gitpod-io bot commented Aug 22, 2021

@commit-lint
Copy link
Contributor

commit-lint bot commented Aug 22, 2021

Features

  • replaced download icon with cloud icon (6870ca2)

Bug Fixes

Contributors

vickywane

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@vickywane
Copy link
Contributor Author

@ivelin

I have implemented the basic feature request to replace the download-off icon with the cloud-off icon.

However, I will need some further clarifications to enable me implement the pending items on this pull request.

  • What's the color code to be used to reflect the connection states?
  • What are the texts to be used in the tooltips for the connection states?
  • Should the icon be displayed when a connection is established?

@ivelin
Copy link
Contributor

ivelin commented Aug 22, 2021

@ivelin

I have implemented the basic feature request to replace the download-off icon with the cloud-off icon.

However, I will need some further clarifications to enable me implement the pending items on this pull request.

  • What's the color code to be used to reflect the connection states?
  • What are the texts to be used in the tooltips for the connection states?
  • Should the icon be displayed when a connection is established?

All good questions. Here is my recommendations:

  • What's the color code to be used to reflect the connection states?

Regular color codes. Primary color as with the other informative icons on the nav bar.

Optional:

  • pop-up a temporary text message with a warning color "Edge device connection lost. Reconnecting...".
  • pop-up a temporary text message with an info color "Edge device connection established."

Side note:
It seems like v-snackbar is the recommended vuetify component for application-wide user messages, while v-alert is the way to go for component scoped alerts. Related resources:

  • What are the texts to be used in the tooltips for the connection states?

Tooltips can have the same text as the pop-up messages above.

  • Should the icon be displayed when a connection is established?

I don't think so. Since this is the normal behavior most of the time, it will be unnecessary clutter.

Optional: display cloud-on icon for a few moments and then hide it.

@ivelin ivelin marked this pull request as draft August 22, 2021 18:50
@pull-request-size pull-request-size bot added size/L and removed size/M labels Aug 23, 2021
@vickywane vickywane marked this pull request as ready for review August 23, 2021 15:30
@vickywane
Copy link
Contributor Author

@ivelin I have just implemented the Snackbar component and displayed it in the timeline component.

The cloud icon and Snackbar responds to the PEER_CONNECTED, PEER_DISCONNECTED, PEER_CONNECTING states.
When in PEER_CONNECTING, the cloud icon changes to the cloud-sync icon type to indicate the state.

@vickywane vickywane requested a review from ivelin August 23, 2021 15:33
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

@vickywane nice work! See a couple of cosmetic comments.

@vickywane
Copy link
Contributor Author

@ivelin I just addressed all the last comments; making the snackbar standalone, moving it to the App component and also correcting the displayed texts.

@vickywane vickywane requested a review from ivelin August 23, 2021 20:31
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

@vickywane UI behavior seems correct. I made a comment about consistency of pop-up/snackbar messages with tooltips.

Also, see if you can improve the snackbar UX. Seems to have a bit too much empty space around the text. Also as a best practice we should show an X or a Close button to allow users to manually close it before the timeout period if they choose to.

@ivelin
Copy link
Contributor

ivelin commented Aug 24, 2021

Screen Shot 2021-08-24 at 10 42 59 AM

Screen Shot 2021-08-24 at 10 43 02 AM

Screen Shot 2021-08-24 at 10 45 01 AM
Screen Shot 2021-08-24 at 10 44 43 AM
Screen Shot 2021-08-24 at 10 44 23 AM
Screen Shot 2021-08-24 at 10 44 14 AM

@vickywane vickywane force-pushed the update/connection-icon branch from 01ccc70 to 6870ca2 Compare August 24, 2021 20:49
@vickywane vickywane requested a review from ivelin August 25, 2021 03:39
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

Almost there. A couple of new comments came up.

@@ -0,0 +1,82 @@
<template>
<div id="ConnectionStatusSnack-ctn">
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane this component shows its current snackbar message each time a new page is loaded. Try going from Timeline to Settings to About and see what happens. Once a message is shown, some flag should clear and the same message should not be shown again. We probably need a vuex mutation for the flag to take care of race conditions as users switch pages while new system messages are pushed.

We can also think about a message queue. If multiple system messages are pushed, queue them up and show them one at a time until the queue is empty. This could be another PR as it adds a fair bit of new logic to think through.

Choose a reason for hiding this comment

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

Micro-Learning Topic: Race condition (Detected by phrase)

What is this? (2min video)

A race condition is a flaw that produces an unexpected result when the timing of actions impact other actions.

Try this challenge in Secure Code Warrior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a valid concern and also an advanced use case.

For a quick fix, I think we can limit the Snackbar to only the timeline screen while this edge case is being worked upon in a new PR.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't consider this an edge case. A system wide message should be only shown once.
With your suggestion if the user goes away and back to the timeline screen, they will still see the last message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

Should I proceed with a fix for that in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please implement the flag to clear shown messages in this PR. Open a separate issue for system message queuing.

@vickywane vickywane requested a review from ivelin August 25, 2021 20:01
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

@vickywane still need to fix the repetitieve message issue and open a new one for queuing.

<div
v-bind="attrs"
id="close-icon"
@click="handleClose"
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane what about the case when the snackbar closes itself due to timeout and not a click?

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 don't understand what you are trying to point out.

The x icon for closing the snackbar manually, and it can also close after a timeout

Copy link
Contributor

Choose a reason for hiding this comment

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

The point is that visibility is only switched to false on click, but not if the snackbar closes due to timeout. In effect the problem with showing the latest old message when switching between menu items sill remains.

<template>
<div id="ConnectionStatusSnack-ctn">
<v-snackbar v-model="visibility">
<span id="snack-message">
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane
Maybe an easier way to handle this is to condition rendering on a computed visibility attribute (a function) instead of a fixes parameter. When the computed attribute is read by the v-model check, the function can return the current state and set it to false.

computed:
  visibility: () => { 
    if (this.isMessageNew) { 
      this.isMessageNew = false
     return true 
    } else {
     return false
    } 

then in setConnectionStatusNotification before the switch statement:

  this.isMessageNew = true

setConnectionStatusNotification () {
switch (this.peerConnectionStatus) {
case 'PEER_CONNECTING':
this.visibility = this.message !== PEER_CONNECTING_NOTIFICATION
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane this repeated check should not be necessary. If the peer state machine fires the same state message multiple times, then something is wrong with the state machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This condition was to handle scenarios when a user navigates to a new screen and the setConnectionStatusNotification function is (re)fired.

<div
v-bind="attrs"
id="close-icon"
@click="handleClose"
Copy link
Contributor

Choose a reason for hiding this comment

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

The point is that visibility is only switched to false on click, but not if the snackbar closes due to timeout. In effect the problem with showing the latest old message when switching between menu items sill remains.

@vickywane
Copy link
Contributor Author

The point is that visibility is only switched to false on click, but not if the snackbar closes due to timeout. In effect the problem with showing the latest old message when switching between menu items sill remains.

Okay, I understand this better. But the timeout is automatically handled by Vuetify. Would you prefer we disable the timeout and make it manual-close only?

@vickywane
Copy link
Contributor Author

@ivelin I have just written a fix to the repetitive bug issue and testing it out, it works as expected.

Taking a closer look into the issue, the Snackbar component was getting recreated on each page navigation, hence, it needed some other way to persist the last shown notification rather than using local state.

I decided to employ the use of localstorage, each time checking that the last stored status is not the same as the one about to be displayed.

On some further notes, the settings page only checks if an edgePeerId is present before it shows that the PWA is connecting. This causes the settings page to lose sync with the Tooltip and Snackbar ( if displayed ). Do we need to make any modifications on the Settings page?

@vickywane vickywane requested a review from ivelin August 30, 2021 15:11
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

@ivelin I have just written a fix to the repetitive bug issue and testing it out, it works as expected.

Glad you are taking the time to carefully think through and test.

Taking a closer look into the issue, the Snackbar component was getting recreated on each page navigation, hence, it needed some other way to persist the last shown notification rather than using local state.

I decided to employ the use of localstorage, each time checking that the last stored status is not the same as the one about to be displayed.

localstorage is more appropriate for persisting state between app sessions. What you need here is a session scoped connectivity state variable. See how we use Vuex store for PnPService and Peer connection status.

On some further notes, the settings page only checks if an edgePeerId is present before it shows that the PWA is connecting. This causes the settings page to lose sync with the Tooltip and Snackbar ( if displayed ). Do we need to make any modifications on the Settings page?

Interesting catch. Can you show exactly the problem with a self documented test case that fails. Once the bug is fixed the test should pass and keep the code from regressing.

switch (this.peerConnectionStatus) {
case 'PEER_CONNECTING':
this.message = PEER_CONNECTING_NOTIFICATION
this.visibility = true
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane
this.visibility = true can be set once before or after the switch. No need to repeat the same code multiple times without clear benefit.

Copy link
Contributor Author

@vickywane vickywane Aug 30, 2021

Choose a reason for hiding this comment

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

Setting visibility once before the switch will mean the snackbar will be displayed for all notification statuses. Currently, the notification is only being shown for connected, connecting and disconnected statuses.

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 have extracted the assignments within each case to a separate method to make follow the DRY convention.

@vickywane
Copy link
Contributor Author

localstorage is more appropriate for persisting state between app sessions. What you need here is a session scoped connectivity state variable. See how we use Vuex store for PnPService and Peer connection status.

I took a second shot at this and I created a new state within the pnp module to store a lastPeerConnectionStatus value. This way, localstorage is not needed.

@vickywane
Copy link
Contributor Author

Interesting catch. Can you show exactly the problem with a self documented test case that fails. Once the bug is fixed the test should pass and keep the code from regressing.

This is not a bug. Its the way the Settings page is built that might need a slight adjustment in a follow-up PR. This line of code within the Settings page has a if condition that evaluates to true when there is an edgePeerId. This should be corrected to use the peerConnectionStatus.

@vickywane vickywane requested a review from ivelin August 30, 2021 21:17
Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

My manual testing showing acceptable behavior. See a few cosmetic comments.

<div>
<!-- nav goes here -->
<NavBar />
<ComponentStatusSnack />
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane usually Vue component names are not prefixed with Component. It becomes redundant and noisy as components add up. Let's rename to statusSnackbar to keep it close to the standard meaning of the material design component names.

vuetify,
store
})

Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane how about a couple of test cases to cover the behavior of the status snackbar when the user switches between menus. This will help prevent regression on this known issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane did you see this comment?

@ivelin
Copy link
Contributor

ivelin commented Aug 30, 2021

On some further notes, the settings page only checks if an edgePeerId is present before it shows that the PWA is connecting. This causes the settings page to lose sync with the Tooltip and Snackbar ( if displayed ). Do we need to make any modifications on the Settings page?

@vickywane to keep this PR moving, let's open a new issue and PR for the settings page. I agree that it should be in sync with the cloud icon and status snackbar.

@vickywane vickywane force-pushed the update/connection-icon branch from c39d0cd to 4e1076c Compare August 31, 2021 13:37
@ivelin
Copy link
Contributor

ivelin commented Aug 31, 2021

  • Implement color coding of the new icon
  • Write sufficient unit tests based on the connection status

@vickywane Are these tasks/checkboxes left open on purpose?

@vickywane
Copy link
Contributor Author

  • Implement color coding of the new icon
  • Write sufficient unit tests based on the connection status

@vickywane Are these tasks/checkboxes left open on purpose?

No.
I will update them now.

@vickywane
Copy link
Contributor Author

@vickywane to keep this PR moving, let's open a new issue and PR for the settings page. I agree that it should be in sync with the cloud icon and status snack bar.

Aright.

I have opened this feature request to follow up on this issue.

Copy link
Contributor

@ivelin ivelin left a comment

Choose a reason for hiding this comment

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

Please address the pending comments.

this.connectionIconColor = 'warning'
} else if (this.peerConnectionStatus === 'PEER_CONNECTING') {
this.connectionStatusIcon = 'cloud-sync-outline'
this.connectionIconColor = 'black'
Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane let's use default colors such as warning and info to avoid problems when the OS switches between light and dark themes. We had this issue in the past several times when some contributors pick colors they like for their widgets which do not agree with the colors of widgets elsewhere in the app.

vuetify,
store
})

Copy link
Contributor

Choose a reason for hiding this comment

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

@vickywane did you see this comment?

@ivelin ivelin merged commit 501bc6c into ambianic:master Sep 3, 2021
github-actions bot pushed a commit that referenced this pull request Sep 3, 2021
# [2.18.0](v2.17.0...v2.18.0) (2021-09-03)

### Bug Fixes

* install wizard bugs ([#707](#707)) ([3697b41](3697b41))

### Features

* replace download icon with cloud icon, add status snackbar (PR [#708](#708)), closes [#697](#697) ([501bc6c](501bc6c))
@ivelin
Copy link
Contributor

ivelin commented Sep 3, 2021

🎉 This PR is included in version 2.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ivelin ivelin added the released label Sep 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants