Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Add initial ADR for the selection dialog as a tree #3723

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

florianbarbin
Copy link
Contributor

Pull request template

General purpose

What is the main goal of this pull request?

  • Bug fixes
  • New features
  • Documentation
  • Cleanup
  • Tests
  • Build / releng

Project management

  • Has the pull request been added to the relevant project and milestone? (Only if you know that your work is part of a specific iteration such as the current one)
  • Have the priority: and pr: labels been added to the pull request? (In case of doubt, start with the labels priority: low and pr: to review later)
  • Have the relevant issues been added to the pull request?
  • Have the relevant labels been added to the issues? (area:, difficulty:, type:)
  • Have the relevant issues been added to the same project and milestone as the pull request?
  • Has the CHANGELOG.adoc been updated to reference the relevant issues?
  • Have the relevant API breaks been described in the CHANGELOG.adoc? (Including changes in the GraphQL API)
  • In case of a change with a visual impact, are there any screenshots in the CHANGELOG.adoc? For example in doc/screenshots/2022.5.0-my-new-feature.png

Architectural decision records (ADR)

  • Does the title of the commit contributing the ADR start with [doc]?
  • Are the ADRs mentioned in the relevant section of the CHANGELOG.adoc?

Dependencies

  • Are the new / upgraded dependencies mentioned in the relevant section of the CHANGELOG.adoc?
  • Are the new dependencies justified in the CHANGELOG.adoc?

Frontend

This section is not relevant if your contribution does not come with changes to the frontend.

General purpose

  • Is the code properly tested? (Plain old JavaScript tests for business code and tests based on React Testing Library for the components)

Typing

We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).

  • Variables have a proper type
  • Functions’ arguments have a proper type
  • Functions’ return type are specified
  • Hooks are properly typed:
    • useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
    • useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
    • useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
    • useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
    • useState<STATE_TYPE>(…)
  • All components have a proper typing for their props
  • No useless optional chaining with ?. (if the GraphQL API specifies that a field cannot be null, do not treat it has potentially null for example)
  • Nullable values have a proper type (for example let diagram: Diagram | null = null;)

Backend

This section is not relevant if your contribution does not come with changes to the backend.

General purpose

  • Are all the event handlers tested?
  • Are the event processor tested?
  • Is the business code (services) tested?
  • Are diagram layout changes tested?

Architecture

  • Are data structure classes properly separated from behavioral classes?
  • Are all the relevant fields final?
  • Is any data structure mutable? If so, please write a comment indicating why
  • Are behavioral classes either stateless or side effect free?

Review

How to test this PR?

Please describe here the various use cases to test this pull request

  • Has the Kiwi TCMS test suite been updated with tests for this contribution?

Copy link
Contributor

@AxelRICHARD AxelRICHARD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok on my side


In addition, the Selection computed by the `SelectionRender` by the server will now return the containment information:
The GraphQL subscription query will thus have a fixed depth. The containment information will be owned by a field called `parentId`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about that? What about an update of the subscription that will modify the depth of the tree?

Copy link
Contributor Author

@florianbarbin florianbarbin Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the TreePropertySection and it uses that kind of data structure to deal with that issue.
I did not understand the first time why we made this choice but when I started to implement this ADR I understood why: we can't build a recursive query without knowing the tree depth.

Are you sure about that? What about an update of the subscription that will modify the depth of the tree?

I'm not sure to understand: that would suppose to have the depth information updated and sent a new request with the same containment depth with

objects {
   ...
   objects {
  	...
  	objects {
    	etc.
        }
    }
}

Copy link
Contributor Author

@florianbarbin florianbarbin Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it is what we doing for diagrams but I suppose that it makes sense to limit the node hierarchy:
(see in diagramFragment.ts)

nodes {
    ...nodeFragment
    borderNodes {
      ...nodeFragment
    }
    childNodes {
      ...nodeFragment
      borderNodes {
        ...nodeFragment
      }
      childNodes {
        ...nodeFragment
        borderNodes {
          ...nodeFragment
        }
        childNodes {
          ...nodeFragment
          borderNodes {
            ...nodeFragment
          }
          childNodes {
            ...nodeFragment
            borderNodes {
              ...nodeFragment
            }
            childNodes {
              ...nodeFragment
              borderNodes {
                ...nodeFragment
              }
            }
          }
        }
      }
    }
  }

