taipy icon indicating copy to clipboard operation
taipy copied to clipboard

Ability to programmatically close a specific notification

Open zmikea opened this issue 1 year ago • 17 comments

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)

zmikea avatar Sep 18 '24 14:09 zmikea

Hey @jrobinAV if this is up for grab, would like to work on this

0hmX avatar Sep 22 '24 18:09 0hmX

Hello @cu8code,

Yes, it is. Let me assign it to you.

Thank you,

jrobinAV avatar Sep 23 '24 08:09 jrobinAV

@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!

0hmX avatar Sep 23 '24 19:09 0hmX

HI,

I believe @FredLL-Avaiga @FabienLelaquais @dinhlongviolin1 @namnguyen20999 are the key people to help you.

jrobinAV avatar Sep 24 '24 11:09 jrobinAV

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

FredLL-Avaiga avatar Sep 24 '24 12:09 FredLL-Avaiga

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?

FabienLelaquais avatar Sep 24 '24 13:09 FabienLelaquais

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

FredLL-Avaiga avatar Sep 24 '24 14:09 FredLL-Avaiga

... 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 avatar Sep 24 '24 15:09 FabienLelaquais

@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 ?

0hmX avatar Sep 25 '24 14:09 0hmX

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).

FredLL-Avaiga avatar Sep 25 '24 14:09 FredLL-Avaiga

for test, yes, you're supposed to test every (reasonable) possibility

FredLL-Avaiga avatar Sep 25 '24 14:09 FredLL-Avaiga

New Quest! image 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.

quest-bot[bot] avatar Oct 07 '24 11:10 quest-bot[bot]

I want to work on this issue can you assign me ? @jrobinAV

AdeshGhadage avatar Oct 09 '24 07:10 AdeshGhadage

Here you go @AdeshGhadage !

FlorianJacta avatar Oct 09 '24 08:10 FlorianJacta

@quest-bot embark

AdeshGhadage avatar Oct 11 '24 07:10 AdeshGhadage

@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 CSS and HTML magic ✨
  • 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.

quest-bot[bot] avatar Oct 11 '24 07:10 quest-bot[bot]

🧚 @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.

quest-bot[bot] avatar Oct 11 '24 07:10 quest-bot[bot]