From 6efd314242595d337bd48a40c3f1df912835a013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Rou=C3=ABn=C3=A9?= Date: Tue, 9 May 2023 16:14:11 +0200 Subject: [PATCH] [1912] Add the possibility to send feedback messages to the frontend after an action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-components/issues/1912 Signed-off-by: Florian Rouëné --- CHANGELOG.adoc | 3 + .../100_feedback_messages_on_actions.adoc | 62 +++++++++++++++++++ .../components/core/api/FeedbackLevel.java | 22 +++++++ .../components/core/api/FeedbackMessage.java | 29 +++++++++ .../core/api/IFeedbackMessageService.java | 45 ++++++++++++++ .../sirius-components-core/src/index.ts | 1 + .../src/workbench/Toast.tsx | 37 +++++++++++ .../src/workbench/Toast.types.ts | 18 ++++++ .../src/workbench/Workbench.tsx | 23 +------ .../delete-project/DeleteProjectModal.tsx | 23 +------ .../src/modals/new-object/NewObjectModal.tsx | 23 +------ .../NewRepresentationModal.tsx | 23 +------ .../new-root-object/NewRootObjectModal.tsx | 23 +------ .../rename-project/RenameProjectModal.tsx | 23 +------ .../src/droparea/DropArea.tsx | 24 +------ .../src/palette/ContextualMenu.tsx | 25 ++------ .../src/palette/ContextualPalette.tsx | 23 +------ .../representation/DiagramRepresentation.tsx | 25 ++------ .../src/toolbar/Toolbar.tsx | 24 ++----- .../src/FlexboxContainerWidget.tsx | 27 +------- .../FormDescriptionEditorRepresentation.tsx | 24 +------ .../src/Group.tsx | 28 +-------- .../src/Page.tsx | 35 +++-------- .../src/PageList.tsx | 34 ++-------- .../src/ToolbarActionWidget.tsx | 31 +--------- .../src/ToolbarActions.tsx | 20 +----- .../src/WidgetEntry.tsx | 22 +------ .../ButtonPropertySection.tsx | 22 +------ .../CheckboxPropertySection.tsx | 21 +------ .../propertysections/ListPropertySection.tsx | 21 +------ .../MultiSelectPropertySection.tsx | 21 +------ .../propertysections/RadioPropertySection.tsx | 21 +------ .../RichTextPropertySection.tsx | 21 +------ .../SelectPropertySection.tsx | 21 +------ .../TextfieldPropertySection.tsx | 21 +------ .../__tests__/ButtonPropertySection.test.tsx | 2 +- .../CheckboxPropertySection.test.tsx | 2 +- .../__tests__/RadioPropertySection.test.tsx | 2 +- .../TextfieldPropertySection.test.tsx | 2 +- .../representations/FormRepresentation.tsx | 26 ++------ .../src/toolbaraction/ToolbarAction.tsx | 22 +------ .../src/views/FormBasedView.tsx | 27 ++------ .../src/views/RepresentationsView.tsx | 26 ++------ .../src/SelectionDialog.tsx | 26 ++------ .../modals/delete-image/DeleteImageModal.tsx | 25 ++------ .../ProjectTemplatesModal.tsx | 23 +------ .../modals/rename-image/RenameImageModal.tsx | 23 +------ .../modals/upload-image/UploadImageModal.tsx | 24 +------ .../src/onboarding/NewDocumentArea.tsx | 24 ++----- .../src/onboarding/NewRepresentationArea.tsx | 24 ++----- .../views/edit-project/EditProjectView.tsx | 26 ++------ .../src/views/new-project/NewProjectView.tsx | 23 +------ .../ProjectImagesSettings.tsx | 25 ++------ .../src/views/projects/ProjectsView.tsx | 29 ++------- .../upload-project/UploadProjectView.tsx | 22 +------ .../modals/new-document/NewDocumentModal.tsx | 23 +------ .../upload-document/UploadDocumentModal.tsx | 24 +------ .../src/treeitems/TreeItemContextMenu.tsx | 22 +------ .../src/views/ExplorerView.tsx | 25 ++------ .../src/ValidationView.tsx | 27 ++------ .../configuration/ViewToolConfiguration.java | 59 ++++++++++++++++++ .../diagram/DiagramOperationInterpreter.java | 15 ++++- .../view/emf/diagram/ToolConverter.java | 10 ++- .../ViewDiagramDescriptionConverter.java | 20 ++++-- .../ViewReconnectionToolsExecutor.java | 21 ++++--- .../emf/diagram/ViewToolSectionsProvider.java | 13 ++-- .../form/ViewFormDescriptionConverter.java | 9 ++- .../ViewFormDescriptionConverterSwitch.java | 30 ++++++--- .../view/emf/view/DynamicDiagramsTests.java | 3 +- .../view/emf/view/DynamicFormsTests.java | 3 +- .../web/services/FeedbackMessageService.java | 62 +++++++++++++++++++ 71 files changed, 585 insertions(+), 1050 deletions(-) create mode 100644 doc/adrs/100_feedback_messages_on_actions.adoc create mode 100644 packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackLevel.java create mode 100644 packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackMessage.java create mode 100644 packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IFeedbackMessageService.java create mode 100644 packages/core/frontend/sirius-components-core/src/workbench/Toast.tsx create mode 100644 packages/core/frontend/sirius-components-core/src/workbench/Toast.types.ts create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/configuration/ViewToolConfiguration.java create mode 100644 packages/web/backend/sirius-components-web/src/main/java/org/eclipse/sirius/components/web/services/FeedbackMessageService.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 440a7e64834..adc76efa2f1 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -19,6 +19,7 @@ - [ADR-098] Use the editing context to compute the metamodels - [ADR-099] Filter tree based representations +- [ADR-100] Feedback messages on actions === Breaking changes @@ -69,6 +70,8 @@ image:doc/screenshots/filterBarFilterButton.png[Filter Bar Filter Button,30%,30% - https://github.com/eclipse-sirius/sirius-components/issues/1830[#1830] [layout] This feature is experimental and can be activated on a diagram by adding "__EXPERIMENTAL" to its name. The new algorithm does the minimum possible to place node without overlap. +- https://github.com/eclipse-sirius/sirius-components/issues/1912[#1912] [core] Add the possibility to send feedback messages to the frontend after an action. + === Improvements - https://github.com/eclipse-sirius/sirius-components/issues/1869[#1869] [tree] Navigate to the first child with the right arrow if a node is expanded. diff --git a/doc/adrs/100_feedback_messages_on_actions.adoc b/doc/adrs/100_feedback_messages_on_actions.adoc new file mode 100644 index 00000000000..8113819d229 --- /dev/null +++ b/doc/adrs/100_feedback_messages_on_actions.adoc @@ -0,0 +1,62 @@ += ADR-100 - Add the possibility to send feedback messages to the frontend after an action + +== Context + +After an action, only technical error messages can be displayed on the UI. +We want to offer the specifier the ability to send back custom return messages to the end user. + +== Decision + +We will provide a new Java service that specifiers can invoke during the execution of their actions (tools behaviors) to stack messages. +These messages will be displayed on the UI after the action resolution. + +=== Backend + +The interface will provide the following method : + +[source,java] +---- +interface IFeedbackMessageService { + void addFeedbackMessage(String message, FeedbackLevel level); +} +---- +with +[source,java] +---- +enum FeedbackLevel { + DEBUG, + INFO, + WARNING, + ERROR, +} +---- + +The implementation must have a scope to limit the _bean_ life cycle to the action only, in order to just return at the end of the action the messages stacked by the services called by the action. +The spring scope of type _request_ provides this limitation. + +At first, we will join all the _string messages_ stacked in a single string, and append it to the existing `Failure` (`IStatus` implementation) _message_ parameter. +In doing so, we can keep the actual _frontend_ representation for this message. + +To differentiate the level applied to the message, we will prefix it with an emoji representing this level. + +=== Frontend + +To begin, we will not change the actual representation for an action error message. +But in order to facilitate the maintenance and the evolutions, we will mutualize all these representations in a single custom component `Toast`. + +with + +[source,typescript] +---- +export interface ToastProps { + message?: string; + open?: boolean; + onClose?: () => void; +} +---- + +Next, we will change this representation to display, for each stacked message, a unique _notification_ with a style depending on the chosen level. + +== Status + +Accepted. diff --git a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackLevel.java b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackLevel.java new file mode 100644 index 00000000000..d1dc960b888 --- /dev/null +++ b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackLevel.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.core.api; + +/** + * Enumeration used to indicate the feedback message level. + * + * @author frouene + */ +public enum FeedbackLevel { + DEBUG, INFO, WARNING, ERROR, +} diff --git a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackMessage.java b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackMessage.java new file mode 100644 index 00000000000..faea19cc047 --- /dev/null +++ b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/FeedbackMessage.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.core.api; + +import java.util.Objects; + +/** + * Record used to represent a feedback message. + * + * @author frouene + */ +public record FeedbackMessage(String message, FeedbackLevel level) { + + public FeedbackMessage { + Objects.requireNonNull(message); + Objects.requireNonNull(level); + } + +} diff --git a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IFeedbackMessageService.java b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IFeedbackMessageService.java new file mode 100644 index 00000000000..d6dcd11df5d --- /dev/null +++ b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/api/IFeedbackMessageService.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.core.api; + +import java.util.List; + +/** + * Interface of the service interacting with the list of stacked feedback messages. + * + * @author frouene + */ +public interface IFeedbackMessageService { + + void addFeedbackMessage(String message, FeedbackLevel level); + + List getFeedbackMessages(); + + /** + * Implementation which does nothing, used for mocks in unit tests. + * + * @author frouene + */ + class NoOp implements IFeedbackMessageService { + + @Override + public void addFeedbackMessage(String message, FeedbackLevel level) { + + } + + @Override + public List getFeedbackMessages() { + return List.of(); + } + } +} diff --git a/packages/core/frontend/sirius-components-core/src/index.ts b/packages/core/frontend/sirius-components-core/src/index.ts index 45a9764d7b2..dec90c9e9bc 100644 --- a/packages/core/frontend/sirius-components-core/src/index.ts +++ b/packages/core/frontend/sirius-components-core/src/index.ts @@ -20,3 +20,4 @@ export * from './workbench/RepresentationContext'; export * from './workbench/Workbench'; export * from './workbench/Workbench.types'; export * from './workbench/WorkbenchViewContribution'; +export * from './workbench/Toast'; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/Toast.tsx b/packages/core/frontend/sirius-components-core/src/workbench/Toast.tsx new file mode 100644 index 00000000000..683dc9e87a2 --- /dev/null +++ b/packages/core/frontend/sirius-components-core/src/workbench/Toast.tsx @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +import IconButton from '@material-ui/core/IconButton'; +import Snackbar from '@material-ui/core/Snackbar'; +import CloseIcon from '@material-ui/icons/Close'; +import { ToastProps } from './Toast.types'; + +export const Toast = ({ message, open, onClose }: ToastProps) => { + return ( + onClose()}> + + + } + data-testid="toast" + /> + ); +}; diff --git a/packages/core/frontend/sirius-components-core/src/workbench/Toast.types.ts b/packages/core/frontend/sirius-components-core/src/workbench/Toast.types.ts new file mode 100644 index 00000000000..2a56ffb06b5 --- /dev/null +++ b/packages/core/frontend/sirius-components-core/src/workbench/Toast.types.ts @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2023 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +export interface ToastProps { + message?: string; + open?: boolean; + onClose?: () => void; +} diff --git a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx index c1327a806c4..6ba61f34226 100644 --- a/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx +++ b/packages/core/frontend/sirius-components-core/src/workbench/Workbench.tsx @@ -11,10 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useSubscription } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useCallback, useContext, useEffect } from 'react'; import { Panels } from './Panels'; @@ -40,6 +37,7 @@ import { workbenchMachine, } from './WorkbenchMachine'; import { WorkbenchViewContribution } from './WorkbenchViewContribution'; +import { Toast } from './Toast'; const editingContextEventSubscription = gql` subscription editingContextEvent($input: EditingContextEventInput!) { @@ -205,25 +203,10 @@ export const Workbench = ({ rightPanelInitialSize={300} mainArea={main} /> - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/core/frontend/sirius-components/src/modals/delete-project/DeleteProjectModal.tsx b/packages/core/frontend/sirius-components/src/modals/delete-project/DeleteProjectModal.tsx index 90a9ae86039..91f8a643faf 100644 --- a/packages/core/frontend/sirius-components/src/modals/delete-project/DeleteProjectModal.tsx +++ b/packages/core/frontend/sirius-components/src/modals/delete-project/DeleteProjectModal.tsx @@ -17,9 +17,6 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { DeleteProjectModalContext, @@ -38,6 +35,7 @@ import { GQLDeleteProjectPayload, GQLErrorPayload, } from './DeleteProjectModal.types'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const deleteProjectMutation = gql` mutation deleteProject($input: DeleteProjectInput!) { @@ -123,25 +121,10 @@ export const DeleteProjectModal = ({ projectId, onDelete, onClose }: DeleteProje - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/core/frontend/sirius-components/src/modals/new-object/NewObjectModal.tsx b/packages/core/frontend/sirius-components/src/modals/new-object/NewObjectModal.tsx index 273ae9135bd..304a27b2946 100644 --- a/packages/core/frontend/sirius-components/src/modals/new-object/NewObjectModal.tsx +++ b/packages/core/frontend/sirius-components/src/modals/new-object/NewObjectModal.tsx @@ -16,13 +16,10 @@ import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -45,6 +42,7 @@ import { SchemaValue, ShowToastEvent, } from './NewObjectModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const createChildMutation = gql` mutation createChild($input: CreateChildInput!) { @@ -207,25 +205,10 @@ export const NewObjectModal = ({ editingContextId, item, onObjectCreated, onClos - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/core/frontend/sirius-components/src/modals/new-representation/NewRepresentationModal.tsx b/packages/core/frontend/sirius-components/src/modals/new-representation/NewRepresentationModal.tsx index 1b2340419b5..3fc17c75548 100644 --- a/packages/core/frontend/sirius-components/src/modals/new-representation/NewRepresentationModal.tsx +++ b/packages/core/frontend/sirius-components/src/modals/new-representation/NewRepresentationModal.tsx @@ -17,14 +17,11 @@ import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -48,6 +45,7 @@ import { SchemaValue, ShowToastEvent, } from './NewRepresentationModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const createRepresentationMutation = gql` mutation createRepresentation($input: CreateRepresentationInput!) { @@ -280,25 +278,10 @@ export const NewRepresentationModal = ({ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/core/frontend/sirius-components/src/modals/new-root-object/NewRootObjectModal.tsx b/packages/core/frontend/sirius-components/src/modals/new-root-object/NewRootObjectModal.tsx index a7d0836ddaf..4488c927416 100644 --- a/packages/core/frontend/sirius-components/src/modals/new-root-object/NewRootObjectModal.tsx +++ b/packages/core/frontend/sirius-components/src/modals/new-root-object/NewRootObjectModal.tsx @@ -18,13 +18,10 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; import FormControlLabel from '@material-ui/core/FormControlLabel'; -import IconButton from '@material-ui/core/IconButton'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -50,6 +47,7 @@ import { SchemaValue, ShowToastEvent, } from './NewRootObjectModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const createRootObjectMutation = gql` mutation createRootObject($input: CreateRootObjectInput!) { @@ -301,25 +299,10 @@ export const NewRootObjectModal = ({ editingContextId, item, onObjectCreated, on - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/core/frontend/sirius-components/src/modals/rename-project/RenameProjectModal.tsx b/packages/core/frontend/sirius-components/src/modals/rename-project/RenameProjectModal.tsx index 000616249a3..5d626b0411d 100644 --- a/packages/core/frontend/sirius-components/src/modals/rename-project/RenameProjectModal.tsx +++ b/packages/core/frontend/sirius-components/src/modals/rename-project/RenameProjectModal.tsx @@ -16,10 +16,7 @@ import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import TextField from '@material-ui/core/TextField'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -39,6 +36,7 @@ import { SchemaValue, ShowToastEvent, } from './RenameProjectModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const renameProjectMutation = gql` mutation renameProject($input: RenameProjectInput!) { @@ -145,25 +143,10 @@ export const RenameProjectModal = ({ projectId, initialProjectName, onRename, on - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/droparea/DropArea.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/droparea/DropArea.tsx index 157000eabb1..977f06edc1c 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/droparea/DropArea.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/droparea/DropArea.tsx @@ -11,11 +11,8 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; -import { DRAG_SOURCES_TYPE } from '@eclipse-sirius/sirius-components-core'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; +import { DRAG_SOURCES_TYPE, Toast } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { DropAreaProps } from './DropArea.types'; @@ -181,25 +178,10 @@ export const DropArea = ({ onDrop={(event) => handleDrop(event)} onDragOver={(event) => handleDragOver(event)} onDragLeave={(event) => handleDragLeave(event)}> - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> {children} diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualMenu.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualMenu.tsx index a3474ed413f..cedffa7c187 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualMenu.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualMenu.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo and others. + * Copyright (c) 2019, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -11,10 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useQuery } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useCallback, useEffect } from 'react'; import { ContextualMenuProps, GQLGetConnectorToolsData, GQLGetConnectorToolsVariables } from './ContextualMenu.types'; @@ -28,6 +25,7 @@ import { ShowToastEvent, } from './ContextualMenuMachine'; import { Tool } from './tool/Tool'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; export const getConnectorToolsQuery = gql` query getConnectorTools( @@ -158,25 +156,10 @@ export const ContextualMenu = ({ return ( <> {menuContent} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx index 9f03a03cfc1..184f6a212b1 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx @@ -11,10 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { ApolloError, gql, useMutation, useQuery } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useCallback, useEffect } from 'react'; import { EditLabelAction, isWithEditableLabel, SModelElement } from 'sprotty'; @@ -55,6 +52,7 @@ import hideImagePath from './icons/hide.svg'; import fadeImagePath from './icons/tonality.svg'; import { ToolSection } from './tool-section/ToolSection'; import { Tool } from './tool/Tool'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; export const getToolSectionsQuery = gql` query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { @@ -474,25 +472,10 @@ export const ContextualPalette = ({ return ( <> {paletteContent} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx index 6f235287893..631e492425c 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 Obeo and others. + * Copyright (c) 2019, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -16,13 +16,11 @@ import { Selection, SelectionEntry, ServerContext, + Toast, } from '@eclipse-sirius/sirius-components-core'; import { SelectionDialog } from '@eclipse-sirius/sirius-components-selection'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import makeStyles from '@material-ui/core/styles/makeStyles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useCallback, useContext, useEffect, useRef } from 'react'; import { HoverFeedbackAction, SEdge, SModelElement, SNode, SPort } from 'sprotty'; @@ -1217,25 +1215,10 @@ export const DiagramRepresentation = ({ /> {content} {selectModelElementDialog} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/toolbar/Toolbar.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/toolbar/Toolbar.tsx index 8288d324a48..a458e9c1c21 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/toolbar/Toolbar.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/toolbar/Toolbar.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 Obeo and others. + * Copyright (c) 2019, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -16,12 +16,10 @@ import FormControl from '@material-ui/core/FormControl'; import IconButton from '@material-ui/core/IconButton'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; import AccountTreeIcon from '@material-ui/icons/AccountTree'; import AspectRatioIcon from '@material-ui/icons/AspectRatio'; -import CloseIcon from '@material-ui/icons/Close'; import ShareIcon from '@material-ui/icons/Share'; import TonalityIcon from '@material-ui/icons/Tonality'; import VisibilityOffIcon from '@material-ui/icons/VisibilityOff'; @@ -52,6 +50,7 @@ import { ToolbarEvent, toolbarMachine, } from './ToolbarMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const hideDiagramElementMutation = gql` mutation hideDiagramElement($input: HideDiagramElementInput!) { @@ -343,25 +342,10 @@ export const Toolbar = ({ {modalElement} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FlexboxContainerWidget.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FlexboxContainerWidget.tsx index d64d120d015..ea3ddcba71a 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FlexboxContainerWidget.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FlexboxContainerWidget.tsx @@ -11,12 +11,10 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import { GQLWidget } from '@eclipse-sirius/sirius-components-forms'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import React, { useEffect, useRef, useState } from 'react'; import { FlexboxContainerWidgetState, FlexboxContainerWidgetStyleProps } from './FlexboxContainerWidget.types'; import { addWidgetMutation, moveWidgetMutation } from './FormDescriptionEditorEventFragment'; @@ -248,33 +246,14 @@ export const FlexboxContainerWidget = ({ onDrop={handleDrop}> {'Drag and drop a widget here'} - setState((prevState) => { return { ...prevState, message: null }; }) } - message={message} - action={ - - setState((prevState) => { - return { ...prevState, message: null }; - }) - }> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx index 59b181bb544..166bccb19be 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx @@ -11,17 +11,14 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useSubscription } from '@apollo/client'; -import { RepresentationComponentProps } from '@eclipse-sirius/sirius-components-core'; +import { RepresentationComponentProps, Toast } from '@eclipse-sirius/sirius-components-core'; import Avatar from '@material-ui/core/Avatar'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; import Typography from '@material-ui/core/Typography'; import ArrowDropDownCircleIcon from '@material-ui/icons/ArrowDropDownCircle'; import BarChartIcon from '@material-ui/icons/BarChart'; import CheckBoxIcon from '@material-ui/icons/CheckBox'; -import CloseIcon from '@material-ui/icons/Close'; import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; import ImageIcon from '@material-ui/icons/Image'; import LabelOutlinedIcon from '@material-ui/icons/LabelOutlined'; @@ -448,25 +445,10 @@ export const FormDescriptionEditorRepresentation = ({ {content} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Group.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Group.tsx index 3b02b07d66f..7cc24f7adfd 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Group.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Group.tsx @@ -11,14 +11,11 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { Selection } from '@eclipse-sirius/sirius-components-core'; +import { Selection, Toast } from '@eclipse-sirius/sirius-components-core'; import { GQLWidget } from '@eclipse-sirius/sirius-components-forms'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme, withStyles } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import ToggleButton from '@material-ui/lab/ToggleButton'; import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup'; import React, { useEffect, useRef, useState } from 'react'; @@ -522,33 +519,14 @@ export const Group = ({ - setState((prevState) => { return { ...prevState, message: null }; }) } - message={message} - action={ - - setState((prevState) => { - return { ...prevState, message: null }; - }) - }> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Page.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Page.tsx index f45471d1703..afd61a95db1 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Page.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/Page.tsx @@ -11,13 +11,11 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; -import { Group } from './Group'; -import { PageProps, PageState } from './Page.types'; +import React, { useEffect, useRef, useState } from 'react'; +import { addGroupMutation, moveGroupMutation } from './FormDescriptionEditorEventFragment'; import { GQLAddGroupInput, GQLAddGroupMutationData, @@ -29,8 +27,8 @@ import { GQLMoveGroupMutationVariables, GQLMovePagePayload, } from './FormDescriptionEditorEventFragment.types'; -import { addGroupMutation, moveGroupMutation } from './FormDescriptionEditorEventFragment'; -import React, { useEffect, useRef, useState } from 'react'; +import { Group } from './Group'; +import { PageProps, PageState } from './Page.types'; const isErrorPayload = (payload: GQLAddPagePayload | GQLMovePagePayload): payload is GQLErrorPayload => payload.__typename === 'ErrorPayload'; @@ -218,33 +216,14 @@ export const Page = ({ onDrop={handleDrop}> {'Drag and drop a group here'} - setState((prevState) => { return { ...prevState, message: null }; }) } - message={message} - action={ - - setState((prevState) => { - return { ...prevState, message: null }; - }) - }> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PageList.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PageList.tsx index c04b4e52d48..c369b96cf50 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PageList.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PageList.tsx @@ -11,17 +11,13 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { Selection } from '@eclipse-sirius/sirius-components-core'; +import { Selection, Toast } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; -import { PageListProps, PageListState } from './PageList.types'; -import { Page } from './Page'; import Tab from '@material-ui/core/Tab'; import Tabs from '@material-ui/core/Tabs'; -import Snackbar from '@material-ui/core/Snackbar'; -import CloseIcon from '@material-ui/icons/Close'; -import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; import React, { useEffect, useState } from 'react'; +import { addPageMutation, deletePageMutation, movePageMutation } from './FormDescriptionEditorEventFragment'; import { GQLAddPageInput, GQLAddPageMutationData, @@ -36,7 +32,8 @@ import { GQLMovePageMutationVariables, GQLMovePagePayload, } from './FormDescriptionEditorEventFragment.types'; -import { addPageMutation, deletePageMutation, movePageMutation } from './FormDescriptionEditorEventFragment'; +import { Page } from './Page'; +import { PageListProps, PageListState } from './PageList.types'; const isErrorPayload = (payload: GQLAddPagePayload | GQLMovePagePayload): payload is GQLErrorPayload => payload.__typename === 'ErrorPayload'; @@ -373,33 +370,14 @@ export const PageList = ({ selection={selection} setSelection={setSelection} /> - setState((prevState) => { return { ...prevState, message: null }; }) } - message={message} - action={ - - setState((prevState) => { - return { ...prevState, message: null }; - }) - }> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActionWidget.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActionWidget.tsx index 83e4c4eed6e..c6dca76ed6a 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActionWidget.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActionWidget.tsx @@ -11,7 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { Selection, ServerContext, ServerContextValue } from '@eclipse-sirius/sirius-components-core'; +import { Selection, ServerContext, ServerContextValue, Toast } from '@eclipse-sirius/sirius-components-core'; import { ButtonStyleProps, getTextDecorationLineValue, @@ -19,10 +19,7 @@ import { GQLToolbarAction, } from '@eclipse-sirius/sirius-components-forms'; import Button from '@material-ui/core/Button'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import React, { useContext, useEffect, useRef, useState } from 'react'; import { deleteToolbarActionMutation, moveToolbarActionMutation } from './FormDescriptionEditorEventFragment'; import { @@ -384,13 +381,9 @@ export const ToolbarActionWidget = ({ {state.buttonLabel} - setState((prevState) => { return { @@ -399,24 +392,6 @@ export const ToolbarActionWidget = ({ }; }) } - message={state.message} - action={ - - setState((prevState) => { - return { - ...prevState, - message: null, - }; - }) - }> - - - } - data-testid="error" /> ); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActions.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActions.tsx index 745635558c5..65048b792a3 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActions.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/ToolbarActions.tsx @@ -12,13 +12,12 @@ *******************************************************************************/ import { useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import { GQLToolbarAction } from '@eclipse-sirius/sirius-components-forms'; import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; import AddIcon from '@material-ui/icons/Add'; -import CloseIcon from '@material-ui/icons/Close'; import { useEffect, useState } from 'react'; import { addToolbarActionMutation, moveToolbarActionMutation } from './FormDescriptionEditorEventFragment'; import { @@ -201,22 +200,7 @@ export const ToolbarActions = ({ - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx index 923ff5ef43b..29f5adc9b8d 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx @@ -11,7 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { Selection } from '@eclipse-sirius/sirius-components-core'; +import { Selection, Toast } from '@eclipse-sirius/sirius-components-core'; import { GQLButton, GQLChartWidget, @@ -30,11 +30,8 @@ import { GQLTextfield, GQLWidget, } from '@eclipse-sirius/sirius-components-forms'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme, withStyles } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; -import CloseIcon from '@material-ui/icons/Close'; import React, { useEffect, useState } from 'react'; import { BarChartWidget } from './BarChartWidget'; import { ButtonWidget } from './ButtonWidget'; @@ -483,22 +480,7 @@ export const WidgetEntry = ({ {widgetElement} - setState({ message: null })} - message={message} - action={ - setState({ message: null })}> - - - } - data-testid="error" - /> + setState({ message: null })} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/ButtonPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/ButtonPropertySection.tsx index d503b3d7145..a2886801f99 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/ButtonPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/ButtonPropertySection.tsx @@ -11,12 +11,9 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { ServerContext, ServerContextValue } from '@eclipse-sirius/sirius-components-core'; +import { ServerContext, ServerContextValue, Toast } from '@eclipse-sirius/sirius-components-core'; import Button from '@material-ui/core/Button'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import gql from 'graphql-tag'; import { useContext, useEffect, useState } from 'react'; import { @@ -193,22 +190,7 @@ export const ButtonPropertySection = ({ ) : null} {widget.buttonLabel} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/CheckboxPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/CheckboxPropertySection.tsx index a8020553617..8f803bb6ee5 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/CheckboxPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/CheckboxPropertySection.tsx @@ -11,14 +11,12 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import Checkbox from '@material-ui/core/Checkbox'; import FormControl from '@material-ui/core/FormControl'; import FormGroup from '@material-ui/core/FormGroup'; import FormHelperText from '@material-ui/core/FormHelperText'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useEffect, useState } from 'react'; import { CheckboxPropertySectionProps, @@ -163,22 +161,7 @@ export const CheckboxPropertySection = ({ /> {widget.diagnostics[0]?.message} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/ListPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/ListPropertySection.tsx index b23379e873f..d77e3f88af2 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/ListPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/ListPropertySection.tsx @@ -11,18 +11,16 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; -import { ServerContext } from '@eclipse-sirius/sirius-components-core'; +import { ServerContext, Toast } from '@eclipse-sirius/sirius-components-core'; import FormControl from '@material-ui/core/FormControl'; import FormHelperText from '@material-ui/core/FormHelperText'; import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableRow from '@material-ui/core/TableRow'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import DeleteIcon from '@material-ui/icons/Delete'; import { MouseEvent, useContext, useEffect, useRef, useState } from 'react'; import { GQLListItem } from '../form/FormEventFragments.types'; @@ -277,22 +275,7 @@ export const ListPropertySection = ({ {widget.diagnostics[0]?.message} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/MultiSelectPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/MultiSelectPropertySection.tsx index 549f148a4b9..39c6b84b160 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/MultiSelectPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/MultiSelectPropertySection.tsx @@ -11,16 +11,14 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import Checkbox from '@material-ui/core/Checkbox'; import FormControl from '@material-ui/core/FormControl'; import FormHelperText from '@material-ui/core/FormHelperText'; -import IconButton from '@material-ui/core/IconButton'; import ListItemText from '@material-ui/core/ListItemText'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useEffect, useState } from 'react'; import { getTextDecorationLineValue } from './getTextDecorationLineValue'; import { @@ -208,22 +206,7 @@ export const MultiSelectPropertySection = ({ ))} {widget.diagnostics[0]?.message} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/RadioPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/RadioPropertySection.tsx index 25a70fb7ef8..0b956bffc89 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/RadioPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/RadioPropertySection.tsx @@ -11,16 +11,14 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import FormControl from '@material-ui/core/FormControl'; import FormControlLabel from '@material-ui/core/FormControlLabel'; import FormHelperText from '@material-ui/core/FormHelperText'; -import IconButton from '@material-ui/core/IconButton'; import Radio from '@material-ui/core/Radio'; import RadioGroup from '@material-ui/core/RadioGroup'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import { useEffect, useState } from 'react'; import { getTextDecorationLineValue } from './getTextDecorationLineValue'; import { PropertySectionLabel } from './PropertySectionLabel'; @@ -192,22 +190,7 @@ export const RadioPropertySection = ({ ))} {widget.diagnostics[0]?.message} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/RichTextPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/RichTextPropertySection.tsx index 888eb198a6a..14f3ed38ada 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/RichTextPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/RichTextPropertySection.tsx @@ -12,9 +12,6 @@ *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { RichTextEditor } from '../richtexteditor/RichTextEditor'; @@ -38,6 +35,7 @@ import { SchemaValue, ShowToastEvent, } from './RichTextPropertySectionMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; export const editRichTextMutation = gql` mutation editRichText($input: EditRichTextInput!) { @@ -174,22 +172,7 @@ export const RichTextPropertySection = ({ readOnly={readOnly} /> - dispatch({ type: 'HIDE_TOAST' })} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' })}> - - - } - data-testid="error" - /> + dispatch({ type: 'HIDE_TOAST' })} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/SelectPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/SelectPropertySection.tsx index c35c0e815e7..9a282e4a61a 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/SelectPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/SelectPropertySection.tsx @@ -11,14 +11,12 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import FormControl from '@material-ui/core/FormControl'; import FormHelperText from '@material-ui/core/FormHelperText'; -import IconButton from '@material-ui/core/IconButton'; import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import { useEffect, useState } from 'react'; import { getTextDecorationLineValue } from './getTextDecorationLineValue'; import { PropertySectionLabel } from './PropertySectionLabel'; @@ -206,22 +204,7 @@ export const SelectPropertySection = ({ ))} {widget.diagnostics[0]?.message} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/TextfieldPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/TextfieldPropertySection.tsx index 7a44440ed6c..3de6f31cb1c 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/TextfieldPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/TextfieldPropertySection.tsx @@ -11,16 +11,13 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useLazyQuery, useMutation } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; import ListItemText from '@material-ui/core/ListItemText'; import MenuItem from '@material-ui/core/MenuItem'; import MenuList from '@material-ui/core/MenuList'; import Popover from '@material-ui/core/Popover'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; import Tooltip from '@material-ui/core/Tooltip'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { FocusEvent, useEffect, useRef, useState } from 'react'; import { GQLTextarea, GQLWidget } from '../form/FormEventFragments.types'; @@ -54,6 +51,7 @@ import { TextfieldPropertySectionEvent, textfieldPropertySectionMachine, } from './TextfieldPropertySectionMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const useStyle = makeStyles(() => ({ style: { @@ -389,22 +387,7 @@ export const TextfieldPropertySection = ({ } /> {proposalsList} - dispatch({ type: 'HIDE_TOAST' })} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' })}> - - - } - data-testid="error" - /> + dispatch({ type: 'HIDE_TOAST' })} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ButtonPropertySection.test.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ButtonPropertySection.test.tsx index 9efbb085ee3..2f655b1ee73 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ButtonPropertySection.test.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ButtonPropertySection.test.tsx @@ -262,7 +262,7 @@ test('should display the error received', async () => { await waitFor(() => { expect(updateWidgetFocusCalled).toBeTruthy(); expect(pushButtonCalled).toBeTruthy(); - expect(screen.getByTestId('error')).not.toBeUndefined(); + expect(screen.getByTestId('toast')).not.toBeUndefined(); expect(baseElement).toMatchSnapshot(); }); }); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/CheckboxPropertySection.test.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/CheckboxPropertySection.test.tsx index 04a8f8768b9..ddc019ecdcf 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/CheckboxPropertySection.test.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/CheckboxPropertySection.test.tsx @@ -241,7 +241,7 @@ test('should display the error received', async () => { await waitFor(() => { expect(updateWidgetFocusCalled).toBeTruthy(); expect(editCheckboxCalled).toBeTruthy(); - expect(screen.getByTestId('error')).not.toBeUndefined(); + expect(screen.getByTestId('toast')).not.toBeUndefined(); expect(baseElement).toMatchSnapshot(); }); }); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/RadioPropertySection.test.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/RadioPropertySection.test.tsx index 9ed5a0aac57..ebfa6c1330d 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/RadioPropertySection.test.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/RadioPropertySection.test.tsx @@ -294,7 +294,7 @@ test('should display the error received', async () => { await waitFor(() => { expect(updateWidgetFocusCalled).toBeTruthy(); expect(editRadioCalled).toBeTruthy(); - expect(screen.getByTestId('error')).not.toBeUndefined(); + expect(screen.getByTestId('toast')).not.toBeUndefined(); expect(baseElement).toMatchSnapshot(); }); }); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/TextfieldPropertySection.test.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/TextfieldPropertySection.test.tsx index fd0bbc3cef2..24e730136d3 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/TextfieldPropertySection.test.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/TextfieldPropertySection.test.tsx @@ -252,7 +252,7 @@ test('should display the error received', async () => { await waitFor(() => { expect(updateWidgetFocusCalled).toBeTruthy(); - expect(screen.getByTestId('error')).not.toBeUndefined(); + expect(screen.getByTestId('toast')).not.toBeUndefined(); expect(baseElement).toMatchSnapshot(); }); }); diff --git a/packages/forms/frontend/sirius-components-forms/src/representations/FormRepresentation.tsx b/packages/forms/frontend/sirius-components-forms/src/representations/FormRepresentation.tsx index 506550a1c6c..8b780abdb7d 100644 --- a/packages/forms/frontend/sirius-components-forms/src/representations/FormRepresentation.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/representations/FormRepresentation.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -11,12 +11,9 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useSubscription } from '@apollo/client'; -import { RepresentationComponentProps } from '@eclipse-sirius/sirius-components-core'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; +import { RepresentationComponentProps, Toast } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { Form } from '../form/Form'; @@ -172,25 +169,10 @@ export const FormRepresentation = ({ return ( <> {content} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/forms/frontend/sirius-components-forms/src/toolbaraction/ToolbarAction.tsx b/packages/forms/frontend/sirius-components-forms/src/toolbaraction/ToolbarAction.tsx index c3f5dffbcd3..8064ef4b85e 100644 --- a/packages/forms/frontend/sirius-components-forms/src/toolbaraction/ToolbarAction.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/toolbaraction/ToolbarAction.tsx @@ -11,12 +11,9 @@ * Obeo - initial API and implementation *******************************************************************************/ import { useMutation } from '@apollo/client'; -import { ServerContext, ServerContextValue } from '@eclipse-sirius/sirius-components-core'; +import { ServerContext, ServerContextValue, Toast } from '@eclipse-sirius/sirius-components-core'; import Button from '@material-ui/core/Button'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles, Theme } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import gql from 'graphql-tag'; import { useContext, useEffect, useState } from 'react'; import { GQLButton } from '../form/FormEventFragments.types'; @@ -196,22 +193,7 @@ export const ToolbarAction = ({ editingContextId, formId, widget, readOnly }: To ) : null} {widget.buttonLabel} - setMessage(null)} - message={message} - action={ - setMessage(null)}> - - - } - data-testid="error" - /> + setMessage(null)} /> ); }; diff --git a/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx b/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx index c21fc524060..617dcd8730e 100644 --- a/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/views/FormBasedView.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -11,11 +11,8 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useSubscription } from '@apollo/client'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { Form } from '../form/Form'; @@ -41,6 +38,7 @@ import { ShowToastEvent, SwitchSelectionEvent, } from './FormBasedViewMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; export const getFormEventSubscription = (subscriptionName: string) => { return ` @@ -86,7 +84,7 @@ export const FormBasedView = ({ const { id, currentSelection, form, widgetSubscriptions, message } = context; /** - * Displays an other form if the selection indicates that we should display another properties view. + * Displays another form if the selection indicates that we should display another properties view. */ useEffect(() => { if (selection.entries.length > 0 && selection !== currentSelection) { @@ -161,25 +159,10 @@ export const FormBasedView = ({ return ( <> {content} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/forms/frontend/sirius-components-forms/src/views/RepresentationsView.tsx b/packages/forms/frontend/sirius-components-forms/src/views/RepresentationsView.tsx index dee013d64d5..2f70c10f033 100644 --- a/packages/forms/frontend/sirius-components-forms/src/views/RepresentationsView.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/views/RepresentationsView.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Obeo and others. + * Copyright (c) 2021, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -12,12 +12,9 @@ *******************************************************************************/ import { gql, useSubscription } from '@apollo/client'; -import { WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; +import { Toast, WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { @@ -146,25 +143,10 @@ export const RepresentationsView = ({ return ( <> {content} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx b/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx index d211f36556f..549982c06b1 100644 --- a/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx +++ b/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 Obeo. + * Copyright (c) 2021, 2023 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -11,21 +11,18 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useSubscription } from '@apollo/client'; -import { ServerContext } from '@eclipse-sirius/sirius-components-core'; +import { ServerContext, Toast } from '@eclipse-sirius/sirius-components-core'; import Button from '@material-ui/core/Button'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; import List from '@material-ui/core/List'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; -import Snackbar from '@material-ui/core/Snackbar'; import { createStyles, makeStyles } from '@material-ui/core/styles'; -import CloseIcon from '@material-ui/icons/Close'; import CropDinIcon from '@material-ui/icons/CropDin'; import { useMachine } from '@xstate/react'; import { useContext, useEffect } from 'react'; @@ -183,25 +180,10 @@ export const SelectionDialog = ({ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/modals/delete-image/DeleteImageModal.tsx b/packages/sirius-web/frontend/sirius-web/src/modals/delete-image/DeleteImageModal.tsx index f7dd573f214..176e6858b04 100644 --- a/packages/sirius-web/frontend/sirius-web/src/modals/delete-image/DeleteImageModal.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/modals/delete-image/DeleteImageModal.tsx @@ -17,9 +17,6 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -32,13 +29,14 @@ import { import { DeleteImageModalContext, DeleteImageModalEvent, + deleteImageModalMachine, HandleResponseEvent, HideToastEvent, RequestImageDeletionEvent, SchemaValue, ShowToastEvent, - deleteImageModalMachine, } from './DeleteImageModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const deleteImageMutation = gql` mutation deleteImage($input: DeleteImageInput!) { @@ -125,25 +123,10 @@ export const DeleteImageModal = ({ imageId, onImageDeleted, onClose }: DeleteIma - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/modals/project-templates/ProjectTemplatesModal.tsx b/packages/sirius-web/frontend/sirius-web/src/modals/project-templates/ProjectTemplatesModal.tsx index 4b054b1e26b..8181ce73ede 100644 --- a/packages/sirius-web/frontend/sirius-web/src/modals/project-templates/ProjectTemplatesModal.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/modals/project-templates/ProjectTemplatesModal.tsx @@ -15,11 +15,8 @@ import { useMutation, useQuery } from '@apollo/client'; import Dialog from '@material-ui/core/Dialog'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; -import CloseIcon from '@material-ui/icons/Close'; import Pagination from '@material-ui/lab/Pagination'; import { useMachine } from '@xstate/react'; import gql from 'graphql-tag'; @@ -49,6 +46,7 @@ import { SchemaValue, ShowToastEvent, } from './ProjectTemplatesModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; export const getProjectTemplatesQuery = gql` query getProjectTemplates($page: Int!) { @@ -252,25 +250,10 @@ export const ProjectTemplatesModal = ({ onClose }: ProjectTemplatesModalProps) = Select a project template {content} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/modals/rename-image/RenameImageModal.tsx b/packages/sirius-web/frontend/sirius-web/src/modals/rename-image/RenameImageModal.tsx index b5327d740ad..144470b854c 100644 --- a/packages/sirius-web/frontend/sirius-web/src/modals/rename-image/RenameImageModal.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/modals/rename-image/RenameImageModal.tsx @@ -16,10 +16,7 @@ import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import TextField from '@material-ui/core/TextField'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useEffect } from 'react'; import { @@ -40,6 +37,7 @@ import { SchemaValue, ShowToastEvent, } from './RenameImageModalMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const renameImageMutation = gql` mutation renameImage($input: RenameImageInput!) { @@ -147,25 +145,10 @@ export const RenameImageModal = ({ imageId, initialImageName, onImageRenamed, on - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/modals/upload-image/UploadImageModal.tsx b/packages/sirius-web/frontend/sirius-web/src/modals/upload-image/UploadImageModal.tsx index b350e5fa261..472f6f8d50e 100644 --- a/packages/sirius-web/frontend/sirius-web/src/modals/upload-image/UploadImageModal.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/modals/upload-image/UploadImageModal.tsx @@ -12,17 +12,14 @@ *******************************************************************************/ import { gql } from '@apollo/client'; import { FileUpload, Form, sendFile } from '@eclipse-sirius/sirius-components'; -import { ServerContext } from '@eclipse-sirius/sirius-components-core'; +import { ServerContext, Toast } from '@eclipse-sirius/sirius-components-core'; import Button from '@material-ui/core/Button'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; import FormGroup from '@material-ui/core/FormGroup'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import TextField from '@material-ui/core/TextField'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import React, { useContext, useEffect, useState } from 'react'; import { @@ -158,25 +155,10 @@ export const UploadImageModal = ({ projectId, onImageUploaded, onClose }: Upload - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/onboarding/NewDocumentArea.tsx b/packages/sirius-web/frontend/sirius-web/src/onboarding/NewDocumentArea.tsx index a976468847b..2c4b352e9ed 100644 --- a/packages/sirius-web/frontend/sirius-web/src/onboarding/NewDocumentArea.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/onboarding/NewDocumentArea.tsx @@ -11,17 +11,16 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; -import IconButton from '@material-ui/core/IconButton'; import List from '@material-ui/core/List/List'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; -import Snackbar from '@material-ui/core/Snackbar'; -import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; -import { Close as CloseIcon, NoteAdd } from '@material-ui/icons'; +import Typography from '@material-ui/core/Typography'; +import { NoteAdd } from '@material-ui/icons'; import { useEffect, useState } from 'react'; import { GQLInvokeEditingContextActionInput, @@ -121,22 +120,7 @@ export const NewDocumentArea = ({ editingContextId, editingContextActions, readO - setState({ message: null })} - action={ - setState({ message: null })}> - - - } - data-testid="error" - /> + setState({ message: null })} /> ); }; diff --git a/packages/sirius-web/frontend/sirius-web/src/onboarding/NewRepresentationArea.tsx b/packages/sirius-web/frontend/sirius-web/src/onboarding/NewRepresentationArea.tsx index 85fe164e10e..1f5dfc2406d 100644 --- a/packages/sirius-web/frontend/sirius-web/src/onboarding/NewRepresentationArea.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/onboarding/NewRepresentationArea.tsx @@ -11,17 +11,16 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useMutation } from '@apollo/client'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; -import IconButton from '@material-ui/core/IconButton'; import List from '@material-ui/core/List'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; -import Snackbar from '@material-ui/core/Snackbar'; -import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; -import { Close as CloseIcon, Collections } from '@material-ui/icons'; +import Typography from '@material-ui/core/Typography'; +import { Collections } from '@material-ui/icons'; import { useEffect, useState } from 'react'; import { NewDocumentAreaState } from './NewDocumentArea.types'; import { NewRepresentationAreaProps } from './NewRepresentationArea.types'; @@ -142,22 +141,7 @@ export const NewRepresentationArea = ({ - setState({ message: null })} - action={ - setState({ message: null })}> - - - } - data-testid="error" - /> + setState({ message: null })} /> ); }; diff --git a/packages/sirius-web/frontend/sirius-web/src/views/edit-project/EditProjectView.tsx b/packages/sirius-web/frontend/sirius-web/src/views/edit-project/EditProjectView.tsx index d640caca2e4..e40b3f0f6c3 100644 --- a/packages/sirius-web/frontend/sirius-web/src/views/edit-project/EditProjectView.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/views/edit-project/EditProjectView.tsx @@ -11,7 +11,7 @@ * Obeo - initial API and implementation *******************************************************************************/ import { gql, useQuery } from '@apollo/client'; -import { Representation, Workbench, WorkbenchViewContribution } from '@eclipse-sirius/sirius-components-core'; +import { Representation, Toast, Workbench, WorkbenchViewContribution } from '@eclipse-sirius/sirius-components-core'; import { DetailsView, RelatedElementsView, RepresentationsView } from '@eclipse-sirius/sirius-components-forms'; import { ExplorerView, @@ -21,12 +21,9 @@ import { } from '@eclipse-sirius/sirius-components-trees'; import { ValidationView } from '@eclipse-sirius/sirius-components-validation'; import Grid from '@material-ui/core/Grid'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; import AccountTreeIcon from '@material-ui/icons/AccountTree'; -import CloseIcon from '@material-ui/icons/Close'; import Filter from '@material-ui/icons/Filter'; import LinkIcon from '@material-ui/icons/Link'; import MenuIcon from '@material-ui/icons/Menu'; @@ -43,12 +40,12 @@ import { EditProjectViewParams, GQLGetProjectQueryData, GQLGetProjectQueryVariab import { EditProjectViewContext, EditProjectViewEvent, + editProjectViewMachine, HandleFetchedProjectEvent, HideToastEvent, SchemaValue, SelectRepresentationEvent, ShowToastEvent, - editProjectViewMachine, } from './EditProjectViewMachine'; import { ObjectTreeItemContextMenuContribution } from './ObjectTreeItemContextMenuContribution'; @@ -199,25 +196,10 @@ export const EditProjectView = () => { {navbar} {main} - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)} - message={message} - action={ - dispatch({ type: 'HIDE_TOAST' } as HideToastEvent)}> - - - } - data-testid="error" /> ); diff --git a/packages/sirius-web/frontend/sirius-web/src/views/new-project/NewProjectView.tsx b/packages/sirius-web/frontend/sirius-web/src/views/new-project/NewProjectView.tsx index bac70e834e2..fca27a7af74 100644 --- a/packages/sirius-web/frontend/sirius-web/src/views/new-project/NewProjectView.tsx +++ b/packages/sirius-web/frontend/sirius-web/src/views/new-project/NewProjectView.tsx @@ -14,11 +14,8 @@ import { gql, useMutation } from '@apollo/client'; import { Form, FormContainer } from '@eclipse-sirius/sirius-components'; import Button from '@material-ui/core/Button'; import Container from '@material-ui/core/Container'; -import IconButton from '@material-ui/core/IconButton'; -import Snackbar from '@material-ui/core/Snackbar'; import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; -import CloseIcon from '@material-ui/icons/Close'; import { useMachine } from '@xstate/react'; import { useEffect } from 'react'; import { Redirect } from 'react-router-dom'; @@ -36,6 +33,7 @@ import { SchemaValue, ShowToastEvent, } from './NewProjectViewMachine'; +import { Toast } from '@eclipse-sirius/sirius-components-core'; const createProjectMutation = gql` mutation createProject($input: CreateProjectInput!) { @@ -162,25 +160,10 @@ export const NewProjectView = () => {