Skip to content

Commit

Permalink
Merge pull request #45860 from nextcloud/fix/files-handle-failed-state
Browse files Browse the repository at this point in the history
fix(files): Bring back handling of failed files
  • Loading branch information
susnux authored Jun 24, 2024
2 parents c76c954 + 0bd7c76 commit 0dc0a9b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="files-list__row"
v-on="rowListeners">
<!-- Failed indicator -->
<span v-if="source.attributes.failed" class="files-list__row--failed" />
<span v-if="isFailedSource" class="files-list__row--failed" />

<!-- Checkbox -->
<FileEntryCheckbox :fileid="fileid"
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
import CustomElementRender from '../CustomElementRender.vue'

import { useNavigation } from '../../composables/useNavigation'
import CustomElementRender from '../CustomElementRender.vue'
import logger from '../../logger.js'

// The registered actions list
Expand Down Expand Up @@ -160,7 +160,7 @@ export default defineComponent({

// Sorted actions that are enabled for this node
enabledActions() {
if (this.source.attributes.failed) {
if (this.source.status === NodeStatus.FAILED) {
return []
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry/FileEntryName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default defineComponent({
},

linkTo() {
if (this.source.attributes.failed) {
if (this.source.status === NodeStatus.FAILED) {
return {
is: 'span',
params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntryGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@dragend="onDragEnd"
@drop="onDrop">
<!-- Failed indicator -->
<span v-if="source.attributes.failed" class="files-list__row--failed" />
<span v-if="isFailedSource" class="files-list__row--failed" />

<!-- Checkbox -->
<FileEntryCheckbox :fileid="fileid"
Expand Down
11 changes: 9 additions & 2 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export default defineComponent({
computed: {
currentDir() {
// Remove any trailing slash but leave root slash
return (this.$route?.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
return (this.$route.query?.dir?.toString() || '/').replace(/^(.+)\/$/, '$1')
},
currentFileId() {
return this.$route.params?.fileid || this.$route.query?.fileid || null
},

fileid() {
return this.source?.fileid
return this.source.fileid ?? 0
},
uniqueId() {
return hashCode(this.source.source)
Expand Down Expand Up @@ -102,6 +102,13 @@ export default defineComponent({
return String(this.fileid) === String(this.currentFileId)
},

/**
* Check if the source is in a failed state after an API request
*/
isFailedSource() {
return this.source.status === NodeStatus.FAILED
},

canDrag() {
if (this.isRenaming) {
return false
Expand Down
5 changes: 5 additions & 0 deletions apps/files/src/utils/hashUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/**
* Simple non-secure hashing function similar to Java's `hashCode`
* @param str The string to hash
* @return {number} a non secure hash of the string
*/
export const hashCode = function(str: string): number {
let hash = 0
for (let i = 0; i < str.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit 0dc0a9b

Please sign in to comment.