-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use the Vue store for spaces #6427
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,5 @@ | ||
Enhancement: Use the Vue store for spaces | ||
|
||
Using the store for spaces integrates them seamlessly in our ecosystem and makes it easier to develop spaces even further. E.g. the properties of a space can now be altered without fetching all spaces again. This was achieved by introducing a "buildSpace" method, that transforms a space into a more generic resource object (just like regular files or shares). | ||
|
||
https://github.com/owncloud/web/pull/6427 |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<template> | ||
<div class="space-overview"> | ||
<list-loader v-if="loadSpaceTask.isRunning" /> | ||
<list-loader v-if="loadFilesListTask.isRunning" /> | ||
<template v-else> | ||
<not-found-message v-if="!space.id" class="space-not-found oc-height-1-1" /> | ||
<div | ||
|
@@ -77,7 +77,7 @@ import { useStore, useRouter, useRouteQuery } from 'web-pkg/src/composables' | |
import marked from 'marked' | ||
import MixinAccessibleBreadcrumb from '../../mixins/accessibleBreadcrumb' | ||
import { bus } from 'web-pkg/src/instance' | ||
import { buildResource, buildWebDavSpacesPath } from '../../helpers/resources' | ||
import { buildResource, buildSpace, buildWebDavSpacesPath } from '../../helpers/resources' | ||
import ResourceTable, { determineSortFields } from '../../components/FilesList/ResourceTable.vue' | ||
import { createLocationSpaces } from '../../router' | ||
import { usePagination, useSort } from '../../composables' | ||
|
@@ -136,19 +136,13 @@ export default { | |
sortBy | ||
}) | ||
|
||
const loadSpaceTask = useTask(function* () { | ||
const response = yield graphClient.drives.getDrive(spaceId) | ||
space.value = response.data || {} | ||
}) | ||
const loadReadmeTask = useTask(function* (signal, ref) { | ||
const markdownEntry = space.value?.special?.find((el) => el?.specialFolder?.name === 'readme') | ||
|
||
if (!markdownEntry) { | ||
if (!space.value.spaceReadmeData) { | ||
return | ||
} | ||
|
||
const fileContents = yield ref.$client.files.getFileContents( | ||
buildWebDavSpacesPath(space.value.id, markdownEntry.name) | ||
buildWebDavSpacesPath(space.value.id, space.value.spaceReadmeData.name) | ||
) | ||
|
||
if (ref.markdownResizeObserver) { | ||
|
@@ -162,14 +156,12 @@ export default { | |
} | ||
}) | ||
const loadImageTask = useTask(function* (signal, ref) { | ||
const imageEntry = space.value?.special?.find((el) => el?.specialFolder?.name === 'image') | ||
|
||
if (!imageEntry) { | ||
if (!space.value.spaceImageData) { | ||
return | ||
} | ||
|
||
const fileContents = yield ref.$client.files.getFileContents( | ||
buildWebDavSpacesPath(space.value.id, imageEntry.name), | ||
buildWebDavSpacesPath(space.value.id, space.value.spaceImageData.name), | ||
{ | ||
responseType: 'arrayBuffer' | ||
} | ||
|
@@ -180,11 +172,30 @@ export default { | |
|
||
const loadFilesListTask = useTask(function* (signal, ref, sameRoute, path = null) { | ||
ref.CLEAR_CURRENT_FILES_LIST() | ||
const response = yield ref.$client.files.list( | ||
const graphResponse = yield graphClient.drives.getDrive(spaceId) | ||
|
||
if (!graphResponse.data) { | ||
return | ||
} | ||
|
||
space.value = buildSpace(graphResponse.data) | ||
|
||
const webDavResponse = yield ref.$client.files.list( | ||
buildWebDavSpacesPath(ref.$route.params.spaceId, path || '') | ||
) | ||
|
||
const resources = response.map(buildResource) | ||
let resources = [] | ||
if (!path) { | ||
// space front page -> use space as current folder | ||
resources.push(space.value) | ||
|
||
const webDavResources = webDavResponse.map(buildResource) | ||
webDavResources.shift() // Remove webdav entry for the space itself | ||
resources = resources.concat(webDavResources) | ||
} else { | ||
resources = webDavResponse.map(buildResource) | ||
} | ||
|
||
const currentFolder = resources.shift() | ||
|
||
ref.LOAD_FILES({ | ||
|
@@ -193,23 +204,22 @@ export default { | |
}) | ||
ref.loadIndicators({ | ||
client: ref.$client, | ||
currentFolder: currentFolder.path | ||
currentFolder: currentFolder?.path | ||
}) | ||
|
||
ref.accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute) | ||
ref.scrollToResourceFromRoute() | ||
}) | ||
|
||
const loadResourcesTask = useTask(function* (signal, ref, sameRoute, path) { | ||
yield loadSpaceTask.perform(ref) | ||
loadReadmeTask.perform(ref) | ||
loadImageTask.perform(ref) | ||
loadFilesListTask.perform(ref, sameRoute, path) | ||
yield loadFilesListTask.perform(ref, sameRoute, path) | ||
|
||
// Only load when in space root, no need to fetch in subdirectories | ||
if (!path) { | ||
loadReadmeTask.perform(ref) | ||
loadImageTask.perform(ref) | ||
} | ||
Comment on lines
+215
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
}) | ||
|
||
return { | ||
space, | ||
loadSpaceTask, | ||
loadImageTask, | ||
loadReadmeTask, | ||
markdownContent, | ||
|
@@ -276,9 +286,8 @@ export default { | |
const sameRoute = to.name === from?.name | ||
const sameItem = to.params?.item === from?.params?.item | ||
|
||
if (!sameRoute || !sameItem) { | ||
this.loadFilesListTask.perform(this, sameRoute, to.params.item) | ||
this.loadReadmeTask.perform(this) | ||
if ((!sameRoute || !sameItem) && from) { | ||
this.loadResourcesTask.perform(this, sameRoute, to.params.item) | ||
} | ||
}, | ||
immediate: true | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need those fields, afaik they will never be set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on how the respective fields are used throughout the code. Sometimes there are string modifications applied - which don't work on
undefined
. IMO ok to keep them defined and empty, like it's done here. Will be cleaned up anyway once we refactor this to TypeScript.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I understood @kulmann , these fields should be available to keep they resource object "aligned" with the other resources. Maybe I got it wrong though, @kulmann ? Jan is right, some of these fields will never be set.