-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix issues with duplicated file names in the same directory #38415
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
@jvillafanez Although this is not yet complete, could you please have a look at the overall approach? To be honest, I don't like it really much myself. It would be cleaner to replace the filename in these actions with the |
If it's just a visualization problem, I think it's better to focus on that. Just show the path or other information that could help to distinguish the files. I'm assuming that the actions are properly executed against the right files. At this point, it seems too late to try to introduce the usage of the fileids. It would be better to start from scratch rather than try to force the usage of fileids. |
That's right, we are just talking about visualization issues. But it's not only about showing something to distinguish such files in the UI. We also need to distinguish them in our code and functionality. As a result I don't think it is that easy to solve. The method that finds most of these elements is Another solution would be to add a new attribute, let's say |
Does it affect only to link shares? If so, maybe it's better to overwrite the methods in the share list, or maybe just make the changes needed there. At least, I think the code changes would be more isolated. |
Unfortunately this affects all of the following lists:
... with pretty much every action: showing details, showing share context, renaming, deleting, ... I'm really wondering why this error was just noticed now. It seems like a pretty common issue to me. |
Question: does the problem come only from the |
I did some more research on this.
Mainly, yes. If this method would work with a unique parameter instead of the name, we would solve most of the problems. However, there might still be some tiny issues where we need to adjust. For instance https://github.com/owncloud/core/blob/master/apps/files/js/filelist.js#L456 ->
I didn't find a way to get the clicked row yet. We are in the context of the filelist, so we don't now the currently clicked file. There is I tried to implement another click event which listens to any click on a row. But it does not work for elements with existing event listeners that stop further events from being executed. I'm currently checking for other ways to get the clicked file. |
I remember noticing these sort of issues in the past. With the development phoenix We can easily expand the UI test coverage if needed. |
I'm afraid there is no real elegant solution to the problem. Maybe this is still the best way to go:
What that means in detail:
I think OC wont drop the current UI in the foreseeable future, so this would be great indeed! |
Yes, that's mostly the idea I had. Still ugly, but hopefully the changes aren't so spread. |
2c18d66
to
e4b7a0d
Compare
5015878
to
4df1ebe
Compare
@phil-davis There is already an acceptance test that addresses this topic, at least partly: https://github.com/owncloud/core/pull/38415/files#diff-2f00159b8d264fe88306f30276f42542327bb49b4324c4daa88e8045ba4d270eR32 The "correct" behavior was even described before, but commented out. Overall I guess this is ready to review. There is still an annoying behavior in such scenarios though: When having 3 folders named "folder" in the file list and clicking on the last one, it will be rendered again at the top of the 3 folders. This is because Backbone re-renders elements when they are updated (via |
d3a4bd5
to
e373edc
Compare
@JammingBen I added a commit that deletes the bug-demo scenario and enables the "gold" scenario for oC10. For oC10 bugs, we usually write a bug-demo scenario in a separate feature file, that demonstrates the "bad" behavior, and passes in the oC10 with the bug. We also write a "gold" scenario that demonstrates how the scenario should work. The "gold" scenario is skipped on oC10. When the bug is fixed, we can delete the bug-demo scenario and remove the skip from the "gold" scenario. |
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.
LGTM - needs a dev review from someone who knows the detail of the JavaScript
apps/files/js/fileactions.js
Outdated
@@ -434,6 +434,7 @@ | |||
a: null | |||
}, | |||
function(event) { | |||
context.fileList.$fileList.trigger(new jQuery.Event('setCurrentRow', {currentRow: context.$file})); |
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.
You can use context.fileList.$fileList._setCurrentRow(...)
here without triggering an event.
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.
You're right. Well, then we could remove all that event stuff and just work with direct method calls, right?!
apps/files/js/filelist.js
Outdated
* Sets the currently clicked row | ||
* We use this event to give the findFileEl a unique identifier. | ||
*/ | ||
_setCurrentRow: function(data) { |
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.
While I'd expect something more straightforward such as _setCurrentRow($rowEl)
, if you want to use an object as parameter, that object should be documented. I mean, the docs doesn't say anything about how the data is expected to be, so we have to rely on reading the function or checking how the function is being used.
You can add something like:
Following attributes must be present in the "data" parameter:
* currentRow: the jQuery element associated to the "selected" row of the filelist.
Optional attributes could also be added later if needed.
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 just used data
because this method was planned to be called via event emitter only. Now if we call that method directly (and it has no other purpose than setting the clicked row-element), I also prefer something like $rowEl
👍
Kudos, SonarCloud Quality Gate passed! |
Description
Lots of frontend actions use the filename as identifier. This works fine for the normal filelist, as the filename is unique per directory. However, in other views like "Shared by link" for instance, it's totally possible that we have multiple files with the same name in one directory. Is this the case, many of these actions will fail or result in strange behavior (show detail view, rename, delete, show sharing dialogue, ...)
This PR fixes those issues by taking the currently clicked row into account.
Related Issue
Types of changes
Checklist: