-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8021 from owncloud/sidebar-panels-via-url
[full-ci] Access right sidebar panels via URL
- Loading branch information
Showing
36 changed files
with
334 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Enhancement: Access right sidebar panels via URL | ||
|
||
Opening the right sidebar (including its panels) is now possible via URL param. | ||
|
||
For private or internal links it only requires the new `details` param in the URL. For other URLs (e.g. personal space, project space) the `scrollTo` param including the resource id is needed as well. | ||
|
||
The following values can be used for the `details` param: | ||
|
||
* `details` - sidebar open, no specific panel | ||
* `actions` - actions panel | ||
* `sharing` - share panel | ||
* `versions` - versions panel | ||
* `space-share` - members panel (project space only) | ||
|
||
https://github.com/owncloud/web/pull/8021 | ||
https://github.com/owncloud/web/issues/7927 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useScrollTo' |
70 changes: 70 additions & 0 deletions
70
packages/web-app-files/src/composables/scrollTo/useScrollTo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { computed, unref } from 'vue' | ||
import { Resource } from 'web-client/src' | ||
import { eventBus, useStore } from 'web-pkg/src' | ||
import { queryItemAsString } from 'web-pkg/src/composables/appDefaults' | ||
import { useRouteQuery } from 'web-pkg/src/composables' | ||
import { SideBarEventTopics } from '../sideBar' | ||
|
||
export interface ScrollToResult { | ||
scrollToResource(resource: Resource): void | ||
scrollToResourceFromRoute(resources: Resource[]): void | ||
} | ||
|
||
export const useScrollTo = (): ScrollToResult => { | ||
const store = useStore() | ||
const scrollToQuery = useRouteQuery('scrollTo') | ||
const detailsQuery = useRouteQuery('details') | ||
const scrollTo = computed(() => { | ||
return queryItemAsString(unref(scrollToQuery)) | ||
}) | ||
const details = computed(() => { | ||
return queryItemAsString(unref(detailsQuery)) | ||
}) | ||
|
||
const scrollToResource = (resource) => { | ||
const resourceElement = document.querySelectorAll( | ||
`[data-item-id='${resource.id}']` | ||
)[0] as HTMLElement | ||
|
||
if (!resourceElement) { | ||
return | ||
} | ||
|
||
// bottom reached | ||
if (resourceElement.getBoundingClientRect().bottom > window.innerHeight) { | ||
resourceElement.scrollIntoView(false) | ||
return | ||
} | ||
|
||
const topbarElement = document.getElementsByClassName('files-topbar')[0] as HTMLElement | ||
// topbar height + th height + height of one row = offset needed when scrolling top | ||
const topOffset = topbarElement.offsetHeight + resourceElement.offsetHeight * 2 | ||
|
||
// top reached | ||
if (resourceElement.getBoundingClientRect().top < topOffset) { | ||
const fileListWrapperElement = document.getElementsByClassName('files-view-wrapper')[0] | ||
fileListWrapperElement.scrollBy(0, -resourceElement.offsetHeight) | ||
} | ||
} | ||
|
||
const scrollToResourceFromRoute = (resources: Resource[]) => { | ||
if (!unref(scrollTo) || !resources.length) { | ||
return | ||
} | ||
|
||
const resource = unref(resources).find((r) => r.id === unref(scrollTo)) | ||
if (resource) { | ||
store.commit('Files/SET_FILE_SELECTION', [resource]) | ||
scrollToResource(resource) | ||
|
||
if (unref(details)) { | ||
eventBus.publish(SideBarEventTopics.openWithPanel, unref(details)) | ||
} | ||
} | ||
} | ||
|
||
return { | ||
scrollToResource, | ||
scrollToResourceFromRoute | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.