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

[full-ci] Resource ids in urls #7725

Merged
merged 68 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
de1ef26
feat: add options type to configurationManager
kulmann Sep 30, 2022
554f73c
feat: whitelist fileId query param
kulmann Sep 30, 2022
dda20fe
refactor: move disabled prop from Resource to SpaceResource
kulmann Sep 30, 2022
ffdbfa7
feat: add util for route options with fileId
kulmann Sep 30, 2022
817b23b
feat: add fileId to url query in DriveRedirect
kulmann Sep 30, 2022
40363db
feat: add fileId to url query in Projects overview
kulmann Sep 30, 2022
2fd8218
feat: resolve spaces by their ids
kulmann Sep 30, 2022
6413ad5
feat: build folder links with file ids
kulmann Sep 30, 2022
d002ee0
feat: add space id to space trash navigate
kulmann Oct 4, 2022
e16805d
feat: add space id to navigate back to space (from e.g. trash)
kulmann Oct 4, 2022
86a995c
feat: add file id to Open folder action
kulmann Oct 4, 2022
48bb088
feat: add fileId to search preview component
kulmann Oct 4, 2022
2517a09
feat: add fileId to editor route queries
kulmann Oct 4, 2022
128791f
fix: wrong set of params from editor create mode
kulmann Oct 4, 2022
9be4b2c
feat: add file id to route after deleting current folder
kulmann Oct 4, 2022
fc9012d
feat: add fileId to not found message component
kulmann Oct 4, 2022
ec50e09
feat: add fileId to share root nav in details panel
kulmann Oct 4, 2022
bd81bb2
feat: add fileId to via link in sidebar sharing panel
kulmann Oct 4, 2022
bc6b56e
feat: add fileId to sidebar links panel
kulmann Oct 4, 2022
951dcf0
fix: use fileId instead of id when calling editor handler
kulmann Oct 4, 2022
e98fe19
refactor: simplify creating route to parent folder when deleting
kulmann Oct 4, 2022
1d8b0c7
feat: use fileId when renaming current folder
kulmann Oct 4, 2022
780e86e
Add itemId to useDriveResolver composable
JammingBen Oct 5, 2022
9a95bd2
Return itemId as Ref<string> from useDriveResolver composable
dschmidt Oct 5, 2022
e9995c7
Add id resolving to upload logic
JammingBen Oct 5, 2022
c1c86e4
feat: use meta request to resolve correct path by file id
kulmann Oct 5, 2022
21163bc
Add fileId to url when advancing to previous/next file in preview app
dschmidt Oct 5, 2022
37d0334
Fix parent folder fileId in upload modal
JammingBen Oct 5, 2022
a17644e
Add parentFolderId to the built resource objects
JammingBen Oct 6, 2022
e31369e
refactor: merge space related folder loaders into one
kulmann Oct 6, 2022
b69854a
refactor: rename shareIndicators option to loadShares
kulmann Oct 6, 2022
c3c710b
WIP: add reproducer for weird 'ReferenceError: Cannot access 'createL…
dschmidt Oct 6, 2022
a8d4edb
Implement validateRoute helper
dschmidt Oct 6, 2022
6b000cc
tests: fix deleted files unit test
kulmann Oct 6, 2022
1105305
tests: fix NotFoundMessage tests
kulmann Oct 6, 2022
2fd7db5
chore: fix linting
kulmann Oct 6, 2022
23ba110
Fix unit tests for CreateAndUpload.spec.js
JammingBen Oct 6, 2022
fd22a03
Fix unit tests for navigate.spec.js
JammingBen Oct 6, 2022
e7f344e
Fix unit tests for UploadInfo.spec.ts
JammingBen Oct 6, 2022
95ed3fe
feat: replace route on wrong path
kulmann Oct 6, 2022
18d3371
feat: introduce file route replacing composable
kulmann Oct 6, 2022
00e88b5
tests: adjust config.json for nightwatch tests
kulmann Oct 6, 2022
3b20558
Enable rename on shared resource
Oct 6, 2022
620b3ea
Remove shareJailId option
Oct 6, 2022
7e9e42f
feat: web-app-draw-io: fix urls based on FileId
dschmidt Oct 6, 2022
51a96b0
feat: web-app-draw-io: fix redirect to another file (e.g. from search)
dschmidt Oct 6, 2022
5662aad
feat: web-app-pdf-viewer: fix urls based on FileId
dschmidt Oct 6, 2022
f8b4461
fix: web-app-text-editor: fix urls based on FileId
dschmidt Oct 6, 2022
e8a657d
feat: web-app-preview: fix urls based on FileId
dschmidt Oct 6, 2022
e643774
Add changelog item
Oct 7, 2022
770c766
Rename useAppNavidation.validateRoute to useAppNavigation.replaceInva…
dschmidt Oct 7, 2022
9fea74c
fixup! Rename useAppNavidation.validateRoute to useAppNavigation.repl…
dschmidt Oct 7, 2022
78ea056
fix: omit fileId in route query copy on breadcrumbs
kulmann Oct 7, 2022
7277158
Fix opening single file public link share opening in apps
dschmidt Oct 7, 2022
d60ef4b
Fix lint
dschmidt Oct 7, 2022
3078c7e
fix: renaming shares via share jail
kulmann Oct 7, 2022
e6ab74c
fixup! fix: renaming shares via share jail
kulmann Oct 7, 2022
9c1a531
fix: share root breadcrumb item
kulmann Oct 7, 2022
e75a4c7
tests: fix unit tests
kulmann Oct 7, 2022
424b1ec
docs: add changelog item and documentation
kulmann Oct 7, 2022
4a2fb73
DRY: move merging of options into a route into a function
dschmidt Oct 7, 2022
43988f1
fix: use fileId for virtual personal space
kulmann Oct 10, 2022
0e5c52d
fix: use basename of shareRoot in search result list
kulmann Oct 10, 2022
bdea9e5
fix: use fileId in driveResolver composable
kulmann Oct 10, 2022
9120532
fix: various file loading oc10 issues
kulmann Oct 10, 2022
c19a25d
test: fix unit test for Preview component
kulmann Oct 10, 2022
6b227df
docs: add issue links to changelog item
kulmann Oct 10, 2022
44bb64e
refactor: simplify code structure in drawio app
kulmann Oct 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Enable renaming on received shares

