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

Cannot switch hyperlink type to button when using Couch DB #5533

Closed
akhenry opened this issue Jul 18, 2022 · 3 comments · Fixed by #5643
Closed

Cannot switch hyperlink type to button when using Couch DB #5533

akhenry opened this issue Jul 18, 2022 · 3 comments · Fixed by #5643
Labels
bug:regression It used to work. Now it doesn't :( severity:critical type:bug
Milestone

Comments

@akhenry
Copy link
Contributor

akhenry commented Jul 18, 2022

When running CouchDB locally, I tried the following:

  1. Create a hyperlink object with default values
  2. Change the hyperlink type to 'button'
  3. Notice that the hyperlink switches to a button briefly, and then back to a link

I am seeing multiple requests to CouchDB after hitting 'Save':

PUT /openmct/cde9bb4c-6cda-4c49-85ff-6b4afc08782e HTTP/1.1
{
    "_id": "cde9bb4c-6cda-4c49-85ff-6b4afc08782e",
    "_rev": "2-42b15c7196783cf5c281d65dac9e2c07",
    "metadata": {
        "category": "domain object",
        "type": "hyperlink",
        "owner": "admin",
        "name": "Unnamed Hyperlink"
    },
    "model": {
        "name": "Unnamed Hyperlink",
        "type": "hyperlink",
        "displayFormat": "link",
        "linkTarget": "_self",
        "url": "https://google.com",
        "displayText": "asdfa",
        "modified": 1657739137046,
        "location": "mine",
        "persisted": 1657739137047
    }
}
POST /openmct/_all_docs?include_docs=true HTTP/1.1
{
    "keys": [
        "c26b1445-3d75-450d-8eca-3a763cc1650d",
        "a23b5c86-d69a-482a-88eb-c7a2565a522e",
        "cde9bb4c-6cda-4c49-85ff-6b4afc08782e"
    ]
}
PUT /openmct/cde9bb4c-6cda-4c49-85ff-6b4afc08782e HTTP/1.1
{
    "_id": "cde9bb4c-6cda-4c49-85ff-6b4afc08782e",
    "_rev": "3-15e9b964b936546b9294ae2b4f5c4074",
    "metadata": {
        "category": "domain object",
        "type": "hyperlink",
        "owner": "admin",
        "name": "Unnamed Hyperlink"
    },
    "model": {
        "name": "Unnamed Hyperlink",
        "type": "hyperlink",
        "displayFormat": "link",
        "linkTarget": "_self",
        "url": "https://google.com",
        "displayText": "asdfa",
        "modified": 1657739137048,
        "location": "mine",
        "persisted": 1657739137048
    }
}
PUT /openmct/cde9bb4c-6cda-4c49-85ff-6b4afc08782e HTTP/1.1
{
    "_id": "cde9bb4c-6cda-4c49-85ff-6b4afc08782e",
    "_rev": "4-a5f81288afc651b382425249dcef7812",
    "metadata": {
        "category": "domain object",
        "type": "hyperlink",
        "owner": "admin",
        "name": "Unnamed Hyperlink"
    },
    "model": {
        "name": "Unnamed Hyperlink",
        "type": "hyperlink",
        "displayFormat": "button",
        "linkTarget": "_self",
        "url": "https://google.com",
        "displayText": "asdfa",
        "modified": 1657739137049,
        "location": "mine",
        "persisted": 1657739137049
    }
}

Notice that the displayFormat does not change until the final PUT request. Sometimes this final PUT with the changed value is never fired off, in which case the property is failed to update locally and in persistence.

Originally posted by @ozyx in #5398 (comment)

@ozyx ozyx added the bug:regression It used to work. Now it doesn't :( label Jul 22, 2022
@ozyx
Copy link
Contributor

ozyx commented Jul 22, 2022

The regression was caused by some change made in this PR #5187

@ozyx
Copy link
Contributor

ozyx commented Jul 22, 2022

@akhenry

So it looks like there are a couple of things happening here.

First, EditPropertiesAction was refactored to use mutate against every property, regardless of whether or not it was changed. This means that changing one object property while using CouchDB ends up firing a PUT request to Couch for every editable property on the object.

Secondly, the Object tree was modified to listen for domainObject name changes in order to automatically alphabetize the tree. Since editing the properties will emit a change event for the 'name' regardless of whether or not it actually changed, this is firing before the CouchDB transaction completes and recreating the object tree with the outdated revision.

This has implications for editing properties on any domainObject while using CouchDB. We need a way to wait for the CouchDB transaction to complete before alphabetizing the tree again.

@jvigliotta
Copy link
Contributor

Verified Fixed - Testathon: 8/22

Was able to change to a button, naved a way, came back, still a button.

@unlikelyzero unlikelyzero added this to the Target:2.0.8 milestone Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:regression It used to work. Now it doesn't :( severity:critical type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants