From 3621961930cec46fd204c2322ff694542b0d85c9 Mon Sep 17 00:00:00 2001 From: Rishi Nayak <90302544+Rishi-0007@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:19:56 +0530 Subject: [PATCH] Add AlertComponent for displaying alerts in the GUI (#1975) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add AlertComponent for displaying alerts in the GUI * Add AlertComponent in index.ts * Refactor AlertComponent to handle dynamic message and update dependencies * Renamed AlertComponent to Notification and updated dependencies * updated dependencies * updated viselements.json * Refactor Notification component to handle dynamic message and add defaultMessage property * Apply suggestions from code review Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com> * Refactor Notification component and add dynamic message handling - Refactor the Notification component in Taipy to improve code readability and maintainability. - Add support for dynamic message handling using the useDynamicProperty hook. - Remove the variant and defaultMessage properties from the Notification component, as they are no longer needed. Closes #693 * Renamed Notification component to Alert and vice versa and updated dependencies * Refactor Alert component and update dependencies * Refactor Alert component to add dynamic rendering capability * feat: Enhance TaipyAlert with dynamic classNames and dispatch actions - Added dynamic className handling to TaipyAlert component. - Implemented dispatching of update actions. - Fixed issues with severity and variant properties. - Added unit tests to validate the new behavior, with all tests passing successfully. * Add Alert.py example with dynamic properties and button to update alert * Refactor Alert.py example and add package.json - Refactor Alert.py example to remove unused code and simplify the page structure. - Add package.json file for frontend/taipy directory from develop branch. * refactor package.json to match it with develop branch * Add license headers to Alert components * Fixed linter issue using ruff * Refactor Notification component and fix merge issue * Refactor Notification component and fix issue due to other PR * Refactor Notification test component to include notificationId in alerts --------- Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com> Co-authored-by: Fred Lefévère-Laoide <90181748+FredLL-Avaiga@users.noreply.github.com> --- doc/gui/examples/Alert.py | 28 +++ frontend/taipy-gui/src/components/Router.tsx | 4 +- .../src/components/Taipy/Alert.spec.tsx | 202 +++--------------- .../taipy-gui/src/components/Taipy/Alert.tsx | 96 +++------ .../components/Taipy/Notification.spec.tsx | 202 ++++++++++++++++++ .../src/components/Taipy/Notification.tsx | 81 +++++++ .../taipy-gui/src/components/Taipy/index.ts | 4 +- taipy/gui/_renderers/factory.py | 16 ++ taipy/gui/viselements.json | 35 ++- 9 files changed, 424 insertions(+), 244 deletions(-) create mode 100644 doc/gui/examples/Alert.py create mode 100644 frontend/taipy-gui/src/components/Taipy/Notification.spec.tsx create mode 100644 frontend/taipy-gui/src/components/Taipy/Notification.tsx diff --git a/doc/gui/examples/Alert.py b/doc/gui/examples/Alert.py new file mode 100644 index 0000000000..c2f901718a --- /dev/null +++ b/doc/gui/examples/Alert.py @@ -0,0 +1,28 @@ +# Copyright 2021-2024 Avaiga Private Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# ----------------------------------------------------------------------------------------- +# To execute this script, make sure that the taipy-gui package is installed in your +# Python environment and run: +# python