-
Notifications
You must be signed in to change notification settings - Fork 218
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
JBPM-5538 & JBPM-5449: Popups for unsaved data and no changes since last save #920
Conversation
Can one of the admins verify this PR? Comment with 'ok to test' to start the build. |
3 similar comments
Can one of the admins verify this PR? Comment with 'ok to test' to start the build. |
Can one of the admins verify this PR? Comment with 'ok to test' to start the build. |
Can one of the admins verify this PR? Comment with 'ok to test' to start the build. |
734bfb3
to
0d6e08e
Compare
ok to test |
Hey @Christopher-Chianelli , first of all thanks for this. |
There was a problem hiding this 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!!
bde023b
to
aa4559e
Compare
@romartin I added equals and hashCode functions for the remaining beans, and wrote tests for saving, HashUtils, and equals/hashCode. |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
aa4559e
to
d9278bc
Compare
There was a problem hiding this 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! :)
There was a problem hiding this 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; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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.
74bcf50
to
e400932
Compare
Reformatted code, added/updated copyright and added more null checks. |
There was a problem hiding this 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.
Resolved; we inserted packages at the same line. (I might have forgotten to alphabetize the order though...) |
9d7ae06
to
aac4587
Compare
(now alphabetized) |
Jenkins execute full downstream build |
6d43b27
to
e0522bf
Compare
Can one of the admins verify this PR? Comment with 'ok to test' to start the build. |
ok to test |
Jenkins execute full downstream build |
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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); | ||
} |
There was a problem hiding this comment.
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; | ||
} | ||
} |
There was a problem hiding this comment.
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; | ||
} | ||
} |
There was a problem hiding this comment.
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; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!! :)
Hey @Christopher-Chianelli , please can you verify that latest included BPMN bean, the |
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). |
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! |
That fixed it! Thanks @romartin! |
5d0e608
to
a54f2f2
Compare
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 |
Jenkins execute full downstream build |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jenkins execute full downstream build |
a54f2f2
to
386ec28
Compare
There was a problem hiding this 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 !!
Jenkins execute full downstream build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
Thanks for informing me @hasys! I'll start investigating the issue immediately. |
Fixed issue @hasys, should I just push the fix to this branch? |
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! |
There was a problem hiding this 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.
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.