@@ -107,6 +118,8 @@ Root
|_ (F)
```

==== Frontend
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about an update of the subscription that will modify the tree? You should also be able to keep the already expanded nodes expanded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, keeping the expanded state locally to the user makes sense since we don't share the representation with others.

@florianbarbin florianbarbin force-pushed the fba/doc/adr153 branch 2 times, most recently from e129ca6 to ea2acd9 Compare July 10, 2024 09:54
@florianbarbin florianbarbin force-pushed the fba/enh/SelectionDialog branch from f9ec7fb to c022bec Compare July 10, 2024 10:10
@florianbarbin florianbarbin changed the base branch from fba/enh/SelectionDialog to fba/doc/adr_152 July 10, 2024 10:12
@sbegaudeau sbegaudeau force-pushed the fba/doc/adr_152 branch 2 times, most recently from a8b0435 to 5d1ab9b Compare July 15, 2024 14:07
Base automatically changed from fba/doc/adr_152 to master July 15, 2024 14:09
@sbegaudeau
Copy link
Member

I've rebased the PR, I'll look into it


== Context

We have restored the previous deactivated Selection Dialog in the context of the ADR: _[ADR-152] Reactivate the Selection Dialog Tool_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference of the ADR has been modified

The `SelectionDialogDescription` from the Diagram View model will have two additional boolean attributes:

* `displayedAsTree`: to indicate whether the dialog layout should be a tree.
* `expandedAtOpening`: to indicate if the tree should be expanded by default (that means all tree items are expanded at opening)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this can realistically ever be a viable option given the MASSIVE performance cost that this would create in any meaningful project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to let the possibility for the specifier to reveal in the tree the selectable elements.
That would avoid for the end user to unfold each tree item to search for a specific element.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there's a difference between expanding some elements and expanding all elements (which would have a MASSIVE performance cost)

* `displayedAsTree`: to indicate whether the dialog layout should be a tree.
* `expandedAtOpening`: to indicate if the tree should be expanded by default (that means all tree items are expanded at opening)

==== Backend and GraphQL API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't re-invent a tree representation, open an alternate version of the dialog with a <TreeView /> inside and use the tree representation directly. It support more than enough features.

@florianbarbin florianbarbin force-pushed the fba/doc/adr153 branch 2 times, most recently from e2da79d to d9c93d8 Compare August 8, 2024 08:57
Comment on lines +50 to +54
The specifier will choose whether the objects returned by the candidates expression will be displayed as a tree or as a flat list.

The `SelectionDialogDescription` from the Diagram View model will have an additional boolean attributes:

* `displayedAsTree`: to indicate whether the dialog layout should be a tree.
Copy link
Member

@sbegaudeau sbegaudeau Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be enough? How can you figure out how to display a simple list as a tree? We should probably hardcore a TreeDescription in the view converter for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand. For me, we will have an hard-coded TreeDescription but provider by an IEditingContextRepresentationDescriptionProvider ?


==== Backend and GraphQL API

If the displayedAsTree is true, we will rely on the TreeRepresentation instead of the current SelectionRepresentation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will the specifier be able to configure that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the specifier will only indicate by a boolean (a checkbox in the studio) in the SelectionDescription whether he want to display the selectable element as a list or as a tree.

Comment on lines +73 to +74
displayedAsTree: Boolean!
objects: [SelectionObject!]!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to reuse a tree subscription instead of the raw selection subscription with its list of objects. I don't understand why this needs to be modified and why displayedAsTree should exist on both Selection and its description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with that but I still have a problem with the "message"

I agree to avoid opening a subscription toward the SelectionRepresentation if the SelectionDialog is intended to represent selectable elements as a tree (in this case we will rely on the TreeView).

The message specified by the specifier is for now not interpreted but the SelectionDescription java pojo code relies on a messageProvider (Function<VariableManager, String>) so it could be interpreted in the future.

So in this case, I'm not sure what I should do to compute the dialog message which is common for both flat and tree representations.

Should I provide the displayAsTree and the message statically by passing them in the graphQL API :

instead of :

type SingleClickOnDiagramElementTool implements Tool {
  id: ID!
  label: String!
  iconURL: [String!]!
  appliesToDiagramRoot: Boolean!
  dialogDescriptionId: String
  targetDescriptions: [DiagramElementDescription!]!
}

We will have :

type SingleClickOnDiagramElementTool implements Tool {
  id: ID!
  label: String!
  iconURL: [String!]!
  appliesToDiagramRoot: Boolean!
  dialogDescription: DialogDescription
  targetDescriptions: [DiagramElementDescription!]!
}



type DialogDescription {
  id: String!
  parameters; [DialogDescriptionParamter!]!
}

type DialogDescriptionParamter {
  key: String!
  value; String!
}

Comment on lines +79 to +82
==== Tree computation Algorithm

Starting from objects returned by the candidates expression, we will compute all the ancestors hierarchy until we reach the root document.

Copy link
Member

@sbegaudeau sbegaudeau Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will use the tree subscription which let the specifier define how the tree structure is organized. We won't define any magic algorithm to create a tree, it's the plain old tree representation which can be organized any way we want. It may not follow EMF's EObject#eContents topological structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to describe how we will represent selectable elements.
It will be similar to org.eclipse.sirius.components.collaborative.widget.reference.browser.ModelBrowsersDescriptionProvider which remove all non selectable leaf from the result in getChildren


If the value of `displayedAsTree` is false, then we keep the current behavior.

If the value of `displayedAsTree` is true, then we will use the `TreeView` component to display the content. We will have something similar to the following code:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, and if it's not true, we will fallback on the existing selection subscription which means that this displayedAsTree boolean cannot be part of the selection subscription in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbegaudeau
Copy link
Member

This ADR has served its purpose as a support for the discussion, I'll merge it as is for now, it can be updated later to reflect the final state of the choices made.

@sbegaudeau sbegaudeau merged commit 9e290b3 into master Aug 28, 2024
3 checks passed
@sbegaudeau sbegaudeau deleted the fba/doc/adr153 branch August 28, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants