The "droppedOnTrash" event was being triggered when the file list was
initialized, but it should be triggered only when the user actually
drops a file on the trash bin.
Besides that, the event had no effect; only the file list handles it,
but as it was not triggered on any element it ended being triggered on
the document, and thus not handled. Moreover, even if it had been
triggered on the file list it would have been done before the handler
was set, so it would not have been handled anyway. And even if it had
been handled no data was provided, so the handler would have failed.
In conclusion, triggering the event there was not needed, and thus it
was removed.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Since 6ad7f32938 SVG icons are directly embedded in "icons-vars.css", so
the starred trash icon is now loaded along with the regular trash icon
all at once. Therefore it is not needed to explicitly prefetch it using
a hidden div.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
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>
Store the last check in the session storage. (Which gets cleared on
logout). And only check once an hour.
Saves a request to the server on most requests when browsing.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Fixes#12588
Probably needs more fixing for the other cases. But this is the quick
fix I could come up with for now.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Navigating to the root folder is already handled by
OCA.Files.Navigation.setActiveItem in case the view doesn't change.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
When a view is rendered it should not be concerned with where it is
going to be placed in the document; in general this should be a
responsibility of the object using the view.
Moreover, when the details view is rendered it should simply prepare a
skeleton that includes the root elements provided by the plugins; those
elements will be updated by the plugins as needed when a file or a tab
is selected.
Finally, the details view should not be explicitly rendered. The
rendering removes the previous elements, but that is needed only when
the details view is in a dirty state, that is, when new plugins were
added since the last time that it was rendered. However, that dirty
state is internally handled, and the view is automatically rendered
again if needed when a file info is set.
Due to all that the details view is no longer explicitly rendered when
updating it with a different file. Also, as each file list has its own
details view, and each details view has its own element, but there can
be only one details view/sidebar element in the document, when the file
list updates the details view it also replaces the current one in the
document with its own details view if needed (that is, if it is not the
current one already).
Besides that, when the element of a details view is replaced with the
element of a different details view the old one should be detached from
the document, but never removed. Otherwise the event handlers would not
work when that element is attached again later (when changing to a
different section in the Files app and then going back to the previous
one).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
fixes#10934
Else it triggers the rendering two times. Resulting is weird state in
for example the comments. Because the comments for OLD_FILEID are
retrieved but then the model is changed to NEW_FILEID. But the old
comments still get in and get parsed.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
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>
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>
This fixes errors from LGTM like the following one:
Variable i is used like a local variable,
but is missing a declaration.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This fixes some recommendations from LGTM:
Avoid automated semicolon insertion (90% of all statements
in the enclosing function have an explicit semicolon).
Signed-off-by: Stefan Weil <sw@weilnetz.de>
In general the style of the tabs container should not change depending
on which tab is the currently selected one. However, this could be
needed in some very specific cases, so now the tab views can specify the
extra CSS classes to be used in their container when they are selected.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Fixes#11030
For https://github.com/orgs/nextcloud/projects/18
This template is now compiled so this no longer has to happen in the
browser. Another step towards a stricter CSP.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
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>