Skip to content

Commit

Permalink
[3623] Remove unused form payload
Browse files Browse the repository at this point in the history
Bug: #3623
Signed-off-by: Michaël Charfadi <[email protected]>
  • Loading branch information
mcharfadi committed Jun 13, 2024
1 parent c382016 commit 25ad2bd
Show file tree
Hide file tree
Showing 73 changed files with 125 additions and 648 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ More existing APIs will be migrated to this new common pattern.
* `Optional<IRepresentationEventProcessor> createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext)`;
* `public Optional<IRepresentationEventProcessor> acquireRepresentationEventProcessor(IRepresentationConfiguration configuration, IInput input)`;
* `Flux<IPayload> getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input);`
- https://github.com/eclipse-sirius/sirius-web/issues/3623[#3623] [form] Remove `IWidgetSubscriptionManagerFactory`

=== Dependency update

Expand Down Expand Up @@ -84,6 +85,7 @@ More existing APIs will be migrated to this new common pattern.
- https://github.com/eclipse-sirius/sirius-web/issues/3544[#3544] [diagram] Add missing positions for inside label
image:doc/screenshots/insideLabelPositions.png[Inside label positions, 70%]
- https://github.com/eclipse-sirius/sirius-web/issues/3574[#3574] [diagram] Add a loading indicator during execution of an arrange-all
- https://github.com/eclipse-sirius/sirius-web/issues/3623[#3623] [form] Remove unused form payload

== v2024.5.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input HierarchyEventInput {
hierarchyId: ID!
}

union HierarchyEventPayload = ErrorPayload | SubscribersUpdatedEventPayload | HierarchyRefreshedEventPayload
union HierarchyEventPayload = ErrorPayload | HierarchyRefreshedEventPayload

type HierarchyRefreshedEventPayload {
id: ID!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ type EditingContextAction {
label: String!
}

type SubscribersUpdatedEventPayload {
id: ID!
subscribers: [Subscriber]!
}

type Subscriber {
username: String!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input DeckEventInput {
deckId: ID!
}

union DeckEventPayload = ErrorPayload | SubscribersUpdatedEventPayload | DeckRefreshedEventPayload
union DeckEventPayload = ErrorPayload | DeckRefreshedEventPayload

type DeckRefreshedEventPayload {
id: ID!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ export interface GQLDeckEventPayload {
__typename: string;
}

export interface GQLSubscribersUpdatedEventPayload extends GQLDeckEventPayload {
id: string;
subscribers: GQLSubscriber[];
}

export interface GQLSubscriber {
username: string;
}

export interface GQLDeckRefreshedEventPayload extends GQLDeckEventPayload {
id: string;
deck: GQLDeck;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ input DiagramEventInput {

union DiagramEventPayload =
ErrorPayload
| SubscribersUpdatedEventPayload
| DiagramRefreshedEventPayload

type DiagramRefreshedEventPayload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ subscription diagramEvent($input: DiagramEventInput!) {
id
message
}
... on SubscribersUpdatedEventPayload {
id
subscribers {
username
}
}
... on DiagramRefreshedEventPayload {
id
diagram {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ export interface GQLErrorPayload extends GQLDiagramEventPayload {
message: string;
}

export interface GQLSubscribersUpdatedEventPayload extends GQLDiagramEventPayload {
subscribers: GQLSubscriber[];
}

export interface GQLSubscriber {
username: string;
}

export interface GQLDiagramRefreshedEventPayload extends GQLDiagramEventPayload {
diagram: GQLDiagram;
cause: GQLRefreshCause;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input FormDescriptionEditorEventInput {
formDescriptionEditorId: ID!
}

union FormDescriptionEditorEventPayload = ErrorPayload | FormDescriptionEditorRefreshedEventPayload | SubscribersUpdatedEventPayload
union FormDescriptionEditorEventPayload = ErrorPayload | FormDescriptionEditorRefreshedEventPayload

type FormDescriptionEditorRefreshedEventPayload {
id: ID!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 2024 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
Expand Down Expand Up @@ -77,12 +77,6 @@ export const formDescriptionEditorEventSubscription = (contributions: WidgetCont
id
message
}
... on SubscribersUpdatedEventPayload {
id
subscribers {
username
}
}
... on FormDescriptionEditorRefreshedEventPayload {
id
formDescriptionEditor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 2024 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
Expand Down Expand Up @@ -31,15 +31,6 @@ export interface GQLFormDescriptionEditorEventPayload {
__typename: string;
}

export interface GQLSubscribersUpdatedEventPayload extends GQLFormDescriptionEditorEventPayload {
id: string;
subscribers: GQLSubscriber[];
}

export interface GQLSubscriber {
username: string;
}

export interface GQLFormDescriptionEditorRefreshedEventPayload extends GQLFormDescriptionEditorEventPayload {
id: string;
formDescriptionEditor: GQLFormDescriptionEditor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import { gql, useSubscription } from '@apollo/client';
import { RepresentationComponentProps, Toast } from '@eclipse-sirius/sirius-components-core';
import { PropertySectionContext, PropertySectionContextValue } from '@eclipse-sirius/sirius-components-forms';
import Avatar from '@material-ui/core/Avatar';
import Tooltip from '@material-ui/core/Tooltip';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import ViewAgendaIcon from '@material-ui/icons/ViewAgenda';
Expand Down Expand Up @@ -146,7 +144,7 @@ export const FormDescriptionEditorRepresentation = ({
FormDescriptionEditorRepresentationEvent
>(formDescriptionEditorRepresentationMachine);
const { toast, formDescriptionEditorRepresentation } = value as SchemaValue;
const { id, formDescriptionEditor, subscribers, message } = context;
const { id, formDescriptionEditor, message } = context;

const { propertySectionsRegistry } = useContext<PropertySectionContextValue>(PropertySectionContext);
const allWidgets: WidgetDescriptor[] = [...coreWidgets];
Expand Down Expand Up @@ -313,13 +311,6 @@ export const FormDescriptionEditorRepresentation = ({
<div className={classes.formDescriptionEditor}>
<div className={classes.header}>
<Typography>Form</Typography>
<div className={classes.subscribers}>
{subscribers.map((subscriber) => (
<Tooltip title={subscriber.username} arrow key={subscriber.username}>
<Avatar classes={{ root: classes.avatar }}>{subscriber.username.substring(0, 1).toUpperCase()}</Avatar>
</Tooltip>
))}
</div>
</div>
{readOnly ? <div className={classes.disabledOverlay}>{content}</div> : content}
<Toast
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 2024 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
Expand All @@ -17,8 +17,6 @@ import {
GQLFormDescriptionEditorEventPayload,
GQLFormDescriptionEditorEventSubscription,
GQLFormDescriptionEditorRefreshedEventPayload,
GQLSubscribersUpdatedEventPayload,
Subscriber,
} from './FormDescriptionEditorEventFragment.types';

export interface FormDescriptionEditorRepresentationStateSchema {
Expand Down Expand Up @@ -48,7 +46,6 @@ export type SchemaValue = {
export interface FormDescriptionEditorRepresentationContext {
id: string;
formDescriptionEditor: GQLFormDescriptionEditor;
subscribers: Subscriber[];
message: string | null;
}
export type ShowToastEvent = { type: 'SHOW_TOAST'; message: string };
Expand All @@ -74,9 +71,6 @@ const isFormDescriptionEditorRefreshedEventPayload = (
payload: GQLFormDescriptionEditorEventPayload
): payload is GQLFormDescriptionEditorRefreshedEventPayload =>
payload.__typename === 'FormDescriptionEditorRefreshedEventPayload';
const isSubscribersUpdatedEventPayload = (
payload: GQLFormDescriptionEditorEventPayload
): payload is GQLSubscribersUpdatedEventPayload => payload.__typename === 'SubscribersUpdatedEventPayload';

export const formDescriptionEditorRepresentationMachine = Machine<
FormDescriptionEditorRepresentationContext,
Expand All @@ -88,7 +82,6 @@ export const formDescriptionEditorRepresentationMachine = Machine<
context: {
id: crypto.randomUUID(),
formDescriptionEditor: null,
subscribers: [],
message: null,
},
states: {
Expand Down Expand Up @@ -163,9 +156,6 @@ export const formDescriptionEditorRepresentationMachine = Machine<
if (isFormDescriptionEditorRefreshedEventPayload(data.formDescriptionEditorEvent)) {
const { formDescriptionEditor } = data.formDescriptionEditorEvent;
return { formDescriptionEditor };
} else if (isSubscribersUpdatedEventPayload(data.formDescriptionEditorEvent)) {
const { subscribers } = data.formDescriptionEditorEvent;
return { subscribers };
}
return {};
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor;
import org.eclipse.sirius.components.collaborative.forms.api.IFormInput;
import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor;
import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManager;
import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorConfiguration;
import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload;
import org.eclipse.sirius.components.collaborative.forms.dto.RenameFormInput;
import org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusInput;
import org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusSuccessPayload;
import org.eclipse.sirius.components.collaborative.forms.variables.FormVariableProvider;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IInput;
Expand Down Expand Up @@ -83,8 +80,6 @@ public class FormEventProcessor implements IFormEventProcessor {

private final ISubscriptionManager subscriptionManager;

private final IWidgetSubscriptionManager widgetSubscriptionManager;

private final IRepresentationSearchService representationSearchService;

private final IRepresentationRefreshPolicyRegistry representationRefreshPolicyRegistry;
Expand All @@ -98,7 +93,7 @@ public class FormEventProcessor implements IFormEventProcessor {
private final VariableManager variableManager;

public FormEventProcessor(FormEventProcessorConfiguration configuration,
ISubscriptionManager subscriptionManager, IWidgetSubscriptionManager widgetSubscriptionManager,
ISubscriptionManager subscriptionManager,
IRepresentationSearchService representationSearchService,
IRepresentationRefreshPolicyRegistry representationRefreshPolicyRegistry, IFormPostProcessor formPostProcessor) {
this.logger.trace("Creating the form event processor {}", configuration.formCreationParameters().getId());
Expand All @@ -109,7 +104,6 @@ public FormEventProcessor(FormEventProcessorConfiguration configuration,
this.formEventHandlers = Objects.requireNonNull(configuration.formEventHandlers());
this.representationSearchService = Objects.requireNonNull(representationSearchService);
this.subscriptionManager = Objects.requireNonNull(subscriptionManager);
this.widgetSubscriptionManager = Objects.requireNonNull(widgetSubscriptionManager);
this.representationRefreshPolicyRegistry = Objects.requireNonNull(representationRefreshPolicyRegistry);
this.formPostProcessor = Objects.requireNonNull(formPostProcessor);

Expand Down Expand Up @@ -158,20 +152,13 @@ public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDesc
}
if (effectiveInput instanceof IFormInput formInput) {

if (formInput instanceof UpdateWidgetFocusInput input) {
this.widgetSubscriptionManager.handle(input);
Optional<IFormEventHandler> optionalFormEventHandler = this.formEventHandlers.stream().filter(handler -> handler.canHandle(formInput)).findFirst();

payloadSink.tryEmitValue(new UpdateWidgetFocusSuccessPayload(input.id(), input.widgetId()));
changeDescriptionSink.tryEmitNext(new ChangeDescription(ChangeKind.FOCUS_CHANGE, input.representationId(), input));
if (optionalFormEventHandler.isPresent()) {
IFormEventHandler formEventHandler = optionalFormEventHandler.get();
formEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.currentForm.get(), formInput);
} else {
Optional<IFormEventHandler> optionalFormEventHandler = this.formEventHandlers.stream().filter(handler -> handler.canHandle(formInput)).findFirst();

if (optionalFormEventHandler.isPresent()) {
IFormEventHandler formEventHandler = optionalFormEventHandler.get();
formEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.currentForm.get(), formInput);
} else {
this.logger.warn("No handler found for event: {}", formInput);
}
this.logger.warn("No handler found for event: {}", formInput);
}
}
}
Expand Down Expand Up @@ -239,7 +226,6 @@ public Flux<IPayload> getOutputEvents(IInput input) {

return Flux.merge(
refreshEventFlux,
this.widgetSubscriptionManager.getFlux(input),
this.subscriptionManager.getFlux(input)
);
}
Expand All @@ -249,7 +235,6 @@ public void dispose() {
this.logger.trace("Disposing the form event processor {}", this.formCreationParameters.getId());

this.subscriptionManager.dispose();
this.widgetSubscriptionManager.dispose();

EmitResult emitResult = this.sink.tryEmitComplete();
if (emitResult.isFailure()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters;
import org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler;
import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor;
import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManagerFactory;
import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorConfiguration;
import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorFactoryConfiguration;
import org.eclipse.sirius.components.core.api.IEditingContext;
Expand Down Expand Up @@ -59,8 +58,6 @@ public class FormEventProcessorFactory implements IRepresentationEventProcessorF

private final ISubscriptionManagerFactory subscriptionManagerFactory;

private final IWidgetSubscriptionManagerFactory widgetSubscriptionManagerFactory;

private final IRepresentationRefreshPolicyRegistry representationRefreshPolicyRegistry;

private final IFormPostProcessor formPostProcessor;
Expand All @@ -72,7 +69,6 @@ public FormEventProcessorFactory(RepresentationEventProcessorFactoryConfiguratio
this.objectService = Objects.requireNonNull(formConfiguration.getObjectService());
this.widgetDescriptors = Objects.requireNonNull(widgetDescriptors);
this.formEventHandlers = Objects.requireNonNull(formConfiguration.getFormEventHandlers());
this.widgetSubscriptionManagerFactory = Objects.requireNonNull(formConfiguration.getWidgetSubscriptionManagerFactory());
this.representationRefreshPolicyRegistry = Objects.requireNonNull(configuration.getRepresentationRefreshPolicyRegistry());
this.formPostProcessor = Objects.requireNonNull(formConfiguration.getFormPostProcessor());
}
Expand Down Expand Up @@ -108,7 +104,6 @@ public Optional<IRepresentationEventProcessor> createRepresentationEventProcesso
IRepresentationEventProcessor formEventProcessor = new FormEventProcessor(
new FormEventProcessorConfiguration(editingContext, this.objectService, formCreationParameters, this.widgetDescriptors, this.formEventHandlers),
this.subscriptionManagerFactory.create(),
this.widgetSubscriptionManagerFactory.create(),
this.representationSearchService,
this.representationRefreshPolicyRegistry,
this.formPostProcessor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor;
import org.eclipse.sirius.components.collaborative.forms.api.IPropertiesDefaultDescriptionProvider;
import org.eclipse.sirius.components.collaborative.forms.api.IPropertiesDescriptionService;
import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManagerFactory;
import org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration;
import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorConfiguration;
import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorFactoryConfiguration;
Expand Down Expand Up @@ -64,8 +63,6 @@ public class PropertiesEventProcessorFactory implements IRepresentationEventProc

private final ISubscriptionManagerFactory subscriptionManagerFactory;

private final IWidgetSubscriptionManagerFactory widgetSubscriptionManagerFactory;

private final IRepresentationRefreshPolicyRegistry representationRefreshPolicyRegistry;

private final IFormPostProcessor formPostProcessor;
Expand All @@ -79,7 +76,6 @@ public PropertiesEventProcessorFactory(IPropertiesDescriptionService propertiesD
this.widgetDescriptors = Objects.requireNonNull(widgetDescriptors);
this.formEventHandlers = Objects.requireNonNull(formConfiguration.getFormEventHandlers());
this.subscriptionManagerFactory = Objects.requireNonNull(configuration.getSubscriptionManagerFactory());
this.widgetSubscriptionManagerFactory = Objects.requireNonNull(formConfiguration.getWidgetSubscriptionManagerFactory());
this.representationRefreshPolicyRegistry = Objects.requireNonNull(configuration.getRepresentationRefreshPolicyRegistry());
this.formPostProcessor = Objects.requireNonNull(formConfiguration.getFormPostProcessor());
}
Expand Down Expand Up @@ -115,7 +111,6 @@ public Optional<IRepresentationEventProcessor> createRepresentationEventProcesso
IRepresentationEventProcessor formEventProcessor = new FormEventProcessor(
new FormEventProcessorConfiguration(editingContext, this.objectService, formCreationParameters, this.widgetDescriptors, this.formEventHandlers),
this.subscriptionManagerFactory.create(),
this.widgetSubscriptionManagerFactory.create(),
this.representationSearchService,
this.representationRefreshPolicyRegistry,
this.formPostProcessor);
Expand Down
Loading

0 comments on commit 25ad2bd

Please sign in to comment.