Skip to content
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(files): correct params on Go back link #43116

Closed
wants to merge 2 commits into from
Closed

Conversation

ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Jan 25, 2024

Summary

Before, going back results an invalid URL. Updating the page results in infinity loop.

(Video with sound)

Before.mp4

This issue fixes the link. But probably we should also fix such an invalid link handling.

After-1.mp4

Also works on root.

After-2.mp4

TODO

  • Remove aria-label - it is not correct to have aria-label different from a button text and not needed when there is a text
  • Set fileid on "Go back"

Checklist

@ShGKme ShGKme added this to the Nextcloud 29 milestone Jan 25, 2024
@ShGKme ShGKme self-assigned this Jan 25, 2024
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Copy link
Contributor

@JuliaKirschenheuter JuliaKirschenheuter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works, great!

@@ -96,7 +96,6 @@
data-cy-files-content-empty>
<template #action>
<NcButton v-if="dir !== '/'"
:aria-label="t('files', 'Go to the previous folder')"
type="primary"
:to="toPreviousDir">
{{ t('files', 'Go back') }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{ t('files', 'Go back') }}
{{ t('files', 'Go to the parent folder') }}

Comment on lines +343 to +345
const fileid = this.pathsStore.getPath(this.currentView?.id, dir)?.toString()
// @ts-expect-error Route expect params to be string, but we need to explicitly set undefined when there is no fileid
return { ...this.$route, params: { fileid }, query: { dir } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to provide the fileid.
Maybe making sure we just keep the view?

Suggested change
const fileid = this.pathsStore.getPath(this.currentView?.id, dir)?.toString()
// @ts-expect-error Route expect params to be string, but we need to explicitly set undefined when there is no fileid
return { ...this.$route, params: { fileid }, query: { dir } }
return { name: this.$route.name, params: { view: this.$route.params?.view || 'files' }, query: { dir } }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand our files routing correctly, we always have fileid in the path, except root.

For example, if I open /Foo/Bar and Bar directory has fileid=700, then the current route is:

  • In Files: /apps/files/files/700?dir=/Foo/Bar
  • In favorites: /apps/files/favorites/700?dir=/Foo/Bar

Let's say, I'm in the root, then I'm going to Baz and back to Bar.

  1. /apps/files/files?dir=/
  2. /apps/files/files/699?dir=/Foo
  3. /apps/files/files/700?dir=/Foo/Bar
  4. /apps/files/files/701?dir=/Foo/Bar/Baz

From 4 shouldn't I return to 3 /apps/files/files/700?dir=/Foo/Bar?
Why /apps/files/files/?dir=/Foo/Bar?

If going back should be without fileid, does it mean that while going through directories forward and though breadcrumb there should also be no fileid?

  1. /apps/files/files?dir=/
  2. /apps/files/files?dir=/Foo
  3. /apps/files/files?dir=/Foo/Bar
  4. /apps/files/files?dir=/Foo/Bar/Baz

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we always have fileid in the path

no, having fileid in the path is optional, we don't rely on it to open folders or browse.
We only rely on it to scroll to a specific file in the current opened folder or trigger a file action on load

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that links to folders in the files list should not contain fileid at all?
Because there is no such a file in the folder, nothing to scroll to.

For example, if /Foo folder has fileid=700, then path /apps/files/files/700?dir=/Foo doesn't make sense — there is no "700" in the /Foo, only in parent /.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have it or you can't.
It will have no effect on the loading of the folder.

the fileid, like in older versions, is only used within the Files app to work with a file within a folder (like open the sidebar, etc etc)

Copy link
Member

@skjnldsv skjnldsv Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Just in the file list when we go to the next folder
  2. In the breadcrumbs
  3. In the "Go back" link
  1. Yes
  2. Yes
  3. aaaaand yes/no, it's good to have it but it's optional

We try to keep the current fileid for this specific reason: #40515

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yes
  2. Yes

will trigger the sidebar action for the file id

Does it mean that opening any folder is supposed to also open a sidebar after it?

If it is not, we have a inconsistent here:

  • Being on a page /:fileid doesn't open a sidebar
  • Opening a link with /:fileid opens a sidebar
  • => A fact of reloading a page opens a sidebar o_O

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, there should be a query param for sidebar, like ?details, similar to openfile?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No please 🙈
Let's not complicate URLs.

Being on a page /:fileid doesn't open a sidebar
Opening a link with /:fileid opens a sidebar
=> A fact of reloading a page opens a sidebar o_O

That's not a inconsistency, this is the feature. It's been long discussed and implemented by the design team.
On load, if you provide a fileid for a FILE, we open the sidebar (if screen size allows)

Copy link
Member

@skjnldsv skjnldsv Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please, let's not dive into this and reconsider 6 years of feature requests, this is not what this issue is about at all.
You have no idea the amount of use cases the Files app supports and I had to match up.

@ShGKme ShGKme closed this Jan 27, 2024
@ShGKme
Copy link
Contributor Author

ShGKme commented Jan 27, 2024

Closed in flavor of #43174

@skjnldsv skjnldsv deleted the fix/files--go-back branch January 30, 2024 10:16
@skjnldsv skjnldsv removed this from the Nextcloud 29 milestone Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants