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] fix: render loading state before loading starts #7325

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-loading-state-in-views
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Loading state in views

We fixed a small glitch in views of the files app, where the view would show a state like "Resource not found" in the brief moment before the resource loading started. Now the views correctly start in a loading state.

https://github.com/owncloud/web/pull/7325
2 changes: 1 addition & 1 deletion packages/web-app-files/src/components/TrashBin.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<app-bar :breadcrumbs="breadcrumbs" :has-bulk-actions="true" />
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message
v-if="isEmpty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface ResourcesViewDefaultsResult<T, TT, TU extends any[]> {
fileListHeaderY: Ref<any>
refreshFileListHeaderPosition(): void
loadResourcesTask: Task<TT, TU>
areResourcesLoading: ComputedRef<boolean>
storeItems: ComputedRef<T[]>
fields: ComputedRef<SortField[]>
paginatedResources: ComputedRef<T[]>
Expand All @@ -41,6 +42,9 @@ export const useResourcesViewDefaults = <T, TT, TU extends any[]>(
options: ResourcesViewDefaultsOptions<TT, TU> = {}
): ResourcesViewDefaultsResult<T, TT, TU> => {
const loadResourcesTask = options.loadResourcesTask || folderService.getTask()
const areResourcesLoading = computed(() => {
return loadResourcesTask.isRunning || !loadResourcesTask.last
})

const store = useStore()
const { refresh: refreshFileListHeaderPosition, y: fileListHeaderY } = useFileListHeaderPosition()
Expand Down Expand Up @@ -84,6 +88,7 @@ export const useResourcesViewDefaults = <T, TT, TU extends any[]>(
fileListHeaderY,
refreshFileListHeaderPosition,
loadResourcesTask,
areResourcesLoading,
storeItems,
fields,
paginatedResources,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/Favorites.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<app-bar />
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message v-if="isEmpty" id="files-favorites-empty" class="files-empty" icon="star">
<template #message>
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/src/views/Personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<create-and-upload />
</template>
</app-bar>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<not-found-message v-if="folderNotFound" class="files-not-found oc-height-1-1" />
<no-content-message
Expand Down Expand Up @@ -199,7 +199,7 @@ export default defineComponent({

return this.$router.replace({
to,
params: { ...to.params, storageId },
params: { ...to.params, storageId, item: to.params.item || this.homeFolder },
query: to.query
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/PublicFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<create-and-upload />
</template>
</app-bar>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<not-found-message v-if="folderNotFound" class="files-not-found oc-height-1-1" />
<no-content-message
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/shares/SharedResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<create-and-upload />
</template>
</app-bar>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<not-found-message v-if="folderNotFound" class="files-not-found oc-height-1-1" />
<no-content-message
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/shares/SharedViaLink.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<app-bar :has-shares-navigation="true" />
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message
v-if="isEmpty"
Expand Down
10 changes: 4 additions & 6 deletions packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="oc-flex oc-flex-column">
<app-bar :has-shares-navigation="true" :has-bulk-actions="true" />
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<!-- Pending shares -->
<div v-if="hasPending">
Expand Down Expand Up @@ -210,11 +210,8 @@ export default defineComponent({
],

setup() {
const { fileListHeaderY, storeItems, fields, loadResourcesTask } = useResourcesViewDefaults<
Resource,
any,
any[]
>()
const { fileListHeaderY, storeItems, fields, loadResourcesTask, areResourcesLoading } =
useResourcesViewDefaults<Resource, any, any[]>()

const store = useStore()
const hasShareJail = useCapabilityShareJailEnabled()
Expand Down Expand Up @@ -272,6 +269,7 @@ export default defineComponent({
// defaults
fileListHeaderY,
loadResourcesTask,
areResourcesLoading,

// view specific
viewMode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<app-bar :has-shares-navigation="true" />
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message
v-if="isEmpty"
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<create-and-upload />
</template>
</app-bar>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<not-found-message v-if="!space.id" class="space-not-found oc-height-1-1" />
<div v-else-if="isSpaceRoot">
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<p v-text="spacesHint" />
</template>
</app-bar>
<app-loading-spinner v-if="loadResourcesTask.isRunning" />
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message
v-if="!spaces.length"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ describe('Trashbin component', () => {
$router
},
setup: () => ({
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
paginatedResources: paginatedResources,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/tests/unit/views/Favorites.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ function mountOptions({
stubs,
router: new VueRouter({ routes }),
setup: () => ({
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
...setup()
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/tests/unit/views/Personal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ function createWrapper(selectedFiles = [resourceForestJpg]) {
setup: () => ({
...Personal.setup(),
paginatedResources: [...resources],
areResourcesLoading: false,
loadResourcesTask: {
isRunning: false,
perform: jest.fn()
},
handleSort: jest.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ describe('PublicFiles view', () => {
breadcrumbs: () => []
},
setup: () => ({
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
paginatedResources: paginatedResources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ function mountOptions(store, loading, setup = {}) {
$router: router
},
setup: () => ({
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
...setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ function mountOptions({
$router: getRouter({ query })
},
setup: () => ({
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
handleSort: jest.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ describe('SharedWithOthers view', () => {
mounted: jest.fn(),
setup: () => ({
...SharedWithOthers.setup(),
areResourcesLoading: loading,
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
paginatedResources: paginatedResources,
Expand Down
5 changes: 4 additions & 1 deletion packages/web-app-files/tests/unit/views/views.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export const accentuatesTableRowTest = async <V extends Vue>(
$_fileActions_triggerDefaultAction: noop
}
}
]
],
setup: () => ({
areResourcesLoading: false
})
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const propsData = {
active: false,
target: exampleNavItem.route.path,
icon: exampleNavItem.icon,
index: 5,
index: '5',
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this related? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not. It just printed a warning to the console when running unit tests, so I fixed it. ;-)

id: '123'
}

Expand Down