As a receiver the user can rename a share which will only take effect for the respective user
but won't change the name for the sharee or other share receivers.

https://github.com/owncloud/web/pull/7725
https://github.com/owncloud/web/issues/6247
14 changes: 14 additions & 0 deletions changelog/unreleased/enhancement-id-based-routing
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Enhancement: Id based routing

We now include fileIds in the URL query to be able to
- resolve files and spaces correctly and
- resolve the correct relative path of a file if it was changed (this might be the case for bookmarks)
The fileIds in the URL can be disabled by setting `options.routing.idBased` to `false` in the `config.json`.

Note: It's recommended to keep the default of fileIds being used in routing. Otherwise it's not possible
to resolve spaces with name clashes correctly.

https://github.com/owncloud/web/issues/6247
https://github.com/owncloud/web/pull/7725
https://github.com/owncloud/web/issues/7714
https://github.com/owncloud/web/issues/7715
2 changes: 2 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ substring of a value of the authenticated user. Examples are `/Shares`, `/{{.Id}
- `options.cernFeatures` Enabling this will activate CERN-specific features. Defaults to `false`.
- `options.hoverableQuickActions` Set this option to `true` to hide the quick actions (buttons appearing on file rows), and only show them when the user
hovers the row with his mouse. Defaults to `false`.
- `option.routing` This accepts an object with the following fields to customize the routing behaviour:
- `options.routing.idBased` Enable or disable fileIds being added to the URL. Defaults to `true` because otherwise e.g. spaces with name clashes can't be resolved correctly. Only disable this if you can guarantee server side that spaces of the same namespace can't have name clashes.

### Sentry

Expand Down
48 changes: 29 additions & 19 deletions packages/web-app-draw-io/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ export default defineComponent({
return `${this.config.url}?${query}`
}
},
watch: {
currentFileContext: {
handler: function () {
this.load()
},
immediate: true
}
},
created() {
this.filePath = this.currentFileContext.path
this.fileExtension = this.filePath.split('.').pop()
this.checkPermissions()
window.addEventListener('message', (event) => {
if (event.data.length > 0) {
const payload = JSON.parse(event.data)
Expand Down Expand Up @@ -114,8 +121,9 @@ export default defineComponent({
async checkPermissions() {
try {
const resource = await this.getFileInfo(this.currentFileContext, {
davProperties: [DavProperty.Permissions]
davProperties: [DavProperty.FileId, DavProperty.Permissions]
})
this.replaceInvalidFileRoute(this.currentFileContext, resource)
this.isReadOnly = ![DavPermission.Updateable, DavPermission.FileUpdateable].some(
(p) => (resource.permissions || '').indexOf(p) > -1
)
Expand All @@ -124,24 +132,26 @@ export default defineComponent({
this.errorPopup(error)
}
},
load() {
this.getFileContents(this.currentFileContext)
.then((resp) => {
this.currentETag = resp.headers.ETag
this.$refs.drawIoEditor.contentWindow.postMessage(
JSON.stringify({
action: 'load',
xml: resp.body,
autosave: this.config.autosave
}),
'*'
)
})
.catch((error) => {
this.errorPopup(error)
})
async loadFileContent() {
try {
const response = await this.getFileContents(this.currentFileContext)
this.currentETag = response.headers.ETag
this.$refs.drawIoEditor.contentWindow.postMessage(
JSON.stringify({
action: 'load',
xml: response.body,
autosave: this.config.autosave
}),
'*'
)
} catch (error) {
this.errorPopup(error)
}
},
async load() {
await Promise.all([this.checkPermissions(), this.loadFileContent()])
},
async importVisio() {
importVisio() {
const getDescription = () =>
this.$gettextInterpolate(
this.$gettext('The diagram will open as a new .drawio file: %{file}'),
Expand Down
25 changes: 17 additions & 8 deletions packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ export default defineComponent({
type: Boolean,
default: false,
required: false
},
itemId: {
type: [String, Number],
required: false,
default: null
}
},
setup(props) {
Expand Down Expand Up @@ -212,7 +217,8 @@ export default defineComponent({
}),
...useUploadHelpers({
space: computed(() => props.space),
currentFolder: computed(() => props.item)
currentFolder: computed(() => props.item),
currentFolderId: computed(() => props.itemId)
}),
...useRequest(),
...useGraphClient(),
Expand Down Expand Up @@ -333,9 +339,10 @@ export default defineComponent({
return
}

const { spaceId, currentFolder, currentFolderId } = file.meta
if (!['public', 'share'].includes(file.meta.driveType)) {
if (this.hasSpaces) {
const driveResponse = await this.graphClient.drives.getDrive(file.meta.spaceId)
const driveResponse = await this.graphClient.drives.getDrive(spaceId)
this.UPDATE_SPACE_FIELD({
id: driveResponse.data.id,
field: 'spaceQuota',
Expand All @@ -347,8 +354,10 @@ export default defineComponent({
}
}

const fileIsInCurrentPath =
file.meta.spaceId === this.space.id && file.meta.currentFolder === this.item
const sameFolder = this.itemId
? currentFolderId === this.itemId
: currentFolder === this.item
const fileIsInCurrentPath = spaceId === this.space.id && sameFolder
if (fileIsInCurrentPath) {
bus.publish('app.files.list.load')
}
Expand Down Expand Up @@ -501,12 +510,11 @@ export default defineComponent({
this.UPSERT_RESOURCE(resource)

if (this.newFileAction) {
const fileId = resource.fileId

this.$_fileActions_openEditor(
this.newFileAction,
this.space.getDriveAliasAndItem(resource),
fileId,
resource.webDavPath,
resource.fileId,
EDITOR_MODE_CREATE
)
this.hideModal()
Expand Down Expand Up @@ -615,14 +623,15 @@ export default defineComponent({
return null
},

async onFilesSelected(filesToUpload: File[]) {
onFilesSelected(filesToUpload: File[]) {
const uploader = new ResourcesUpload(
filesToUpload,
this.files,
this.inputFilesToUppyFiles,
this.$uppyService,
this.space,
this.item,
this.itemId,
this.spaces,
this.hasSpaces,
this.createDirectoryTree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import {
isLocationPublicActive,
isLocationSpacesActive
} from '../../router'
import { useRouter, useStore } from 'web-pkg/src/composables'
import { useRouter } from 'web-pkg/src/composables'
import { defineComponent, PropType } from '@vue/composition-api'
import { Resource } from 'web-client'
import { SpaceResource } from 'web-client/src/helpers'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'

export default defineComponent({
name: 'NotFoundMessage',
Expand All @@ -67,26 +67,20 @@ export default defineComponent({
},
setup(props) {
const router = useRouter()
const store = useStore()
const isProjectSpace = props.space?.driveType === 'project'
return {
showPublicLinkButton: isLocationPublicActive(router, 'files-public-link'),
showHomeButton: isLocationSpacesActive(router, 'files-spaces-generic') && !isProjectSpace,
showSpacesButton: isLocationSpacesActive(router, 'files-spaces-generic') && isProjectSpace,
homeRoute: createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: props.space?.getDriveAliasAndItem({
path: store.getters.homeFolder
} as Resource)
}
}),
publicLinkRoute: createLocationPublic('files-public-link', {
params: {
driveAliasAndItem: props.space?.getDriveAliasAndItem({
path: ''
} as Resource)
driveAliasAndItem: 'personal'
}
}),
publicLinkRoute: createLocationPublic(
'files-public-link',
createFileRouteOptions(props.space, {})
),
spacesRoute: createLocationSpaces('files-spaces-projects')
}
}
Expand Down
65 changes: 36 additions & 29 deletions packages/web-app-files/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ import maxSize from 'popper-max-size-modifier'
import { mapGetters, mapActions, mapState } from 'vuex'
import { EVENT_TROW_MOUNTED, EVENT_FILE_DROPPED } from '../../constants'
import { SortDir } from '../../composables'
import * as path from 'path'
import { determineSortFields } from '../../helpers/ui/resourceTable'
import {
useCapabilityProjectSpacesEnabled,
Expand All @@ -192,6 +191,9 @@ import { formatDateFromJSDate, formatRelativeDateFromJSDate } from 'web-pkg/src/
import { SideBarEventTopics } from '../../composables/sideBar'
import { buildShareSpaceResource, extractDomSelector, SpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { CreateTargetRouteOptions } from '../../helpers/folderLink'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { basename, dirname } from 'path'

export default defineComponent({
mixins: [Rename],
Expand Down Expand Up @@ -559,7 +561,7 @@ export default defineComponent({
.length
},
openRenameDialog(item) {
this.$_rename_trigger({ resources: [item] }, this.getMatchingSpace(item.storageId))
this.$_rename_trigger({ resources: [item] }, this.getMatchingSpace(item))
},
openSharingSidebar(file) {
let panelToOpen
Expand All @@ -573,45 +575,42 @@ export default defineComponent({
bus.publish(SideBarEventTopics.openWithPanel, panelToOpen)
},
folderLink(file) {
return this.createFolderLink(file.path, file)
return this.createFolderLink({ path: file.path, fileId: file.fileId, resource: file })
},
parentFolderLink(file) {
if (file.shareId && file.path === '/') {
return createLocationShares('files-shares-with-me')
}

return this.createFolderLink(path.dirname(file.path), file)
return this.createFolderLink({
path: dirname(file.path),
...(file.parentFolderId && { fileId: file.parentFolderId }),
resource: file
})
},
createFolderLink(p, resource) {
createFolderLink(options: CreateTargetRouteOptions) {
if (this.targetRouteCallback) {
return this.targetRouteCallback(p, resource)
return this.targetRouteCallback(options)
}

const { path, fileId, resource } = options
let space
if (resource.shareId) {
const space = buildShareSpaceResource({
space = buildShareSpaceResource({
shareId: resource.shareId,
shareName: path.basename(resource.shareRoot),
shareName: basename(resource.shareRoot),
serverUrl: configurationManager.serverUrl
})
return createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: space.getDriveAliasAndItem({ path: p } as Resource)
},
query: {
shareId: resource.shareId
}
})
} else {
space = this.getMatchingSpace(resource)
}

const matchingSpace = this.getMatchingSpace(resource.storageId)
if (!matchingSpace) {
if (!space) {
return {}
}
return createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: matchingSpace.getDriveAliasAndItem({ path: p } as Resource)
}
})
return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(space, { path, fileId })
)
},
fileDragged(file) {
this.addSelectedResource(file)
Expand Down Expand Up @@ -718,7 +717,7 @@ export default defineComponent({
this.emitSelect(this.resources.map((resource) => resource.id))
},
emitFileClick(resource) {
let space = this.getMatchingSpace(resource.storageId)
let space = this.getMatchingSpace(resource)
if (!space) {
space = buildShareSpaceResource({
shareId: resource.shareId,
Expand Down Expand Up @@ -784,12 +783,20 @@ export default defineComponent({
ownerName: resource.owner[0].displayName
})
},
getMatchingSpace(storageId): SpaceResource {
return this.space || this.spaces.find((space) => space.id === storageId)
getMatchingSpace(resource: Resource): SpaceResource {
return (
this.space ||
this.spaces.find((space) => space.id === resource.storageId) ||
buildShareSpaceResource({
shareId: resource.shareId,
shareName: resource.name,
serverUrl: configurationManager.serverUrl
})
)
},
getDefaultParentFolderName(resource) {
if (this.hasProjectSpaces) {
const matchingSpace = this.getMatchingSpace(resource.storageId)
const matchingSpace = this.getMatchingSpace(resource)
if (matchingSpace?.driveType === 'project') {
return matchingSpace.name
}
Expand All @@ -802,7 +809,7 @@ export default defineComponent({
if (resource.shareId) {
return resource.path === '/'
? this.$gettext('Shared with me')
: path.basename(resource.shareRoot)
: basename(resource.shareRoot)
}

return this.$gettext('Personal')
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app-files/src/components/Search/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import SideBar from '../../components/SideBar/SideBar.vue'
import { buildShareSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { useStore } from 'web-pkg/src/composables'
import { configurationManager } from 'web-pkg/src/configuration'
import { basename } from 'path'

const visibilityObserver = new VisibilityObserver()

Expand Down Expand Up @@ -120,7 +121,7 @@ export default defineComponent({
if (resource.shareId) {
return buildShareSpaceResource({
shareId: resource.shareId,
shareName: resource.name,
shareName: basename(resource.shareRoot),
serverUrl: configurationManager.serverUrl
})
}
Expand Down
Loading