vaadin / collaboration-engine

The simplest way to build real-time collaboration into web apps
https://vaadin.com/collaboration
Other
3 stars 1 forks source link

Binder doesn't populate the form when topic connection is refused #13

Closed pekam closed 3 years ago

pekam commented 3 years ago

Describe the bug The licensing model is based on an end user quota. The default behavior for users who exceed the quota is, that the collaboration features are disabled, but the app continues to work as a single-user experience. In particular, CollaborationBinder should continue to work as the regular Binder, without the field value synchronization and field highlight features.

Currently, the user exceeding the quota can edit the form, and saving the field values back to the bean works with writeBean. However, when opening the form, the form is not populated with initial values.

To Reproduce Steps to reproduce the behavior:

  1. Create any kind of a form and use CollaborationBinder with it.
  2. Provide a callback for returning the bean with initial property values for populating the fields, e.g.:
    binder.setTopic("topic-id", () -> {
    Person p = new Person();
    p.setFirstName("first");
    p.setLastName("last");
    return p;
    });
  3. Start the app and open it as enough users to exceed the entire quota (including the grace period quota).
  4. Open the form as one more user.
  5. Notice how the fields are empty.

Expected behavior The fields should be populated with the provided values for firstName and lastName properties.

Versions

Technical details The bug occurs because CollaborationBinder populates the form with the callback provided to setTopic, and populating the form happens in the topic connection's activation callback. When the quota is exceeded, the topic is not activated.

To fix the issue, there needs to be a way for openTopicConnection to inform the caller that the connection failed. Another issue #14 has been created for this feature. After #14, the new API can be used to populate the form if the connection fails.

We can use CollaborationEngine::requestAccess to solve this. If the user has access, open a topic connection and do things as before, otherwise just populate the form.

pekam commented 3 years ago

Decided to go back from requestAccess to TopicConnectionRegistration::onConnectionFailed (#14), because using requestAccess made things complex.