Skip to content

Commit

Permalink
[3627] Remove unused mutation in form
Browse files Browse the repository at this point in the history
Bug: #3627
Signed-off-by: Michaël Charfadi <[email protected]>
  • Loading branch information
mcharfadi committed Jun 14, 2024
1 parent 25ad2bd commit 3d9ee82
Show file tree
Hide file tree
Showing 55 changed files with 394 additions and 2,497 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ More existing APIs will be migrated to this new common pattern.
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
- https://github.com/eclipse-sirius/sirius-web/issues/3627[#3627] [form] Remove unused mutation in form

== v2024.5.0

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ extend type Mutation {
editSelect(input: EditSelectInput!): EditSelectPayload!
editTextfield(input: EditTextfieldInput!): EditTextfieldPayload!
editRichText(input: EditRichTextInput!): EditRichTextPayload!
updateWidgetFocus(input: UpdateWidgetFocusInput!): UpdateWidgetFocusPayload!
clickListItem(input: ClickListItemInput!): ClickListItemPayload!
deleteListItem(input: DeleteListItemInput!): DeleteListItemPayload!
pushButton(input: PushButtonInput!): PushButtonPayload!
Expand Down Expand Up @@ -531,21 +530,6 @@ input EditRichTextInput {

union EditRichTextPayload = ErrorPayload | SuccessPayload

input UpdateWidgetFocusInput {
id: ID!
editingContextId: ID!
representationId: ID!
widgetId: ID!
selected: Boolean!
}

union UpdateWidgetFocusPayload = ErrorPayload | UpdateWidgetFocusSuccessPayload

type UpdateWidgetFocusSuccessPayload {
id: ID!
updateFocusWidgetId: String!
}

input DeleteListItemInput {
id: ID!
editingContextId: ID!
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ import {
GQLPushButtonMutationVariables,
GQLPushButtonPayload,
GQLSuccessPayload,
GQLUpdateWidgetFocusInput,
GQLUpdateWidgetFocusMutationData,
GQLUpdateWidgetFocusMutationVariables,
GQLUpdateWidgetFocusPayload,
} from './ButtonPropertySection.types';
import { PropertySectionLabel } from './PropertySectionLabel';
import { getTextDecorationLineValue } from './getTextDecorationLineValue';
Expand Down Expand Up @@ -85,24 +81,10 @@ export const pushButtonMutation = gql`
}
`;

export const updateWidgetFocusMutation = gql`
mutation updateWidgetFocus($input: UpdateWidgetFocusInput!) {
updateWidgetFocus(input: $input) {
__typename
... on ErrorPayload {
messages {
body
level
}
}
}
}
`;

const isErrorPayload = (payload: GQLPushButtonPayload | GQLUpdateWidgetFocusPayload): payload is GQLErrorPayload =>
const isErrorPayload = (payload: GQLPushButtonPayload): payload is GQLErrorPayload =>
payload.__typename === 'ErrorPayload';

const isSuccessPayload = (payload: GQLPushButtonPayload | GQLUpdateWidgetFocusPayload): payload is GQLSuccessPayload =>
const isSuccessPayload = (payload: GQLPushButtonPayload): payload is GQLSuccessPayload =>
payload.__typename === 'SuccessPayload';

/**
Expand Down Expand Up @@ -149,43 +131,6 @@ export const ButtonPropertySection: PropertySectionComponent<GQLButton> = ({
}
}, [loading, error, data]);

const [
updateWidgetFocus,
{ loading: updateWidgetFocusLoading, data: updateWidgetFocusData, error: updateWidgetFocusError },
] = useMutation<GQLUpdateWidgetFocusMutationData, GQLUpdateWidgetFocusMutationVariables>(updateWidgetFocusMutation);

const sendUpdateWidgetFocus = (selected: boolean) => {
const input: GQLUpdateWidgetFocusInput = {
id: crypto.randomUUID(),
editingContextId,
representationId: formId,
widgetId: widget.id,
selected,
};
const variables: GQLUpdateWidgetFocusMutationVariables = {
input,
};
updateWidgetFocus({ variables });
};

useEffect(() => {
if (!updateWidgetFocusLoading) {
if (updateWidgetFocusError) {
addErrorMessage('An unexpected error has occurred, please refresh the page');
}
if (updateWidgetFocusData) {
const { updateWidgetFocus } = updateWidgetFocusData;
if (isErrorPayload(updateWidgetFocus)) {
addMessages(updateWidgetFocus.messages);
}
}
}
}, [updateWidgetFocusLoading, updateWidgetFocusData, updateWidgetFocusError]);

const onFocus = () => sendUpdateWidgetFocus(true);
const onBlur = () => {
sendUpdateWidgetFocus(false);
};
const onClick = () => {
const input: GQLPushButtonInput = {
id: crypto.randomUUID(),
Expand All @@ -210,8 +155,6 @@ export const ButtonPropertySection: PropertySectionComponent<GQLButton> = ({
variant="contained"
color="primary"
onClick={onClick}
onBlur={onBlur}
onFocus={onFocus}
disabled={readOnly || widget.readOnly}
classes={{ root: classes.style }}>
{widget.imageURL?.length > 0 ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,6 @@ export interface GQLSuccessPayload extends GQLPushButtonPayload {
messages: GQLMessage[];
}

export interface GQLErrorPayload extends GQLPushButtonPayload, GQLUpdateWidgetFocusPayload {
export interface GQLErrorPayload extends GQLPushButtonPayload {
messages: GQLMessage[];
}

export interface GQLUpdateWidgetFocusMutationVariables {
input: GQLUpdateWidgetFocusInput;
}

export interface GQLUpdateWidgetFocusInput {
id: string;
editingContextId: string;
representationId: string;
widgetId: string;
selected: boolean;
}

export interface GQLUpdateWidgetFocusMutationData {
updateWidgetFocus: GQLUpdateWidgetFocusPayload;
}

export interface GQLUpdateWidgetFocusPayload {
__typename: string;
}

export interface GQLUpdateWidgetFocusSuccessPayload extends GQLUpdateWidgetFocusPayload {}
Loading

0 comments on commit 3d9ee82

Please sign in to comment.