Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
12.05k stars 841 forks source link

Ability to programmatically close a specific notification #1801

Open zmikea opened 1 week ago

zmikea commented 1 week ago

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

Code of Conduct

cu8code commented 2 days ago

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

jrobinAV commented 2 days ago

Hello @cu8code,

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

Thank you,

cu8code commented 1 day ago

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

jrobinAV commented 1 day ago

HI,

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

FredLL-Avaiga commented 1 day ago

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

FabienLelaquais commented 1 day ago

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?

FredLL-Avaiga commented 1 day ago

after reading the code:

FabienLelaquais commented 1 day ago

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

cu8code commented 3 hours ago

@FabienLelaquais @jrobinAV reading the code

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 ?

FredLL-Avaiga commented 3 hours ago

no need to return an object if a dev wants to be able to close a notification:

FredLL-Avaiga commented 3 hours ago

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