taipy
taipy copied to clipboard
Ability to programmatically close a specific notification
Description
I have potentially 3 notifications during a process, and at the end of the process want to programmatically close a specific one of them immediately, but leave the other two to close based on their duration.
Solution Proposed
create an ID for each notification upon creation so that a user can obtain it upon creation, example: id = notify(state, 'info', 'blah blah', duration=10000) And then later in code, they can close it with the line id.close
Impact of Solution
No response
Additional Context
No response
Acceptance Criteria
- [ ] Ensure new code is unit tested, and check code coverage is at least 90%.
- [ ] Create related issue in taipy-doc for documentation and Release Notes.
- [ ] Check if a new demo could be provided based on this, or if legacy demos could be benefit from it.
- [ ] Ensure any change is well documented.
Code of Conduct
- [X] I have checked the existing issues.
- [ ] I am willing to work on this issue (optional)
Hey @jrobinAV if this is up for grab, would like to work on this
Hello @cu8code,
Yes, it is. Let me assign it to you.
Thank you,
@jrobinAV can you tell me which part of the code should I focus on. Just some of your initial thoughts about the problems. And the implementation!
HI,
I believe @FredLL-Avaiga @FabienLelaquais @dinhlongviolin1 @namnguyen20999 are the key people to help you.
right now there is no identifier for a notification
I don't know if the notistack package proposes this feature (deletion)
If it does I suppose we should create a new type of notification (so that we use the same ws message type) and implement it on the frontend depending on the way the package works
If a notification CAN be closed from the front-end... (which I think is pretty easy). We could add an option "identifier" parameter to 'notify()' and send it along with the ALERT message, store it as a (data?) property of the generated element. Then remove it when a new message (should we reuse ALERT?) is received referring to that id. @FredLL-Avaiga, thoughts?
after reading the code:
- there's already a way to remove the last notification by passing
type= "" - notistack support a key entry in the option object. So we only need to add an id to the payload and set it if present Should be quite easy
... that sounds great. "Last notification" use case already handled (which I suspect is 99% of the cases). Now we will want to add some semantics to 'duration': like "I 0, leave the notification on the page as long as it was not explicitly closed".
@FabienLelaquais @jrobinAV reading the code
- Every time we send a notification, we will send an additional ID
- we need to return an object, that will have a close method
- we could also just return the notification_ID, create a new function to close the notification taking notification_ID as parameter. https://github.com/Avaiga/taipy/blob/0ba8f1e4391ebd6e1a7da8c53f90ce5819f21913/taipy/gui/gui_actions.py#L64
Also, how do I visually test, all the different changes, do I have to build each of the models, and then create an example, to visually check everything is working ?
no need to return an object if a dev wants to be able to close a notification:
- first notify with an id (ie add an optional id to
notify) - when suitable, call the
close_notification(state, id)(the frontend, will act accordingly).
for test, yes, you're supposed to test every (reasonable) possibility
New Quest!
A new Quest has been launched in @Avaiga’s repo. Merge a PR that solves this issue to loot the Quest and earn your reward.
Some loot has been stashed in this issue to reward the solver!
🗡 Comment @quest-bot embark to check-in for this Quest and start solving the issue. Other solvers will be notified!
⚔️ When you submit a PR, comment @quest-bot loot #1801 to link your PR to this Quest.
Questions? Check out the docs.
I want to work on this issue can you assign me ? @jrobinAV
Here you go @AdeshGhadage !
@quest-bot embark
@AdeshGhadage has embarked on their Quest. 🗡
- @AdeshGhadage has been on GitHub since 2022.
- They have merged 11 public PRs in that time.
- Their swords are blessed with
CSSandHTMLmagic ✨ - They have contributed to this repo before.
This is not an assignment to the issue. Please check the repo’s contribution guidelines before submitting a PR.
Questions? Check out the docs.
🧚 @AdeshGhadage has submitted PR https://github.com/Avaiga/taipy/issues/1985 and is claiming the loot.
Keep up the pace, or you'll be left in the shadows.
Questions? Check out the docs.