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

Unified base mode colors and helper function #1

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

louisg1337
Copy link
Contributor

Moved modeColors, BaseModes, and getBaseModeByKey from diaryHelper.ts to e-mission-common for centralized use between e-mission platforms.

Testing Done

  • Used npm link to add my local e-mission-common as a dependency in e-mission-phone
  • Then replaced the objects and function in favor of our e-mission-common version as shown below.
    export const modeColors = base_mode_colors.modeColors;
    export const BaseModes = base_mode_colors.BaseModes;
    export const getBaseModeByKey = base_mode_colors.getBaseModeByKey;
    

Copy link
Owner

@JGreenlee JGreenlee 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 setting this up. Glad you were able to use the compile script and use npm link to test the compiled JS in the context of e-mission-phone

You should try to test the source Python code as well

src/emcommon/diary/base_mode_colors.py Outdated Show resolved Hide resolved
src/emcommon/diary/base_mode_colors.py Outdated Show resolved Hide resolved
src/emcommon/diary/base_mode_colors.py Outdated Show resolved Hide resolved
src/emcommon/diary/base_mode_colors.py Outdated Show resolved Hide resolved
@louisg1337
Copy link
Contributor Author

Thanks for the feedback @JGreenlee! I took some time to incorporate your requests and actually properly test the python implementation, in which I found a few more bugs that I also addressed in this latest push. Also, I did have to change toUpperCase() to upper(), but apparently split() and pop() are both functions in python as well, so I ended up getting lucky with that.

Testing Done

  • I did the same tests as above, where I plugged in our e-mission-common's versions of our functions in diaryHelper.ts and I got no errors.
  • I tested the python implementation of get_base_mode_by_key() as follows...
    print(get_base_mode_by_key("AIR"))
    print(get_base_mode_by_key("HELLO"))
    > {'name': 'AIR', 'icon': 'airplane', 'color': '#bf5900'}
    > {'name': 'UNKNOWN', 'icon': 'help', 'color': '#555555'}
  • I then did the same for the javascript implementation...
    console.log(get_base_mode_by_key("AIR"))
    console.log(get_base_mode_by_key("HELLO"))
    > {'name': 'AIR', 'icon': 'airplane', 'color': '#bf5900'}
    > {'name': 'UNKNOWN', 'icon': 'help', 'color': '#555555'}

Copy link
Owner

@JGreenlee JGreenlee left a comment

Choose a reason for hiding this comment

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

Great! Now can you create a corresponding PR on e-mission-phone? Search for places where getBaseModeByKey was imported from diaryHelper. Replace those by importing base_mode_colors from e-mission-common and calling base_mode_colors.get_base_mode_by_key.
Then you can remove getBaseModeByKey.

@louisg1337
Copy link
Contributor Author

Sounds good, just released a PR with those changes!

@JGreenlee JGreenlee merged commit ab1da45 into JGreenlee:master Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants