-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Skip move logic if the parent is staying the same #12937
Skip move logic if the parent is staying the same #12937
Conversation
Hi there @CyberReiter, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Hello @CyberReiter , Thanks for this update, it's always better to prevent unnecessary actions 😉 I was wondering if you could also implement this on the Dictionary items move action, which is located in Cheers! |
Hey @mikecp Good catch, I totally forgot to also check Controllers for such logic! |
Hi @CyberReiter , Thanks for the update, it's good that we cover dictionary items as well 👍 I have one last remark, and I'm very sorry I did not notice it the first time. While testing today, I noticed that when we move media items and dictionary items under the same parent, we get an error message, while we get a success message in the other cases. I think it would be more consistent to have the same behavior in all cases, and I guess it is then better to align with what already existed, which would then be to display errors in the other situations.
with something like
We then get an error like this, which is similar to what we get on Dictionary: For the moving of content itself, the logic is quite different and it seems not possible to return an error without creating a full scope, so here I would leave it as you implemented it, and return a success. I'm pinging @nul800sebastiaan here to get his feeling on this. So, what do you think about all this? Would you be willing to update to the more consistent way 😁? Thanks in advance for the extra help! Cheers! |
Hi @mikecp I also found it strange that the behaviour was different for the different types but I thought I would leave it as it is for now. For the content part I would leave that out for this PR as I don't see a way of changing this without making a breaking change. |
Changed the behaviour to now show an error across the board when moving an item to its parent. For the missing translations on the content types the problem seems to be that the promise returned by the |
return umbRequestHelper.resourcePromise( | ||
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostMove"), | ||
{ | ||
parentId: args.parentId, | ||
id: args.id | ||
}, { responseType: 'text' }), | ||
promise); | ||
'Failed to move content type'); |
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 saw your comment about the promise not being returned on time, but what about keeping the promise and having something like
promise ?? 'Failed to move content type'
This way, if the promise ever gets returned on time, we get the foreseen label and otherwise we have a fallback.
What do you think? (same question in mediatype.resource of course😁 )
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.
problem is that the promise is not null but an Promise object so this won't work 🤔
There also does not seem to be an easy way of waiting for the promise to finish as there is no way to check for the state of it.
Only possibility that comes to my mind would be to have a bool which would be set to true if the promise finished in time and then set the message based on in it like so isFinished ? promise : 'Failed to move content type'
However by doing this we would introduce a 3rd way of handling this message as we already have the way it is done on the data types (static message) and another way for media (static message + taking some of the translation from the api response)
errorMsg = errorMsg + ": " + data.notifications[0].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.
Thanks for your comments @CyberReiter !
In that case, I would suggest to keep things as they are. It's already a great improvement, so it should not hold us from merging all this 😁
Thanks again for this update 👍
Cheers!
Prerequisites
Description
Added checks to ContentTypes, Content and DataTypes Move functions to skip all the logic if the parent would stay the same.
How to test
Try moving around ContentTypes, Content and DataTypes and make sure this still works as expected