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

[7105] Feature - Adding error for a field defined with range #8229

Conversation

alexanmtz
Copy link
Contributor

@alexanmtz alexanmtz commented May 17, 2019

Fixes #7105

status-input-range-validation

Summary

Support input range validation with min and max properties

Review notes

  • Add the extension code, install it and check the validation

Testing notes

  • Add the extension code, install it and check the validation

Platforms

  • Android
  • iOS
  • macOS
  • Linux
  • Windows

Areas that maybe impacted

  • Extensions
Functional
  • 1-1 chats
  • public chats
  • group chats
  • wallet / transactions
  • dapps / app browsing
  • account recovery
  • new account
  • user profile updates
  • networks
  • mailservers
  • fleet
  • bootnodes
Non-functional
  • battery performance
  • CPU performance / speed of the app
  • network consumption

Steps to test

Add the following extension to test

{meta {:name "Test extension example 10"
:description "just to test the input error example version 10"
:documentation ""}

views/hello
[input {:style {:margin 10} :placeholder "Test" :min 1 :max 8}]

hooks/wallet.settings.hello
{:label "Settings for test error input extension"
:view [hello]}}
  • Open Status
  • ...
  • Step 3, etc.

status: ready

@alexanmtz alexanmtz requested a review from a team as a code owner May 17, 2019 20:45
@status-github-bot
Copy link

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?

@status-im-auto
Copy link
Member

status-im-auto commented May 17, 2019

Jenkins Builds

Click to see older builds (27)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ d3104dc #1 2019-05-17 21:02:18 ~17 min android 📦 apk
✔️ d3104dc #1 2019-05-17 21:04:43 ~19 min android-e2e 📦 apk
✔️ d3104dc #1 2019-05-17 21:05:54 ~20 min macos 📦 dmg
✔️ d3104dc #1 2019-05-17 21:08:36 ~23 min linux 📦 App
✔️ d3104dc #1 2019-05-17 21:09:37 ~24 min windows 📦 exe
✔️ d3104dc #1 2019-05-17 21:09:44 ~24 min ios 📦 ipa
✔️ b1ef307 #2 2019-05-17 22:24:16 ~17 min android-e2e 📦 apk
✔️ b1ef307 #2 2019-05-17 22:24:20 ~17 min android 📦 apk
✔️ b1ef307 #2 2019-05-17 22:26:55 ~19 min macos 📦 dmg
✔️ b1ef307 #2 2019-05-17 22:30:41 ~23 min ios 📦 ipa
✔️ b1ef307 #2 2019-05-17 22:32:42 ~25 min windows 📦 exe
✔️ 156f342 #3 2019-05-22 21:32:17 ~17 min macos 📦 dmg
✔️ 156f342 #3 2019-05-22 21:32:59 ~18 min android 📦 apk
✔️ 156f342 #3 2019-05-22 21:34:24 ~19 min android-e2e 📦 apk
✔️ 156f342 #3 2019-05-22 21:36:22 ~21 min linux 📦 App
✔️ 156f342 #3 2019-05-22 21:36:55 ~21 min windows 📦 exe
✔️ 156f342 #3 2019-05-22 21:41:03 ~26 min ios 📦 ipa
ea81090 #6 2019-06-04 16:23:58 ~2 min ios 📄 log
ea81090 #6 2019-06-04 16:24:02 ~2 min linux 📄 log
ea81090 #6 2019-06-04 16:24:20 ~3 min windows 📄 log
ea81090 #6 2019-06-04 16:24:32 ~3 min macos 📄 log
ea81090 #6 2019-06-04 16:31:00 ~10 min android-e2e 📄 log
ea81090 #6 2019-06-04 16:31:00 ~10 min android 📄 log
898db7c #7 2019-06-07 08:40:13 ~2 min ios 📄 log
898db7c #7 2019-06-07 08:40:34 ~2 min windows 📄 log
898db7c #7 2019-06-07 08:40:44 ~2 min macos 📄 log
898db7c #7 2019-06-07 08:40:44 ~2 min linux 📄 log
Commit #️⃣ Finished (UTC) Duration Platform Result
9e7d80a #8 2019-06-07 08:44:51 ~1 min linux 📄 log
9e7d80a #8 2019-06-07 08:45:15 ~2 min macos 📄 log
9e7d80a #8 2019-06-07 08:45:45 ~2 min windows 📄 log
9e7d80a #8 2019-06-07 08:47:46 ~4 min ios 📄 log
9e7d80a #8 2019-06-07 08:47:59 ~5 min android 📄 log
9e7d80a #8 2019-06-07 08:48:10 ~5 min android-e2e 📄 log
✔️ e98a964 #11 2019-06-11 15:49:05 ~12 min android 📦 apk
✔️ e98a964 #10 2019-06-11 15:49:08 ~12 min android-e2e 📦 apk
✔️ e98a964 #10 2019-06-11 15:49:21 ~12 min ios 📦 ipa
✔️ e98a964 #10 2019-06-11 15:52:52 ~15 min macos 📦 dmg
✔️ e98a964 #10 2019-06-11 15:54:34 ~17 min linux 📦 App
✔️ e98a964 #10 2019-06-11 15:55:52 ~18 min windows 📦 exe

