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

Mutables for the Tree 🎄 + clean up TreeItem observers and mutables properly #6032

Merged
merged 29 commits into from
Dec 20, 2022

Conversation

ozyx
Copy link
Member

@ozyx ozyx commented Dec 1, 2022

Closes #5982 #5975

Describe your changes:

  • Use MutableDomainObjects within the main tree if object supports mutation
  • Refresh the conflicted object after a conflict error on save
  • Handle errors thrown during create, ensure that the "Saving" modal is always closed
  • If currently navigated item doesn't have a path to root (non-persisted object after conflict), default the Create modal's selected item to the "mine" folder
  • Fix issue where tree item observers were not being destroyed (at all)
  • Fix issue where the removal of a parent item only destroyed the parent's observer, and not the childrens' observers
  • Do not assign any listeners, observers, or mutables if the tree is a SelectorTree (tree within the create modal)

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots.

Author Checklist

  • Changes address original issue?
  • Tests included and/or updated with changes?
  • Command line build passes?
  • Has this been smoke tested?
  • Testing instructions included in associated issue OR is this a dependency/testcase change?

Reviewer Checklist

  • Changes appear to address issue?
  • Reviewer has tested changes by following the provided instructions?
  • Changes appear not to be breaking changes?
  • Appropriate automated tests included?
  • Code style and in-line documentation are appropriate?
  • Has associated issue been labelled unverified? (only applicable if this PR closes the issue)
  • Has associated issue been labelled bug? (only applicable if this PR is for a bug fix)

- Ensure that the "Saving" modal dialog is closed

- Notify user of the error, and also print to console to catch in e2e
- If create fails due to a conflict or otherwise, and the user immediately tries to "Create" again, default the selector tree's selected item to the "mine" folder (which we know exists).
- Only use mutables and observers if NOT a SelectorTree

- Properly clean up observers and mutables when a parent item is removed from the tree
@ozyx ozyx added this to the Target:2.1.4 milestone Dec 1, 2022
@ozyx ozyx changed the title Mutables for the Tree + clean up TreeItem observers and mutables properly Mutables for the Tree 🎄 + clean up TreeItem observers and mutables properly Dec 1, 2022
@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #6032 (829025b) into master (1a4bd0f) will decrease coverage by 0.08%.
The diff coverage is 20.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6032      +/-   ##
==========================================
- Coverage   55.07%   54.99%   -0.09%     
==========================================
  Files         600      600              
  Lines       23696    23748      +52     
  Branches     2109     2112       +3     
==========================================
+ Hits        13051    13060       +9     
- Misses      10055    10098      +43     
  Partials      590      590              
Flag Coverage Δ *Carryforward flag
e2e-ci 39.49% <57.14%> (ø) Carriedforward from 1a4bd0f
e2e-full 51.23% <50.00%> (ø) Carriedforward from 1a4bd0f
e2e-stable 50.04% <28.57%> (-0.01%) ⬇️
unit 50.73% <14.51%> (-0.05%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
src/api/Editor.js 51.72% <0.00%> (-1.85%) ⬇️
...c/plugins/persistence/couch/CouchObjectProvider.js 49.48% <0.00%> (-0.96%) ⬇️
src/ui/layout/BrowseBar.vue 46.59% <0.00%> (-0.54%) ⬇️
src/ui/layout/mct-tree.vue 10.50% <4.25%> (+<0.01%) ⬆️
src/api/objects/ObjectAPI.js 89.74% <85.71%> (-1.45%) ⬇️
src/plugins/formActions/CreateAction.js 96.34% <85.71%> (-0.68%) ⬇️
src/plugins/charts/bar/BarGraphView.vue 54.49% <0.00%> (-3.00%) ⬇️
src/plugins/gauge/components/Gauge.vue 62.50% <0.00%> (-0.63%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a4bd0f...829025b. Read the comment docs.

@ozyx ozyx added the pr:e2e:couchdb npm run test:e2e:couchdb label Dec 2, 2022
- Error notification on 'My Items' folder missing was removed, so don't check for it
@ozyx ozyx added pr:e2e:couchdb npm run test:e2e:couchdb and removed pr:e2e:couchdb npm run test:e2e:couchdb labels Dec 2, 2022
@ozyx ozyx added pr:e2e:couchdb npm run test:e2e:couchdb and removed pr:e2e:couchdb npm run test:e2e:couchdb labels Dec 2, 2022
@ozyx ozyx added pr:e2e:couchdb npm run test:e2e:couchdb and removed pr:e2e:couchdb npm run test:e2e:couchdb labels Dec 2, 2022
@ozyx ozyx marked this pull request as ready for review December 2, 2022 18:56
Copy link
Collaborator

@unlikelyzero unlikelyzero left a comment

Choose a reason for hiding this comment

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

This is the most I could do from my phone

e2e/tests/functional/couchdb.e2e.spec.js Show resolved Hide resolved
e2e/tests/functional/forms.e2e.spec.js Outdated Show resolved Hide resolved
const page2 = await page.context().newPage();

await Promise.all([
page.goto('./', { waitUntil: 'networkidle' }),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Woah

createDomainObjectWithDefaults(page2, {
type: 'Clock'
})
]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love this pattern

]);

// Start logging console errors from this point on
let errors = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we waiting until now because of the mine error we couldn't solve last sprint

Copy link
Member Author

Choose a reason for hiding this comment

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

Waiting until now so that we don't capture the expected 409 error from couchdb

e2e/tests/functional/forms.e2e.spec.js Outdated Show resolved Hide resolved
@ozyx ozyx removed the pr:e2e:couchdb npm run test:e2e:couchdb label Dec 2, 2022
@scottbell
Copy link
Contributor

scottbell commented Dec 5, 2022

Testing creation of objects after a conflict appears to work:

Screen.Recording.2022-12-05.at.7.26.04.PM.mov

Copy link
Contributor

@scottbell scottbell left a comment

Choose a reason for hiding this comment

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

LGTM

@ozyx ozyx modified the milestones: Target:2.1.4, Target:2.1.5 Dec 5, 2022
if (checkItem.navigationPath !== path
&& checkItem.navigationPath.includes(path)) {
this.destroyObserverByPath(checkItem.navigationPath);
this.destroyMutableByPath(checkItem.navigationPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@ozyx ozyx requested a review from jvigliotta December 5, 2022 23:41
Copy link
Contributor

@akhenry akhenry left a comment

Choose a reason for hiding this comment

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

This looks really awesome. Just a couple of questions. Thanks!

src/ui/layout/mct-tree.vue Outdated Show resolved Hide resolved
src/ui/layout/mct-tree.vue Show resolved Hide resolved
src/ui/layout/mct-tree.vue Outdated Show resolved Hide resolved
- Remove check for typeof 'function' to not hide any potential coding errors
@ozyx ozyx requested a review from akhenry December 16, 2022 21:06
Copy link
Contributor

@akhenry akhenry left a comment

Choose a reason for hiding this comment

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

I found a small issue in testing - #5982 (comment)

@ozyx ozyx requested a review from akhenry December 19, 2022 19:41
@ozyx
Copy link
Member Author

ozyx commented Dec 19, 2022

I found a small issue in testing - #5982 (comment)

OK, I think I've got a fix for this. We rethrow the error on a conflicted save, allowing saveAndFinishEditing() to catch it. Then we just cancel out of the existing edit session, triggering the re-render on the layout. Lemme know if you see any potential issues with this approach.

@ozyx ozyx enabled auto-merge (squash) December 20, 2022 17:38
@@ -234,7 +234,8 @@ class CouchObjectProvider {
#handleResponseCode(status, json, fetchOptions) {
this.indicator.setIndicatorToState(this.#statusCodeToIndicatorState(status));
if (status === CouchObjectProvider.HTTP_CONFLICT) {
throw new this.openmct.objects.errors.Conflict(`Conflict persisting ${fetchOptions.body.name}`);
const objectName = JSON.parse(fetchOptions.body)?.model?.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

YES. Thank you for doing doing this. I was running into this one as well.

@jvigliotta jvigliotta self-requested a review December 20, 2022 20:48
Copy link
Contributor

@jvigliotta jvigliotta left a comment

Choose a reason for hiding this comment

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

Looks great! Awesome work!

@ozyx ozyx merged commit d6e8044 into master Dec 20, 2022
@jvigliotta jvigliotta deleted the mct5982 branch December 20, 2022 21:27
ozyx added a commit that referenced this pull request Dec 29, 2022
…vers and mutables properly

* fix: refresh object after conflict error

* fix: recover from error thrown during create

- Ensure that the "Saving" modal dialog is closed

- Notify user of the error, and also print to console to catch in e2e

* fix: default selector tree item to 'mine' folder

- If create fails due to a conflict or otherwise, and the user immediately tries to "Create" again, default the selector tree's selected item to the "mine" folder (which we know exists).

* fix: don't listen to composition if Selector Tree

* refactor: remove dead code

* fix: use MutableDomainObjects in the tree

- Only use mutables and observers if NOT a SelectorTree

- Properly clean up observers and mutables when a parent item is removed from the tree

* test: verify conflicts don't break object creation

* test: verify dialog closes and object is created

* refactor(e2e): update test

- Error notification on 'My Items' folder missing was removed, so don't check for it

* test: increase timeout

* refactor(e2e): use Promise.any()

* refactor(e2e): use Promise instead of polling

* test: add 2p annotation

* test: use `waitForRequest` instead of promise

- tidy up test, add comments describing our pattern

* docs(e2e): add best practices for network tests

* refactor(e2e): avoid using Promise.any

* fix: de-reactify observer and mutable maps

* fix: destroy by path on treeItem close

* fix: don't refresh for synchronized objects

* docs: fix a typo 🔥

* fix: remove existing mutable before adding

* fix: fail fast if these aren't functions

- Remove check for typeof 'function' to not hide any potential coding errors

* fix: walk up navigationPath if item not found

* chore: fix lint errors

* fix: parse conflicted object name correctly

* fix: re-throw conflict error

* fix: Cancel edit mode on conflict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:e2e:couchdb npm run test:e2e:couchdb
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CouchDB] Creating an object hangs forever after receiving a conflict error
5 participants