summaryrefslogtreecommitdiffstats
path: root/apps/files/js
Commit message (Collapse)AuthorAgeFilesLines
* Fix dropping a folder on a folder rowDaniel Calviño Sánchez2019-01-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the uploaded files have a relative path (that is, when a folder is uploaded) it is first ensured that all the parent folders exist, which is done by trying to create them. When a folder is created in the currently opened folder the file list is updated and a row for the new folder is added. However, this was done too when the folder already existed, which caused the previous row to be removed and a new one added to replace it. For security reasons, some special headers need to be set in requests; this is done automatically for jQuery by handling the "ajaxSend" event in the document. In the case of DAV requests, if the headers are not set the server rejects the request with "CSRF check not passed". When a file or folder is dropped on a folder row the jQuery upload events are chained from the initial drop event, which has the row as its target. In order to upload the file jQuery performs a request, which triggers the "ajaxSend" event in the row; this event then bubbles up to the document, which is then handled by adding the special headers to the request. However, when a folder was dropped on a folder row that folder row was removed when ensuring that the folder exists. The jQuery upload events were still triggered on the row, but as it had been removed it had no parent nodes, and thus the events did not bubble up. Due to this the "ajaxSend" event never reached the document when triggered on the removed row, the headers were not set, and the upload failed. All this is simply fixed by not removing the folder row when trying to create it if it existed already. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Remove event handler no longer neededDaniel Calviño Sánchez2018-10-231-6/+0
| | | | | | | | | | | | | | The custom handler for "URL changed" events were added to reload the file list whenever the sections for favorites and shares were opened; this was used to fix the problem of not reloading the file lists when opening them for a second time. However, besides that the handlers were not really necessary, and as the root of the bug was fixed in the previous commit those handlers are now removed. The file list for tags uses the handler for a different purpose, though, so that one was kept. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Fix opening a section again in the Files appDaniel Calviño Sánchez2018-10-233-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When a section is open in the Files app a "show" event is triggered. File list objects handle that event by reloading themselves, but only if the file list was shown at least once. However, the file list objects of plugins are created when the "show" event is triggered for the first time for their section; as the file list objects register their handler for the "show" event when they are created they never handle the first triggered "show" event, as the handler is set while that event is being already handled. Therefore, from the point of view of the handler, the second time that a "show" event was triggered it was seen as if the file list was shown for the first time, and thus it was not reloaded. Now the "shown" property is explicitly set for those file lists that are created while handling a "show" event, which causes them to be reloaded as expected when opening their section again. Note that it is not possible to just reload the file list whenever it is shown; the file list is reloaded also when the directory changes, and this can happen when the web page is initially loaded and the URL is parsed. In that case, if file lists were reloaded when shown for the first time then it could be reloaded twice, one with the default parameters due to the "show" event and another one with the proper parameters once the URL was parsed, and the files that appeard in the list would depend on which response from the server was received the last. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Do not hide the progress bar while the chunked upload is being assembledDaniel Calviño Sánchez2018-09-261-1/+48
| | | | | | | | | | | | | | | Large files are not uploaded in a single operation, but uploaded in several chunks; once all the chunks are uploaded then the server needs to assemble them to get the final file. Before, once the chunks were uploaded the progress bar was hidden. However, this was confusing for the users, as the file could still need some time to appear in the file list due to the assembling. Now once all the chunks are uploaded the text in the progress bar changes to inform the user that there are still some pending operations, and only when the file is finally assembled the progress bar is hidden. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Do not show an error message when draging and dropping textDaniel Calviño Sánchez2018-06-121-0/+10
| | | | | | | | | | | When the browser reports a drag of items other than files (for example, text) and then triggers a drop event with no files no error message should be shown to the user, as in that case there would be no highlight of the drop zone and no indication that the drop would be valid (except for the mouse cursor); the error message should be shown only when the drop event with no files follows a file drag. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Remove no longer needed special handling for FirefoxDaniel Calviño Sánchez2018-06-121-15/+8
| | | | | | | | | | The highlighting was removed in Firefox when the cursor was no longer moving to handle the behaviour of reporting a file drag and then providing no files in the drop event. That behaviour (which was only present in Firefox 48 and 49) is already handled with the "dropnofiles" callback, so that special handling is no longer needed. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Use "dropnofiles" callback to disable the drop state in the UIDaniel Calviño Sánchez2018-06-121-0/+10
| | | | | | | | | | | | | | | | | | When a file is dragged from the desktop to the file list the file list is highlighted, and when the file is finally dropped or the drag operation is cancelled the highlighting is removed. In some cases, due to a wrong implementation, a browser may end a file drag with a drop with no files (for example, when a folder or text is dragged), which would cause the highlight to not be removed. Now those cases are handled with the "dropnofiles" callback, which restores the UI and also shows a message to the user. The error message is just a generic one, as in some cases it is not even possible to know whether the problem came from a text drag or a folder drag, and whether the problem appears or not depends on the browser, version and even operating system. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Add callback to clean up after misbehaved drag and drop eventsDaniel Calviño Sánchez2018-06-121-0/+12
| | | | | | | | | | | | | | | | | | | The jQuery Plugin triggers the "dragover" callback when the browser triggers the "dragover" event and the types in their DataTransfer include a "Files" item. It also triggers the "drop" callback when the browser triggers the "drop" event and the list of files in its DataTransfer is not empty. Unfortunately some browsers may trigger "dragover" events with a DataTransfer that includes a "Files" item and then trigger a "drop" event with an empty list of files. When that happens the actions performed in the "dragXXX" callbacks could be left hanging if they were expected to be finished in the "drop" callback (for example, if the drop zone was highlighted during the drag to be then restored when the file was finally dropped). This commit adds the "dropnofiles" callback to be able to handle those situations. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Remove duplicated codeDaniel Calviño Sánchez2018-06-121-6/+1
| | | | | | | "disableDropState" was set as the event handler in 8d4e5747f386a0, but the duplicated code was accidentally added back in 786e858d23c4a4. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Fix race condition when preparing upload folderDaniel Calviño Sánchez2018-05-101-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | Before any upload is submitted the upload is registered in a list of known uploads; this is needed to retrieve the upload object at several points of the upload process. When a chunked upload is submitted first a directory to upload all the chunks is created and, once that is done, the chunks are sent; in order to send a chunk the upload object needs to be retrieved from the list of known uploads. When all the active uploads were finished the list of known uploads was cleared. However, an upload is not active until it actually starts sending the data, so while waiting for the upload directory to be created the upload is already in the list of known uploads yet not active. Due to all this, if the active uploads finished while another pending upload was waiting for the upload directory to be created that pending upload would be removed from the list of known uploads too, and once the directory was created and thus the chunks were sent a field of a null upload object would be accessed thus causing a failure. Instead of removing all the known uploads at once when the active uploads finish now each upload is explicitly removed when it finishes. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Ensure proper color contrast according to WCAG AAJan-Christoph Borchardt2018-05-091-3/+7
| | | | Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
* Fixed files copy/move when in favorites or recent sectionJohn Molakvoæ (skjnldsv)2018-04-182-6/+9
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Fix progress bar hidden before the upload endsDaniel Calviño Sánchez2018-04-091-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The jQuery File Upload plugin triggers the "stop" event once there are no more files being uploaded (even if some of them were added when another upload was already in progress). Therefore, the progress bar should be hidden in the "fileuploadstop" callback. In some cases the "stop" event is not triggered and thus the progress bar is not hidden once no more files are being uploaded. This is caused by a race condition and it will be fixed in another commit; except in buggy cases like that one (that need to be fixed anyway) it is safe to hide the progress bar in the "fileuploadstop" callback. In any case, note that the callbacks in "fileuploaddone" may be called after the "stop" event was triggered and handled when using chunked uploads. In that case once all the chunks are uploaded the assembled file is moved to its final destination, so its promise could be resolved after the "stop" event was triggered. Therefore a different approach would be needed to keep the progress bar visible until the chunked upload is truly finished, but for the time being the current one is good enough. Before this commit the progress bar was being hidden when the first upload finished, either successfully or with an error, no matter if there were other files being uploaded too. The progress bar was being explicitly hidden also when the upload was cancelled. When an upload is cancelled all the single uploads are aborted, which triggers a "fail" event for each of them. However, the "stop" event is always triggered when no more files are being uploaded, so it is triggered too once all the single uploads were aborted. As all the single uploads are immediately aborted in a loop when the general upload is cancelled it makes no difference to hide the progress bar when the first single upload is aborted or when all the single uploads were aborted, so the progress bar is no longer explicitly hidden in the former case. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Improve documentation of "getTotalWidth"Daniel Calviño Sánchez2018-03-011-1/+4
| | | | | | | | | | "getTotalWidth" is not more accurate; it is simply not clamped. Moreover, "width/outerWidth" could be used in tests too, and also even if "getTotalWidth" could be used in tests while others not that would not be something to be stated in the API documentation, but in a comment. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Do not show the crumbs again after hiding themDaniel Calviño Sánchez2018-03-011-6/+0
| | | | | | | | | | | | | | | | | | | After the changes in the previous commit "_showCrumb" no longer shows the menu, only the same crumb that was hidden by the last call to "_hideCrumb". Therefore, if the crumb was hidden because it did not fit there is no need to try to show it again, as it will still not fit. Moreover, the calculated width for a hidden element is not always accurate; in some cases the calculated width is lower than the actual width (it happens, for example, when using a background image like the "Share" icon), which causea the crumb to be shown even if there is not enough room, which in the end causes the siblings to overflow the contents. No unit tests for this one, though; you will have to trust me on this, sorry ;-) Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Fix menu visibilityDaniel Calviño Sánchez2018-03-011-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | The crumb for the menu was shown like any other crumb when calling "_showCrumb", but it was also shown when other crumbs were hidden without taking into account the available width. This caused several related problems, like the breadcrumbs taking too much space when the menu was sometimes shown after the rest of the crumbs were adjusted to the available width, or the menu being shown instead of the last crumb even if there was room for it when the available width was increased. Now the menu is always hidden before starting the resizing of the crumbs to ensure that whether it was previously shown or not does not affect the result. In a similar way, the menu will no longer be shown by "_showCrumb", as it is not a regular crumb that has to be shown simply if there is enough room. The menu is now shown as soon as any other crumb is hidden; this ensures that the menu width will be taken into account in further width checks. As when _updateMenu" is called it no longer needs to take care of showing the menu this fixes the issue revealed when fixing the test setup in the previous commit. Finally, this implicitly fixes the failure in the breadcrumbs tests when run on Firefox, as it was caused by the menu interfering in the calculations of the other crumbs when increasing the width. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Take padding and margins of crumbs into accountDaniel Calviño Sánchez2018-03-011-2/+2
| | | | | | | | | When calculating the total width of the crumbs only its padding was taken into account; now the margin is too. In a similar way, before showing a crumb only its width was taken into account; now its padding and margin are taken into account too. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Compress siblings before calculating the available width for crumbsDaniel Calviño Sánchez2018-03-011-0/+9
| | | | | | | | | | | | | | | | When the parent element of the breadcrumbs was resized to a larger width and the siblings of the breadcrumbs expanded to fill all the available width some crumbs could be hidden even if there was enough room for them. The reason was that the width of the siblings being used to calculate the available width for the breadcrumbs was the expanded width of the siblings. Now as many crumbs as possible (that is, fitting in the parent, no matter the siblings) are first shown so the expanding siblings are compressed before calculating the available width. Due to the lack of support for flexboxes in PhantomJS the related unit test is skipped; it has to be run in other browser, like Firefox. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Take all visible siblings into accountDaniel Calviño Sánchez2018-03-011-1/+9
| | | | | | | | | Other apps could add elements to the controls outside the creatable actions div (for example, the button to switch to the gallery), so the widths of all the visible siblings of the breadcrumbs have to be taken into account in the size calculations. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Take padding and margin of the creatable actions div into accountDaniel Calviño Sánchez2018-03-011-1/+1
| | | | | | | | | | | | | | | There are some differences in width handling between the browsers used to run the tests, most likely due to their support (or lack of) of certain CSS features: PhantomJS requires "width" to be set (probably because it does not handle flex displays and treats it like a block, so "min-width" does not matter in this case), while Firefox requires "min-width" to be set (otherwise the children of "#controls" could be compressed due to its use of flex display and the elements would end with a different width than the one needed for the tests). Due to all that the width of the breadcrumb siblings must be specified in the tests using both "width" and "min-width". Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Replace attribute with local variableDaniel Calviño Sánchez2018-03-011-3/+3
| | | | | | | | The "usedWidth" attribute was not used elsewhere outside the "_resize" method, so it was replaced with a local variable. Moreover, it was also renamed to a more suitable name ("availableWidth"). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Set the width of the parent element in breadcrumb testsDaniel Calviño Sánchez2018-03-011-19/+1
| | | | | | | | | Setting the width of the parent element of the breadcrumbs and then explicitly calling "_resize" is enough to test the resizing behaviour. This makes possible to remove the "setMaxWidth" method and its related code, which was used only for testing purposes. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Fix empty details view after renaming a fileDaniel Calviño Sánchez2018-01-111-1/+1
| | | | | | | | | | | "FileList._updateDetailsView" expects either a file name (as a string) or a file model (as an "OCA.File.FileInfoModel"), but when called through "updateInList" an "OC.Files.FileInfo" object was given instead. As the given attribute was not a model "_updateDetailsView" treated it as a file name and tried to get the model for that file, which failed and caused the details view to be emptied. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Don't encode paths passed to the OC.Files.ClientRoeland Jago Douma2018-01-101-7/+7
| | | | | | | This is handled already in the client. So double encoding breaks things in some situations. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Hide favourite icon in details view if favourite action is not availableDaniel Calviño Sánchez2018-01-051-0/+9
| | | | | | | | | | | | When the favourite icon in the details view is clicked the "Favorite" action is triggered. However, if the action name given to "triggerAction" is not found then the "Download" action is triggered instead. As the "Favorite" action is not available in some file lists (like "Recents") the "Download" action was executed instead in those cases, which was a strange behaviour. Now the favourite icon is hidden if its action is not available. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Fixup! removed unwanted lineJohn Molakvoæ (skjnldsv)2018-01-031-1/+0
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Fixed quota update on upload and on deleteJohn Molakvoæ (skjnldsv)2018-01-032-15/+6
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Merge pull request #7681 from nextcloud/fix-quota-update-2Morris Jobke2018-01-032-0/+23
|\ | | | | Update quotas on each upload
| * Fix unwanted varJohn Molakvoæ (skjnldsv)2018-01-031-1/+1
| | | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
| * Update quotas on each uploadJohn Molakvoæ (skjnldsv)2018-01-032-0/+23
| | | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* | Merge pull request #7533 from ↵Morris Jobke2018-01-031-1/+12
|\ \ | |/ |/| | | | | nextcloud/oc-28545-handle-oc-total-length-in-new-chunking [oc] Handle OC-Total-Length in new chunking
| * Only set X-OC-Mtime when browser provided lastModified on uploadVincent Petry2017-12-151-4/+12
| | | | | | | | Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
| * Transmit OC-Total-Length in browser as wellThomas Müller2017-12-151-1/+4
| | | | | | | | Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* | Show warning if slash is entered as filenameMorris Jobke2018-01-031-0/+2
| | | | | | | | Signed-off-by: Morris Jobke <hey@morrisjobke.de>
* | Merge pull request #7624 from ↵Morris Jobke2018-01-021-0/+3
|\ \ | | | | | | | | | | | | nextcloud/fix-fileActions-currentFile-not-set-before-using-it Fix "fileActions.currentFile" not set before using it
| * | Fix "fileActions.currentFile" not set before using itDaniel Calviño Sánchez2017-12-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an empty area of a file row was clicked and the "Details" action was executed "fileActions.currentFile" was not guaranteed to be set to the appropriate object (it depended on the previous actions of the user), so when it was used by "getCurrentMimeType()" and other FileActions functions they may not work as expected. Now it is explicitly set to the appropriate value before its use. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* | | Merge pull request #7592 from nextcloud/update-quota-on-files-uploadRoeland Jago Douma2017-12-283-2/+28
|\ \ \ | |/ / |/| | Update quota on files upload
| * | Fixed testsJohn Molakvoæ (skjnldsv)2017-12-262-3/+0
| | | | | | | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
| * | Update quota on file upload and deletionJohn Molakvoæ (skjnldsv)2017-12-213-1/+30
| |/ | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* | Merge pull request #7591 from ↵Morris Jobke2017-12-222-11/+34
|\ \ | | | | | | | | | | | | nextcloud/trigger-events-before-and-after-a-file-action-is-executed Trigger events before and after a file action is executed
| * | Remove internal unused propertyDaniel Calviño Sánchez2017-12-211-9/+0
| | | | | | | | | | | | Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
| * | Trigger the "Details" action when clicking on an empty file row spaceDaniel Calviño Sánchez2017-12-211-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clicking on an empty space in a file row causes the details view to be shown. As it is a user initiated action on the file list now it is done by triggering the Details action instead of directly calling "_updateDetailsView"; the result is the same in both cases, but using the action is more consistent (clicking on the file name triggers the default action, and clicking on the inline actions triggers those actions) and also makes possible to use the "beforeTriggerAction" and "afterTriggerAction" listeners. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
| * | Trigger events before and after a file action is executedDaniel Calviño Sánchez2017-12-191-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the same way that other elements can know when a FileAction is registered or a default action is set this commit makes possible to be notified before and after a FileAction is executed. This is achieved by wrapping the registered action handler in a custom function that notifies the listeners before and after executing the handler itself. Due to this approach only FileActions registered through "registerAction" trigger the events, although that is not a problem as this is how the actions should be added to the FileActions anyway. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* | | Fixed breadcrumbs calculation and actions flowJohn Molakvoæ (skjnldsv)2017-12-201-1/+1
|/ / | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* / Fix drag shadow not visible when dragging a file on a narrow screenDaniel Calviño Sánchez2017-12-141-1/+0
|/ | | | | | | | | | | | | | | | | When a file from the file list is dragged a drag shadow (a copy of the file row that follows the cursor position) is created. The drag shadow element is created as a direct child of the body element, so it needs a higher "z-index" than the one used for the file list to be visible. In narrow screens the "#app-content" uses a "z-index" of 1000 in order to be visible over the "#navigation-bar" when they overlap, so the "z-index" of the drag shadow must be at least 1000 to be visible over the file list. Instead of updating the hardcoded "z-index" it was removed and replaced by CSS rules for ".dragshadow" elements to ease theming. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* Merge pull request #6079 from nextcloud/fix-antivirusblizzz2017-12-111-6/+29
|\ | | | | Parse Sabre Exception in OC.Files.Client and file-upload
| * Parse Sabre Exception in OC.Files.Client and file-uploadVincent Petry2017-11-131-6/+29
| | | | | | | | | | | | | | | | In case of error, instead of a generic error message, an upload will display whichever message is returned in the Sabre Exception, if applicable. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
* | Merge pull request #6670 from nextcloud/handle-encryption-state-in-web-interfaceTobias Kaminsky2017-12-061-4/+11
|\ \ | | | | | | Handle encryption state in web interface
| * | show e2e folder icon on encrypted foldersBjoern Schiessle2017-11-201-1/+4
| | | | | | | | | | | | Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
| * | Add data attribute to file list rows telling if the file is encryptedDaniel Calviño Sánchez2017-11-201-2/+4
| | | | | | | | | | | | Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>