Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Updates the handling of the create machine callback handlers to update the existing model instead of destroying and re-creating #504

Merged
merged 4 commits into from Aug 21, 2014

Conversation

hatched
Copy link
Contributor

@hatched hatched commented Aug 19, 2014

Destroying and re-creating the machine model caused the tokens to disappear then re-appear when the deltas came in. Updating the models instead keeps them in the DOM.

Created a new module called 'yui-patches' as a place to put monkey patches to the YUI codebase.

@jujugui
Copy link
Contributor

jujugui commented Aug 19, 2014

Test FAILed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/juju-gui/1652/

Jeff Pihach added 3 commits August 19, 2014 12:26
…o the YUI source tree.

Update the machine model id when the juju ACK comes in using the new lazy-model-list method updateModelId
@hatched hatched force-pushed the update-ghost-models-1348163 branch from a7c3179 to 140b133 Compare August 19, 2014 21:01
@hatched
Copy link
Contributor Author

hatched commented Aug 19, 2014

To QA

This will need to be QA'd under sandbox and a real env (LXC, EC2, etc).
Use the mv flag.

  • Switch to machine view
  • Add a machine
  • Deploy the machine
  • The machine token should change from a ghost token to a real machine token without disappearing.

Also do exploratory QA around things which create machines/containers to make sure they all still work.

@@ -1210,7 +1210,7 @@ YUI.add('juju-models', function(Y) {
@return {Object} The newly created model instance.
*/
addGhost: function(parentId, containerType, attrs) {
var obj = attrs ? Y.clone(attrs) : Object.create(null);
var obj = attrs ? Y.clone(attrs) : {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

YUI uses the native object prototype methods when reviving a LML model to a Y.Model

@jujugui
Copy link
Contributor

jujugui commented Aug 19, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/juju-gui/1653/

@return {Object} The model object with the updated id. Or Throws if the
requested id is already in the id map.
*/
Y.LazyModelList.prototype.updateModelId = function(model, newId, revive) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a totally new function, right, not overwriting anything?

Is there any argument for creating our own extension of the model list and extending that for service list &c?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally new, correct.

The argument was that I didn't want to have to go and change everywhere in the app which uses it and then re-test the entire app :) This way anyone using LML will just get that functionality. Maybe if we end up adding more than a single method it'll make sense to do that, but atm I think it would be overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per the discussion on IRC. The reason this is an issue in LML is that the LML has an internal ID map which is only updated on add and remove so you cannot update the id on an object within the LML and still have it work correctly.

@jcsackett
Copy link
Contributor

So, most of this looks fine; I'm really not sold on monkey patching LazyModelList rather than just adding the updateId function to the existing db lists.

Given its current usage you could actually add it to just the machine list, couldn't you? I'm willing to be convinced otherwise, but right now I don't see the logic in favor of globally patching YUI for this.

@hatched
Copy link
Contributor Author

hatched commented Aug 20, 2014

Yes it could be added to the machine list, or anywhere really but imho it makes sense to put it on the lml as it's a limitation of the default functionality which is being patched by adding a method to fix said functionality.

@kadams54
Copy link
Contributor

It seems like the container token(s) aren't being re-rendered after the ack comes back. The machine token switches from uncommitted to committed, but the container (bare metal) does not.

To reproduce:

Walk through the QA steps above. Once you complete them, the machine token will be as described, but the root container/bare metal container token will still have the blue uncommitted dot. I think it's just a rendering issue because if I deselect and reselect the machine (i.e., force the container token to re-render) the normal deployed state is used.

@jcsackett
Copy link
Contributor

After discussion on IRC, I'm good with the patch. Please add a test for it as we discussed.

With that, 👍

@hatched hatched force-pushed the update-ghost-models-1348163 branch from 140b133 to 004b857 Compare August 21, 2014 18:05
@hatched
Copy link
Contributor Author

hatched commented Aug 21, 2014

Thanks for the reviews. As discussed on IRC @kadams54 I'll be deferring the fix for that bug to an immediate follow-up as it was a pre-existing condition exposed by this work.

:shipit:

@jujugui
Copy link
Contributor

jujugui commented Aug 21, 2014

Status: merge request accepted. Url: http://ci.jujugui.org:8080/job/juju-gui-merge

@jujugui
Copy link
Contributor

jujugui commented Aug 21, 2014

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/juju-gui/1664/

jujugui added a commit that referenced this pull request Aug 21, 2014
Updates the handling of the create machine callback handlers to update the existing model instead of destroying and re-creating

Destroying and re-creating the machine model caused the tokens to disappear then re-appear when the deltas came in. Updating the models instead keeps them in the DOM.

Created a new module called 'yui-patches' as a place to put monkey patches to the YUI codebase.
@jujugui jujugui merged commit a483b2a into juju:develop Aug 21, 2014
@hatched hatched deleted the update-ghost-models-1348163 branch August 21, 2014 21:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants