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

get localstorage support (#2190) #2234

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

dinhlongviolin1
Copy link
Member

@dinhlongviolin1 dinhlongviolin1 commented Nov 11, 2024

Resolve #2190

localStorage.setItem and localStorage.removeItem can be used directly on the browser console to test out the feature

from taipy.gui import Gui, get_local_storage


def button_click(state):
    print(get_local_storage(state, "TaipyClientId")) # would return str | None
    print(get_local_storage(state, "TaipyClientId", "hey")) # would return dict

Gui("<|Click me|button|on_action=button_click|>").run()

Copy link
Contributor

github-actions bot commented Nov 11, 2024

Coverage report for ./frontend/taipy

Caution

Coverage does not meet threshold
Statements coverage not met for global: expected >=80%, but got 52.07920792079208%

St.
Category Percentage Covered / Total
🔴 Statements 52.08% 263/505
🔴 Branches 21.75% 67/308
🔴 Functions 14.66% 17/116
🔴 Lines 53.42% 242/453

Test suite run success

7 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from 0c2fb22

Copy link
Contributor

Coverage report for ./frontend/taipy-gui

Caution

Coverage does not meet threshold
Branches coverage not met for global: expected >=80%, but got 69.25624811803674%

St.
Category Percentage Covered / Total
🟢 Statements
87.77% (-0.07% 🔻)
3408/3883
🟡 Branches
69.26% (-0.04% 🔻)
2300/3321
🟢 Functions
83.42% (-0.22% 🔻)
629/754
🟢 Lines
88.24% (-0.06% 🔻)
3152/3572
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / taipyReducers.ts
89.49% (-0.97% 🔻)
81.22% (-0.83% 🔻)
83.64% (-3.16% 🔻)
89.92% (-0.91% 🔻)

Test suite run success

681 tests passing in 47 suites.

Report generated by 🧪jest coverage report action from a98cddf

Copy link
Contributor

github-actions bot commented Nov 11, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19325 16795 87% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
taipy/gui/init.py 100% 🟢
taipy/gui/data/data_scope.py 94% 🟢
taipy/gui/gui.py 79% 🟢
taipy/gui/gui_actions.py 66% 🟢
taipy/gui/types.py 96% 🟢
TOTAL 87% 🟢

updated for commit: 0c2fb22 by action🐍

Copy link
Member

@FredLL-Avaiga FredLL-Avaiga left a comment

Choose a reason for hiding this comment

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

Not sure about this local storage API redéfinition in the browser
Way to invasive for my taste
And I'm not sure a security audit would appreciate

frontend/taipy-gui/src/hooks/useLocalStorageWithEvent.ts Outdated Show resolved Hide resolved
frontend/taipy-gui/src/hooks/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@FabienLelaquais FabienLelaquais left a comment

Choose a reason for hiding this comment

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

I would like to improve the doc a little bit before you actually merge.
Let's do that together if that works for you.


def get_local_storage(state: State, *keys: str) -> t.Optional[t.Union[str, t.Dict[str, str]]]:
"""Get local storage value(s).
Arguments:
Copy link
Member

Choose a reason for hiding this comment

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

Line skip here.

Can this be called anytime in the app life cycle?

I suspect we should add more details on invoking this API (with the complexity of the keys type).

Copy link
Member Author

Choose a reason for hiding this comment

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

i have not tested every case but it is very early on, only after the state id is initialized.

Arguments:
state (State^): The current user state as received in any callback.
*keys (string): The keys to get from the local storage
Returns:
Copy link
Member

Choose a reason for hiding this comment

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

Line skip.

Explanations are pretty weak. Let's spend some time together on this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

i am open to any proposal to the doc

Copy link
Contributor

This PR has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this PR, then please add new commit or another comment, otherwise this PR will be closed in 14 days. For more information please refer to the contributing guidelines.

@github-actions github-actions bot added the 🥶Waiting for contributor Issues or PRs waiting for a long time label Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🥶Waiting for contributor Issues or PRs waiting for a long time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retrieve values from the front-end local storage
3 participants