@alexanmtz alexanmtz changed the title Issue 7105 - Adding error for a field defined with range [7105] Feature - Adding error for a field defined with range May 17, 2019
@flexsurfer flexsurfer requested a review from jeluard May 20, 2019 07:19
(defn input [{:keys [keyboard-type style error on-change change-delay placeholder placeholder-text-color selection-color
(defn- in-range
;; Determines whether a number is in a range
[n, start, end]
Copy link
Contributor

Choose a reason for hiding this comment

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

Commas are a bit weird here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No more commas at all 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I still see them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeluard it was removed in the last commit: 0ce6e99

Copy link
Member

Choose a reason for hiding this comment

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

they are still here

Copy link
Member

Choose a reason for hiding this comment

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

commas still here

@@ -25,26 +28,44 @@
(js/clearTimeout id))
(reset! current (js/setTimeout #(on-input-change-text on-change value) delay)))

(defn input [{:keys [keyboard-type style error on-change change-delay placeholder placeholder-text-color selection-color
(defn- in-range
;; Determines whether a number is in a range
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be defined as function doc?

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 think no need comments at all, the function is pretty simple and self explained

(cond
(nil? n) true
(and (nil? start) (nil? end)) true
(= n "") true
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be combined with nil check into string/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.

changed 👍

Copy link
Member

Choose a reason for hiding this comment

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

it could be simplest form
(or (string/blank? n) (and (nil? start) (nil? end)) (and (< n end) (> n start)) )

[tooltip/tooltip error (styles/error error)])])

(let [input-range (reagent/atom nil)]
(fn []
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the fn here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeluard I tried to do in different ways, and only works when there's a anonymous function to handle. In some tutorials about atoms and event handling using clojure, reagent and react it was using this approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

What didn't work w/o it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeluard I think it is related to event handling with reagent, it needs to re-render once the atom change with the updated values.

You can see here:
https://github.com/status-im/status-react/blob/develop/src/status_im/ui/screens/wallet/components/views.cljs#L229

It is a similar situation where fn is used, I there's many of those inside the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

But what didn't work exactly? Not clear from your comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry @jeluard, without fn wrapped on the component when using reagent/atom, the input don't update the atom value and didn't check on on-change for the in-range function, so nothing happens if I get rid of the fn inside. This means the validation and the input error don't appear and nothing happens.

[status-im.ui.components.text-input.styles :as styles]
[status-im.extensions.capacities.map :as map-component]))
(:require
[reagent.core :as reagent]
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually use previous format

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 know why these spaces was inserted, but I Solved now 👍

Copy link
Member

@flexsurfer flexsurfer left a comment

Choose a reason for hiding this comment

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

for some reason i can't see changes in the code, maybe something wrong with commits. could you please squash commits and rebase onto develop, thanks

(defn input [{:keys [keyboard-type style error on-change change-delay placeholder placeholder-text-color selection-color
(defn- in-range
;; Determines whether a number is in a range
[n, start, end]
Copy link
Member

Choose a reason for hiding this comment

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

they are still here

(cond
(nil? n) true
(and (nil? start) (nil? end)) true
(= n "") true
Copy link
Member

Choose a reason for hiding this comment

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

it could be simplest form
(or (string/blank? n) (and (nil? start) (nil? end)) (and (< n end) (> n start)) )

@alexanmtz alexanmtz force-pushed the feature/7105-update-extension-to-support-number-range branch 3 times, most recently from f622566 to ea81090 Compare June 4, 2019 16:20
@alexanmtz
Copy link
Contributor Author

please try now @flexsurfer , there's a only commit only now 👍

@Serhy
Copy link
Contributor

Serhy commented Jun 11, 2019

Hey @alexanmtz could you please rebase onto develop (because builds are failing to succeed) and squash your commits into one?

@alexanmtz alexanmtz force-pushed the feature/7105-update-extension-to-support-number-range branch from c6e92f9 to e98a964 Compare June 11, 2019 15:36
@alexanmtz
Copy link
Contributor Author

Done 👍 @Serhy

@asemiankevich asemiankevich self-assigned this Jun 12, 2019
@asemiankevich
Copy link
Contributor

@alexanmtz do you have your extension posted on ipfs so you can share a link?

@statustestbot
Copy link

98% of end-end tests have passed

Total executed tests: 49
Failed tests: 1
Passed tests: 48

Failed tests (1)

Click to expand
1. test_backup_recovery_phrase_warning_from_wallet

Device 1: Wait for PlusButton
Device 1: Wait for PlusButton

Donation was not received during 300 seconds!

Device sessions

Passed tests (48)

Click to expand
1. test_block_user_from_public_chat
Device sessions

2. test_filters_from_daap
Device sessions

3. test_copy_and_paste_messages
Device sessions

4. test_send_transaction_from_daap
Device sessions

5. test_request_and_receive_tokens_in_1_1_chat
Device sessions

6. test_deploy_contract_from_daap
Device sessions

7. test_open_transaction_on_etherscan
Device sessions

8. test_public_chat_messaging
Device sessions

9. test_long_press_to_delete_1_1_chat
Device sessions

10. test_password_in_logcat_sign_in
Device sessions

11. test_text_message_1_1_chat
Device sessions

12. test_add_to_contacts
Device sessions

13. test_sign_typed_message (TestRail link is not found)
Device sessions

14. test_unread_messages_counter_1_1_chat
Device sessions

15. test_logcat_send_transaction_from_daap
Device sessions

16. test_send_message_in_group_chat
Device sessions

17. test_logcat_send_transaction_from_wallet
Device sessions

18. test_send_token_with_7_decimals
Device sessions

19. test_modify_transaction_fee_values
Device sessions

20. test_send_eth_from_wallet_to_address
Device sessions

21. test_manage_assets
Device sessions

22. test_logcat_send_transaction_in_1_1_chat
Device sessions

23. test_request_and_receive_eth_in_1_1_chat
Device sessions

24. test_long_press_to_delete_public_chat
Device sessions

25. test_send_emoji
Device sessions

26. test_search_chat_on_home
Device sessions

27. test_logcat_recovering_account
Device sessions

28. test_messaging_in_different_networks
Device sessions

29. test_send_tokens_in_1_1_chat
Device sessions

30. test_network_mismatch_for_send_request_commands
Device sessions

31. test_logcat_sign_message_from_daap
Device sessions

32. test_switch_users_and_add_new_account
Device sessions

33. test_send_stt_from_wallet
Device sessions

34. test_send_eth_in_1_1_chat
Device sessions

35. test_login_with_new_account
Device sessions

36. test_send_eth_from_wallet_to_contact
Device sessions

37. test_add_contact_from_public_chat
Device sessions

38. test_send_two_transactions_one_after_another_in_dapp
Device sessions

39. test_password_in_logcat_creating_account
Device sessions

40. test_backup_recovery_phrase
Device sessions

41. test_offline_status
Device sessions

42. test_open_google_com_via_open_dapp
Device sessions

43. test_unread_messages_counter_public_chat
Device sessions

44. test_sign_message_from_daap
Device sessions

45. test_user_can_remove_profile_picture
Device sessions

46. test_share_contact_code_and_wallet_address
Device sessions

47. test_request_eth_in_wallet
Device sessions

48. test_refresh_button_browsing_app_webview
Device sessions

@alexanmtz
Copy link
Contributor Author

alexanmtz commented Jun 12, 2019

@alexanmtz do you have your extension posted on ipfs so you can share a link?

@asemiankevich https://get.status.im/extension/ipfs@QmShrYmDYGAicPRYkqfq98Aipee5oQ1op5r9ZCwGjJWF7g/

Is set to a min value of 1 and max of 8 to the input test, that would be available on wallet settings.

@alexanmtz
Copy link
Contributor Author

The code of the extension is on the PR:

{meta {:name "Test extension example 10"
:description "just to test the input error example version 10"
:documentation ""}

views/hello
[input {:style {:margin 10} :placeholder "Test" :min 1 :max 8}]

hooks/wallet.settings.hello
{:label "Settings for test error input extension"
:view [hello]}}

@asemiankevich
Copy link
Contributor

@alexanmtz do you have your extension posted on ipfs so you can share a link?

@asemiankevich https://get.status.im/extension/ipfs@QmShrYmDYGAicPRYkqfq98Aipee5oQ1op5r9ZCwGjJWF7g/

Is set to a min value of 1 and max of 8 to the input test, that would be available on wallet settings.

it fails after i install it in status

image

@alexanmtz
Copy link
Contributor Author

alexanmtz commented Jun 12, 2019

@alexanmtz do you have your extension posted on ipfs so you can share a link?

@asemiankevich https://get.status.im/extension/ipfs@QmShrYmDYGAicPRYkqfq98Aipee5oQ1op5r9ZCwGjJWF7g/
Is set to a min value of 1 and max of 8 to the input test, that would be available on wallet settings.

it fails after i install it in status

Try this:
https://get.status.im/extension/ipfs@QmaRbdPJjzLiRGGb68Vx2DpPb8simpHBFBTQG1gcbjrFpq/

Or try to create the extension yourself with the code I provided.

@Serhy Serhy self-assigned this Jun 12, 2019
@Serhy
Copy link
Contributor

Serhy commented Jun 12, 2019

Looks good on iOS and Android.
Scientific format also supported (which I take as expected) - i.e. 1e1 returns true in a -100..100 range.

Screenshot 2019-06-12 at 17 50 38

Thanks, @alexanmtz !

…xtensions

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
@flexsurfer flexsurfer force-pushed the feature/7105-update-extension-to-support-number-range branch from e98a964 to 287e097 Compare June 12, 2019 15:02
@flexsurfer flexsurfer merged commit 287e097 into status-im:develop Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Update extension input to support number range
7 participants