-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add AlertComponent for displaying alerts in the GUI #1975
base: develop
Are you sure you want to change the base?
Add AlertComponent for displaying alerts in the GUI #1975
Conversation
@quest-bot loot #693 |
Quest PR submitted!@Rishi-0007, you are attempting to solve the issue and loot this Quest. Will you be successful? Questions? Check out the docs. |
Hi @FredLL-Avaiga , |
@Rishi-0007 If you have a screenshot (or even a few) to illustrate your proposal, that would make the review easier. In any case, thank you for your help. |
Hi @FredLL-Avaiga, |
Hey @FredLL-Avaiga , I've updated the message property in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there
…aultMessage property
Hi @Rishi-0007, can you fix the conflicts and resolve the conversation that are no longer active ? |
Hi @FredLL-Avaiga, Thank you for your feedback. I'm not entirely sure about the best way to resolve the conflicts and manage the conversations that are no longer active. Could you kindly provide some guidance on how to proceed with these tasks? I appreciate your help! |
doc/gui/examples/Alert.py
Outdated
severity = "error" | ||
variant = "filled" | ||
message = "This is an error message." | ||
render = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't use render here
doc/gui/examples/Alert.py
Outdated
# A simple page that binds the Alert component to dynamic variables and adds a button to trigger the update | ||
page = """ | ||
<|{message}|alert|severity={severity}|variant={variant}|render={render}|> | ||
<br/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for br or button
doc/gui/examples/Alert.py
Outdated
<|Update Alert|button|on_action=update_alert|> | ||
""" | ||
|
||
# Function to toggle between variants and severities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for a button on_action
@FredLL-Avaiga does this looks good to you? from taipy.gui import Gui
severity = "error"
variant = "filled"
message = "This is an error message."
page = """
<|{message}|alert|severity={severity}|variant={variant}|>
"""
if __name__ == "__main__":
gui = Gui(page)
gui.run(title="Test Alert") |
You could even be not simplistic and keep only the message as a variable and group the 2 lines with gui |
from taipy.gui import Gui
message = "This is an error message."
Gui(f"<|{{message}}|alert|severity='error'|variant='filled'|>").run(title="Test Alert") Is this gd? |
bdb722c
to
354eae0
Compare
A bit too compact |
4fc9a24
to
d4fec0e
Compare
- Refactor Alert.py example to remove unused code and simplify the page structure. - Add package.json file for frontend/taipy directory from develop branch.
Hey @FredLL-Avaiga , from taipy.gui import Gui
severity = "error"
variant = "filled"
message = "This is an error message."
page = """
<|{message}|alert|severity={severity}|variant={variant}|>
"""
if __name__ == "__main__":
gui = Gui(page)
gui.run(title="Test Alert") Also i have removed package.json from my commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like you to NOT commit any package.json file
frontend/taipy/package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like you to NOT commit this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there
alerts: AlertMessage[]; | ||
} | ||
|
||
const TaipyNotification = ({ alerts }: NotificationProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Waiting for this PR to be merged because it'll be easier to integrate then |
Thanks for the update! I understand, and I’ll wait for the PR to be merged. |
The PR about closing notification (that has an impact on the old alert component) was merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all good except for the conflicts with the last PR merged
if (alert) { | ||
if (alert.atype === "") { | ||
if (lastKey.current) { | ||
closeSnackbar(lastKey.current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something was lost in the conflict resolution
this should be
useEffect(() => {
if (alert) {
const notificationId = alert.notificationId || "";
if (alert.atype === "") {
closeSnackbar(notificationId);
} else {
enqueueSnackbar(alert.message, {
variant: alert.atype as VariantType,
action: notifAction,
autoHideDuration: alert.duration,
key: notificationId,
});
alert.system && new Notification(document.title || "Taipy", { body: alert.message, icon: faviconUrl });
}
dispatch(createDeleteAlertAction(notificationId));
}
}, [alert, enqueueSnackbar, closeSnackbar, notifAction, faviconUrl, dispatch]);
This pull request introduces the
Alert.tsx
to the Taipy framework and adds relevant tests. The component allows rendering of customizable alerts with dynamicmessage
,severity
, andvariant
properties. Additionally, there have been significant changes to existing components as per the maintainers' request.This PR addresses the issue outlined in feature #693.
Changes in this PR:
Alert.tsx
: A new component that renders an alert using Material-UI'sAlert
component.Alert.tsx
andAlert.spec.tsx
have been renamed toNotification.tsx
andNotification.spec.tsx
to avoid naming conflicts.factory.py
: Registered theAlert Component
with properties (message
,severity
,variant
) and enabled dynamic updates.viselements.json
: Added the definition for theAlert Component
, including its properties.Alert Component
to dynamically verify its behavior for different alert messages, severities, and variants.Example test:
doc/gui/examples/Alert.py:
Output:
Screencast.from.2024-10-16.01-04-41.mp4
Additional Information:
Checklist:
develop
branch.Related Issue:
This PR resolves issue #693.