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

[DDW-881] Enhance logic for updating menus #2838

Merged
merged 41 commits into from Feb 8, 2022
Merged

Conversation

szymonmaslowski
Copy link
Contributor

@szymonmaslowski szymonmaslowski commented Jan 25, 2022

This PR:

  • fixes behaviour of the wallet settings item of the menu:
    • enables the option if the user is on the one of wallet pages
    • disables (greyed with deactivated hotkey) the option if the user:
      • is on the one of wallet pages but has some dialog opened
      • is already on the wallet settings page
    • hides (and deactivates the hotkey) the option if the user:
      • is not on the one of the wallet pages
  • integrates AssetSettingDialog with the UiDIalogs mobx store
  • unifies IPC communication regarding menu rebuild to a single channel
  • removes implicit IPC channel.send() calls from react components and stores methods
  • creates new feature responsible for watching for all data changes requiring menu rebuild and triggering it

⚠️ This PR touches also the implementation of menu changes that happen after accepting terms of use (enabling "About Daedalus", "Redeem ITN rewards", "Settings" and "Daedalus Diagnostics") and changing language. For those cases the behaviour was not changed, so everything should work as previously. For those cases changes are all about the refactoring.

Todos

Screenshots

image
image
image
image

Testing Checklist

Test scenarios

Scenario 1 - Validate the menu is updated after switching languages

Given that Daedalus is running
When I access to the "Settings" screen
And switch the current language
Then I can see that the items on the menu are also displayed in the selected language

Scenario 2 - Validate the wallet settings option while wallet is selected

Given that Daedalus has at least one wallet
And I am on any tab from a wallet (except settings)
And no dialog is open
When I check the menu "Daedalus"
Then I can see the option "Wallet settings" is visible and enabled
And upon clicking on it using the hotkeys, I'm redirected to the "Settings" tab if the wallet

Scenario 3 - Validate the wallet settings option while wallet is selected and a dialog is open

Given that Daedalus has at least one wallet
And I am on any tab from a wallet (except settings)
And any dialog or overlay is open (Send ADA, Wallet Address, Add tokens, Tokens settings, Change password, Verify recovery phrase, Wallet public/multi-signature key, Delete wallet, About screen,Diagnostic screen, Redeem ITN rewards)
When I check the menu "Daedalus"
Then I can see the option "Wallet settings" is visible and disabled
And upon clicking on it or using the hotkeys, nothing happens

Scenario 4 - Validate the wallet settings option while "wallet settings" is visible

Given that Daedalus has at least one wallet
And I am on the settings tab from a wallet 
When I check the menu "Daedalus"
Then I can see the option "Wallet settings" is visible and disabled
And upon clicking on it or using the hotkeys, nothing happens

Scenario 5 - Validate the wallet settings option when there are no wallets

Given that Daedalus has no wallet
And I am on the "Add wallet" screen
When I check the menu "Daedalus"
Then I can see the option "Wallet settings" is not visible

Scenario 6 - Validate the wallet settings option when no wallet is selected

Given that Daedalus has at least one wallet
And I am not on any tab from a wallet (not selected)
When I check the menu "Daedalus"
Then I can see the option "Wallet settings" is not visible

Scenario 7 - Validate options before initial setup

Given that I have just installed Daedalus
When I run it for the first time
And validate the menu item before the initial setup
Then I can see the following options are disabled:

- Daedalus - About Daedalus
- Daedalus - Redeem ITN rewards
- Daedalus - Settings
- Help - Daedalus diagnostics

Review Checklist

Basics

  • PR assigned to the PR author(s)
  • input-output-hk/daedalus-dev and input-output-hk/daedalus-qa assigned as PR reviewers
  • If there are UI changes, Alexander Rukin assigned as an additional reviewer
  • All visual regression testing has been reviewed (Go to Github Actions tab -> Select Chromatic workflow -> Run on your working branch)
  • PR has appropriate labels (release-vNext, feature/bug/chore, WIP)
  • PR link is added to a Jira ticket, ticket moved to In Review
  • PR is updated to the most recent version of the target branch (and there are no conflicts)
  • PR has a good description that summarizes all changes
  • PR contains screenshots (in case of UI changes)
  • CHANGELOG entry has been added to the top of the appropriate section (Features, Fixes, Chores) and is linked to the correct PR on GitHub
  • There are no missing translations (running yarn manage:translations produces no changes)
  • Text changes are proofread and approved (Jane Wild / Amy Reeve)
  • Japanese text changes are proofread and approved (Junko Oda)
  • Storybook works and no stories are broken (yarn storybook)
  • In case of dependency changes yarn.lock file is updated

Code Quality

  • Important parts of the code are properly commented and documented
  • Code is properly typed with flow
  • React components are split-up enough to avoid unnecessary re-renderings
  • Any code that only works in main process is neatly separated from components

Testing

  • New feature/change is covered by acceptance tests
  • New feature/change is manually tested and approved by QA team
  • All existing acceptance tests are still up-to-date
  • New feature/change is covered by Daedalus Testing scenario
  • All existing Daedalus Testing scenarios are still up-to-date

After Review

  • Update Slack QA thread by marking it with a green checkmark

@alexander-rukin
Copy link
Contributor

image

this dialog should have setting option disabledd too

@szymonmaslowski szymonmaslowski changed the title [DDW-881] A feature responsible for rebuilding app menu on changes from various stores [DDW-881] Enhance logic for updating menus Jan 25, 2022
@szymonmaslowski
Copy link
Contributor Author

image

this dialog should have setting option disabledd too

This case is covered now.

@gabriela-ponce
Copy link

@szymonmaslowski Here are a couple of scenarios where the "wallet settings" option is still visible and enabled:

  • Transactions tab - Export CSV dialog - Check this screenshot.
  • Send tab - Add tokens dialog- Check this screenshot.

Comment on lines 378 to 386
getAssetSettingsDialogWasOpened = (): Promise<boolean> =>
LocalStorageApi.get(keys.ASSET_SETTINGS_DIALOG_WAS_OPENED, false);

setAssetSettingsDialogWasOpened = (): Promise<void> =>
LocalStorageApi.set(keys.ASSET_SETTINGS_DIALOG_WAS_OPENED, true);

unsetAssetSettingsDialogWasOpened = (): Promise<void> =>
LocalStorageApi.unset(keys.ASSET_SETTINGS_DIALOG_WAS_OPENED);

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 removed those three methods since they look like an overhead. We should not use persistent storage to store the information about whether the dialog is open since it is just a runtime information. Except the usage in the AssetsStore which was just checking whether the dialog was open I didn't found any other usages so they were safe to remove.

@szymonmaslowski
Copy link
Contributor Author

@szymonmaslowski Here are a couple of scenarios where the "wallet settings" option is still visible and enabled:

  • Transactions tab - Export CSV dialog - Check this screenshot.
  • Send tab - Add tokens dialog- Check this screenshot.

Thanks @gabriela-ponce for rising those.
Regarding the Add tokens dialog - already working on a fix for it it.
Regarding the Export CSV I didn't consider it a dialog, but you are right. I have consulted with @alexander-rukin on that and we agreed it is worth to fix if it is relatively small amount of effort so I will check how is it implemented and if that will be easy to fix I will do that.

@@ -38,7 +40,15 @@ const makeRebuildApplicationMenu = ({
send = () => {},
} = {}): RebuildApplicationMenu => ({ send }: any);

const defaultArgs: MakeReactionCallbackArgs = {
const renderComponent = (args) => {
const Component = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Another suggestion is that you could test the MenuUpdater to have a better integration test. Currently you are only testing the internal implementation.

function renderComponent(spy) {
return <>
<MenuUpdaterProvider appStore={{}} profileStore={{}} router={{}} stakingStore={{}} uiDialogsStore={{}}>
 <MenuUpdater onUpdate={({isNavigationEnabled, walletSettingsState}) => spy({isNavigationEnabled, walletSettingsState})} />
</MenuUpdaterProvider>
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The MenuUpdater component itself is not important as its role is only to provide required data using the mobx api. The sole logic is contained in the useMenuUpdater. Testing the MenuUpdater would require from me to involve mobx to testing which IMO is not worth for value it would give. I think we don't need to test things like connecting the component to mobx store

@gabriela-ponce
Copy link

@szymonmaslowski The scenarios were updated according to the new requirements you mentioned. And the latest fixes look good, great job 🚀

I found this issue on build 20711 (doesn't reproduce on develop).

  • Can't open the dialog "Native token settings". Check this video.

@szymonmaslowski
Copy link
Contributor Author

@szymonmaslowski The scenarios were updated according to the new requirements you mentioned. And the latest fixes look good, great job 🚀

I found this issue on build 20711 (doesn't reproduce on develop).

  • Can't open the dialog "Native token settings". Check this video.

The change responsible for opening that dialog should have been missed during merging. It is reverted already and should be working fine now. Thanks @gabriela-ponce.

Copy link

@gabriela-ponce gabriela-ponce left a comment

Choose a reason for hiding this comment

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

Good job 🚀

Copy link
Contributor

@renanvalentin renanvalentin left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

@danielmain danielmain merged commit 8abd7b3 into develop Feb 8, 2022
@danielmain danielmain deleted the feature/ddw-881 branch February 8, 2022 16:59
@danielmain danielmain added release-4.9.0-FC1 Daedalus Flight and removed ⏳release-vNext labels Feb 10, 2022
renanvalentin pushed a commit that referenced this pull request Mar 7, 2022
Co-authored-by: Michael Chappell <michael.chappell@iohk.io>
renanvalentin pushed a commit that referenced this pull request Mar 7, 2022
Co-authored-by: Michael Chappell <michael.chappell@iohk.io>
renanvalentin pushed a commit that referenced this pull request Mar 7, 2022
Co-authored-by: Michael Chappell <michael.chappell@iohk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants