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

JBPM-5538 & JBPM-5449: Popups for unsaved data and no changes since last save #920

Merged

Conversation

Christopher-Chianelli
Copy link
Contributor

Depends on #910, which depends on kiegroup/droolsjbpm-build-bootstrap#449. The unsaved changes message will not appear if you make any changes now. Additionally, if you try saving without making any changes, a popup will appear informing you that there are no changes since you last saved. Some components hashCode functions need to be updated so that it changes when the component changes.

@kie-ci
Copy link

kie-ci commented Jun 5, 2017

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

3 similar comments
@kie-ci
Copy link

kie-ci commented Jun 5, 2017

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

@kie-ci
Copy link

kie-ci commented Jun 5, 2017

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

@kie-ci
Copy link

kie-ci commented Jun 5, 2017

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

@Christopher-Chianelli Christopher-Chianelli force-pushed the save-popup-always-show branch 4 times, most recently from 734bfb3 to 0d6e08e Compare June 9, 2017 12:39
@romartin
Copy link
Contributor

romartin commented Jun 9, 2017

ok to test

@romartin
Copy link
Contributor

romartin commented Jun 9, 2017

Hey @Christopher-Chianelli , first of all thanks for this.
I just realized now that this PR exists hehe, feel free for next times, when creating PRs for Stunner, to add a reference to my github user in the comment, this way I will receive the notification and will start as soon as possible the review :) Up to you!
Thanks!

Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

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

Hey @Christopher-Chianelli , tested and it works good yeah, anyway there are still missing a couple of things:

  • It's missing to add the equals/hashCode implementations tfor the beans in the CaseManagement API modules, as it's being considered a KIE editor too.
  • Unit tests in general - so for HashUtils methods, unit tests for the updates in AbstractProjectDiagramEditor, and probably makes sense too creating a single test class for testing the equality for all existing BPMN and another one for testing CM nodes..
    Thanks!!

@Christopher-Chianelli Christopher-Chianelli force-pushed the save-popup-always-show branch 3 times, most recently from bde023b to aa4559e Compare June 13, 2017 15:27
@Christopher-Chianelli
Copy link
Contributor Author

@romartin I added equals and hashCode functions for the remaining beans, and wrote tests for saving, HashUtils, and equals/hashCode.

Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

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

Hey @Christopher-Chianelli , thanks it's almost completed hehe! Just added a few comments, hope easy to fix in a bit. On the other hand good job, tested and it works good.
BTW please remember to squash into a single commit!
Thanks!

}

@Override
public void endEdgeTraversal(final Edge edge) {
Copy link
Contributor

@romartin romartin Jun 13, 2017

Choose a reason for hiding this comment

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

the method endEdgeTraversal can be removed - no need to override this method, as already exist a default method on the interface

Copy link
Contributor Author

@Christopher-Chianelli Christopher-Chianelli Jun 13, 2017

Choose a reason for hiding this comment

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

@romartin done! The two methods that just called the default were there just in case I need to modify them; since I don't they were removed. The multiple if statements were there since before for some reason my hashCode implementation for the nodes weren't being called. I have squashed all the commits. Note that this branch is now based at HEAD~1, since the current master branch is not compiling due to missing methods.

int[] myHashArr = hashArr;
@Override
public void
startGraphTraversal(final org.kie.workbench.common.stunner.core.graph.Graph graph) {
Copy link
Contributor

@romartin romartin Jun 13, 2017

Choose a reason for hiding this comment

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

the method startGraphTraversal can be removed - no need to override this method, as already exist a default method on the interface

super.startEdgeTraversal(edge);
final Object content = edge.getContent();
myHashArr[0] = HashUtil.combineHashCodes(myHashArr[0], content.hashCode());
if (content instanceof Child) {
Copy link
Contributor

@romartin romartin Jun 13, 2017

Choose a reason for hiding this comment

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

I think that the different hash values combined inside these if sentences (not only this one, I mean all in this method) are not necessary, so in this method only combining the hash for the edge.getContent() should be enough. I think it's true because both sources and target nodes for each edge instance, are already being processed in the other callback method startNodeTraversal, so probably you're duplicating the hashes twice this way.
Does it makes sense? Can you try it please?

Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

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

Yeah sounds good now @Christopher-Chianelli , thanks! :)

@romartin
Copy link
Contributor

CC @manstis @hasys in case you want to review too :)

@manstis manstis requested a review from hasys June 14, 2017 07:38
Copy link
Member

@manstis manstis left a comment

Choose a reason for hiding this comment

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

Added @hasys for review too.

Could you please also run code formatter over the changes as I see a number of inconsistencies. It might also be worth adding similar changes to the Case Management definitions.

@@ -0,0 +1,19 @@
package org.kie.workbench.common.stunner.core.util;
Copy link
Member

Choose a reason for hiding this comment

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

License

@@ -0,0 +1,334 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
Copy link
Member

Choose a reason for hiding this comment

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

2017

@@ -28,4 +29,24 @@ public DiagramImpl(final @MapsTo("name") String name,
super(name,
metadata);
}

@Override
public int hashCode()
Copy link

@jomarko jomarko Jun 14, 2017

Choose a reason for hiding this comment

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

This hashCode() and equals() below are kind of suspicious for me. Are we sure that getGraph() returns always non null value? Same question about getMetadata() and getName().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for finding that! Before, HashUtil.combineHashCodes took an array of Objects and called hashCode on each of them (after doing a null check). However, it always called Object's hashCode implementation, so I changed it to take an array of ints.

@Christopher-Chianelli Christopher-Chianelli force-pushed the save-popup-always-show branch 2 times, most recently from 74bcf50 to e400932 Compare June 14, 2017 14:30
@Christopher-Chianelli
Copy link
Contributor Author

Reformatted code, added/updated copyright and added more null checks.

Copy link
Member

@manstis manstis left a comment

Choose a reason for hiding this comment

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

@Christopher-Chianelli Please resolve the merge conflict.

@Christopher-Chianelli
Copy link
Contributor Author

Resolved; we inserted packages at the same line. (I might have forgotten to alphabetize the order though...)

@Christopher-Chianelli
Copy link
Contributor Author

(now alphabetized)

@hasys
Copy link
Member

hasys commented Jun 15, 2017

Jenkins execute full downstream build

@Christopher-Chianelli Christopher-Chianelli force-pushed the save-popup-always-show branch 2 times, most recently from 6d43b27 to e0522bf Compare June 16, 2017 19:05
@kie-ci
Copy link

kie-ci commented Jun 19, 2017

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

@romartin
Copy link
Contributor

ok to test

@hasys
Copy link
Member

hasys commented Jun 20, 2017

Jenkins execute full downstream build

Copy link
Member

@hasys hasys left a comment

Choose a reason for hiding this comment

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

Hi @Christopher-Chianelli,
thank you, looks good! Just some thoughts from me:

  • BUG: Open process, move any node, try to save => you will see "You have no unsaved changes."
  • Improvements: Show notification "You have no unsaved changes.", not Error.
  • Also tasks and unrelated issues were reported: JBPM-6126, JBPM-6127, JBPM-6128.
  • about missing tests see inline comments and JBPM-6126

dimensionsSet.equals(other.dimensionsSet);
}
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

Not tested methods.

dataIOSet.equals(other.dataIOSet);
}
return super.equals(o);
}
Copy link
Member

Choose a reason for hiding this comment

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

Not tested methods.

} else {
return false;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Not tested methods.

} else {
return false;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Not tested additions.

return false;
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Not tested methods.


private boolean hasUnsavedChanges() {
return getCurrentDiagramHash() != originalHash;
}
Copy link
Member

Choose a reason for hiding this comment

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

No tests for changes in the file.

continueSaveOnceValid.execute();
} else {
//TODO: Localize message
errorPopupPresenter.showMessage("You have no unsaved changes.");
Copy link
Member

Choose a reason for hiding this comment

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

I see duplicated not localized literal. @romartin how do we handle it for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes sure, please inject the TranslationService so you can use errai i18n here. Thanks!! :)

@romartin
Copy link
Contributor

Hey @Christopher-Chianelli , please can you verify that latest included BPMN bean, the EmbeddedSubprocess, does also contains the right equals/hasCode methods? This new bean has been added a few days ago, before this commit, so probably it needs to override that methods too.
Thanks!

@Christopher-Chianelli
Copy link
Contributor Author

I cannot really check anything that been added in the last commit, @romartin; the last commit fails to build on master due to missing classes (BlobImpl, I think, from uberfire). I can add the hashCode/equals, but I won't be able to test or run it on the webclient (compilation fails during gwt compile, not mvn build).

@romartin
Copy link
Contributor

Hey @Christopher-Chianelli , mmm the build works for me, but yeahh not sure why Errai snapshots seem not to be building on nexus for last few days... anyway building it locally makes it work, so please just build latest Errai and Uberfire locally and you will be able to build & run the app. Lemme know if any issues! Thanks!

@Christopher-Chianelli
Copy link
Contributor Author

That fixed it! Thanks @romartin!

@Christopher-Chianelli Christopher-Chianelli force-pushed the save-popup-always-show branch 3 times, most recently from 5d0e608 to a54f2f2 Compare June 22, 2017 20:58
@Christopher-Chianelli
Copy link
Contributor Author

Added bunch of tests, made moving nodes count as changes and did localization (I think, notify me if I made a mistake). Also added hashCode and equals for EmbeddedSubprocess.

@romartin
Copy link
Contributor

Jenkins execute full downstream build

Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

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

Hey @Christopher-Chianelli
Rather than just a couple of minor things, all good for me, tested and it works fine.
Requesting only these minor changes and then all good for me, can be merged.
Thanks!

super.onSave();
}
else {
//TODO: Localize message
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this TODO can be removed

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 only wrote the message in the English Common Constants properties file, so I don't know how it'll behave in other languages.

}
else {
//TODO: Localize message
Window.alert(CommonConstants.INSTANCE.NoChangesSinceLastSave());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please better using the method showError (in this class), it uses an uberfire generic popup widget - we should avoid the use of Window.alert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want it to be an error or notification? @hasys requested for it to be a notification (since I couldn't find a notification class that is applicable to what data I have at the time of the popup, so I used WIndow.alert for a generic notification).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sorry, I mean something like this:
image

Just notification, no Message Dialog with buttons.

@hasys
Copy link
Member

hasys commented Jun 23, 2017

Jenkins execute full downstream build

@Christopher-Chianelli
Copy link
Contributor Author

Changed Window.alert to an info notification and removed the TODO @romartin @hasys.

Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

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

Great, thanks @Christopher-Chianelli !!

@hasys
Copy link
Member

hasys commented Jun 26, 2017

Jenkins execute full downstream build

Copy link
Member

@hasys hasys left a comment

Choose a reason for hiding this comment

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

Hi @Christopher-Chianelli,

thank you, looks really cool! Sorry, but I found one issue there JBPM-6157, but guess it's better to merge this PR and fix bug later (in current Sprint or next one).

@Christopher-Chianelli
Copy link
Contributor Author

Thanks for informing me @hasys! I'll start investigating the issue immediately.

@Christopher-Chianelli
Copy link
Contributor Author

Fixed issue @hasys, should I just push the fix to this branch?

@hasys
Copy link
Member

hasys commented Jun 27, 2017

Hi @Christopher-Chianelli, for me two small PR are better than one huge. If it's possible I prefer merge this one (it is already big one) and send new PR. Thank you!

Copy link

@jomarko jomarko left a comment

Choose a reason for hiding this comment

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

My inputs incorporated. Thanks.

@manstis manstis merged commit ef84b62 into kiegroup:master Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants