Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Create new folder, navigate to page - #9548

Merged
JammingBen merged 9 commits into
owncloud:masterfrom
jacob-nv:pagination-folder-scroll
Aug 18, 2023
Merged

JammingBen merged 9 commits into
owncloud:masterfrom
jacob-nv:pagination-folder-scroll

Conversation

@jacob-nv

@jacob-nv jacob-nv commented Aug 7, 2023

Copy link
Copy Markdown
Contributor

Description

Once folder is created it's id is matched with sorted items to get page on which is located

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@jacob-nv
jacob-nv marked this pull request as ready for review August 7, 2023 14:06
@update-docs

update-docs Bot commented Aug 7, 2023

Copy link
Copy Markdown

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.

@dschmidt dschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you move the logic tojthe scrollToResource composable, so it can be reused?

@pascalwengerter

Copy link
Copy Markdown
Contributor

Can you move the logic tojthe scrollToResource composable, so it can be reused?

Also my first thought :) within the scrollToResource there's a check if the resourceId is on the current page, if not it currently returns but you could check if it exists within the paginated resources and then trigger the page transition

@jacob-nv
jacob-nv requested a review from dschmidt August 8, 2023 09:45
@pascalwengerter

Copy link
Copy Markdown
Contributor

@jacob-nv I think this PR lacks a changelog item linking this PR and the issue it closes :)


const scrollToResource = async (resourceId: Resource['id'], options = { forceScroll: false }) => {
if (unref(sortedItems)) {
const index = findIndex(unref(sortedItems), (item: Resource) => item.id === resourceId)

@pascalwengerter pascalwengerter Aug 8, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd prefer doing this lookup only in the if (!resourceElement) {...} block below and check the "current page DOM" for the fileId first?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wouldn't prefer that tbh 😬

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess I have an idea why, but would you mind elaborating?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pascalwengerter okay, I see what you mean, but if I need to scroll to element on different page, I would have to query the row again no?

Right now it's:

  1. Check if I'm on correct page
  2. If not change page
  3. Query DOM row
  4. Scroll to it

If I'm not mistaken, changing the order would then be:

  1. Query DOM row
  2. If doesn't exists, check what's the correct page and change page
  3. Query DOM row
  4. Scroll to it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yep, that's what I meant

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

... but I would solve the whole issue a little differently, wrote it down in detail in my review

@dschmidt dschmidt left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't really like, that we're now sorting and paginating all files again, when it also happened in the view already.

What I thought about: make useScrollTo publish an event over the eventBus, that usePagination can consume to switch to the right page. Afterwards the actual scrolling can happen

edit:
My initial feeling was that we should just pass in the sorted/paginated resources from the useResourceViewDefaults composable - but that doesn't work when we want to switch to a newly created file/folder, where the action was triggered from CreateAndUpload - that's why I think using the eventBus might be the best option

@jacob-nv

jacob-nv commented Aug 9, 2023

Copy link
Copy Markdown
Contributor Author

I don't really like, that we're now sorting and paginating all files again, when it also happened in the view already.

What I thought about: make useScrollTo publish an event over the eventBus, that usePagination can consume to switch to the right page. Afterwards the actual scrolling can happen

edit: My initial feeling was that we should just pass in the sorted/paginated resources from the useResourceViewDefaults composable - but that doesn't work when we want to switch to a newly created file/folder, where the action was triggered from CreateAndUpload - that's why I think using the eventBus might be the best option

Rewrote, but still had to move part of the useScroll login to usePagination. After publishing event and routing, useScroll is not able to query the DOM element. Or do you have better idea how to deal with? Wasn't able to sync it in a way it would execute without moving that part of logic

@jacob-nv
jacob-nv requested a review from dschmidt August 9, 2023 17:32
@dschmidt

dschmidt commented Aug 9, 2023

Copy link
Copy Markdown
Member

Thanks for taking care!

Yeah, we don't have a proper way to "ack" an event - maybe you could send a "navigated to page" event ... but it's probably not bad like this either and you could leave it like this. I'm about to head out, can look later or tomorrow again

const page = Math.ceil((index + 1) / Number(unref(perPage)))
router.push({ ...unref(route), query: { ...unref(route).query, page } }).then(() => {
eventBus.publish('app.files.navigate.scrollTo', { resourceId, forceScroll })
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're getting somewhere!

I'm not completely happy with this, but I played around with it and it's tricky to solve it directly through the page ref. I would like to try a few more things, but have to focus on other things for now.
If that's okay for you, I will try again tonight and if I don't find anything useful, I'm fine to have this merged tomorrow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I obviously didn't get to it, feel free to merge

@jacob-nv
jacob-nv requested a review from dschmidt August 15, 2023 13:40

@JammingBen JammingBen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jacob-nv

Copy link
Copy Markdown
Contributor Author

Code LGTM, unit tests are failing though: https://drone.owncloud.com/owncloud/web/38188/9/5

useKeyboardTableNavigation (same as other keyboard actions related composables) uses useStore.
Calling that throws the error. I don't really have any ideas about fixing that.

@sonarqubecloud

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

53.3% 53.3% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@JammingBen
JammingBen enabled auto-merge (squash) August 18, 2023 05:26
@JammingBen
JammingBen dismissed dschmidt’s stale review August 18, 2023 05:29

Issues have been addressed

@JammingBen
JammingBen merged commit 01c4f0d into owncloud:master Aug 18, 2023
ownclouders pushed a commit that referenced this pull request Aug 19, 2023
* Create new folder, navigate to page

* Revert "Create new folder, navigate to page"

This reverts commit d6f6d96.

* Create new folder, navigate to page - useScrollTo

* Revert "Create new folder, navigate to page - useScrollTo"

This reverts commit cc3fb0a.

* Scroll to navigates to proper page through busEvent

* Scroll to navigates - callback with busEvents

* useScrollTo type fix

* Pagination folder scroll, fixing eventBus path
ownclouders pushed a commit that referenced this pull request Aug 20, 2023
* Create new folder, navigate to page

* Revert "Create new folder, navigate to page"

This reverts commit d6f6d96.

* Create new folder, navigate to page - useScrollTo

* Revert "Create new folder, navigate to page - useScrollTo"

This reverts commit cc3fb0a.

* Scroll to navigates to proper page through busEvent

* Scroll to navigates - callback with busEvents

* useScrollTo type fix

* Pagination folder scroll, fixing eventBus path
ownclouders pushed a commit that referenced this pull request Aug 21, 2023
* Create new folder, navigate to page

* Revert "Create new folder, navigate to page"

This reverts commit d6f6d96.

* Create new folder, navigate to page - useScrollTo

* Revert "Create new folder, navigate to page - useScrollTo"

This reverts commit cc3fb0a.

* Scroll to navigates to proper page through busEvent

* Scroll to navigates - callback with busEvents

* useScrollTo type fix

* Pagination folder scroll, fixing eventBus path
AlexAndBear pushed a commit that referenced this pull request Dec 13, 2023
* Create new folder, navigate to page

* Revert "Create new folder, navigate to page"

This reverts commit d6f6d96.

* Create new folder, navigate to page - useScrollTo

* Revert "Create new folder, navigate to page - useScrollTo"

This reverts commit cc3fb0a.

* Scroll to navigates to proper page through busEvent

* Scroll to navigates - callback with busEvents

* useScrollTo type fix

* Pagination folder scroll, fixing eventBus path
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scroll to new folder when being created on another page

4 participants