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

fix(folders): empty content and unknown folder render #2577

Merged
merged 3 commits into from
Aug 8, 2024
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
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

39 changes: 25 additions & 14 deletions src/views/Folders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

<template>
<!-- Errors handlers-->
<NcEmptyContent v-if="error === 404" illustration-name="folder">
{{ t('photos', 'This folder does not exist') }}
<NcEmptyContent v-if="error === 404" :name="t('photos', 'This folder does not exist')">
<template #icon>
<FolderIcon />
</template>
</NcEmptyContent>
<NcEmptyContent v-else-if="error">
{{ t('photos', 'An error occurred') }}
</NcEmptyContent>
<NcEmptyContent v-else-if="initializing" icon="icon-loading">
{{ t('photos', 'Loading folders …') }}
<NcEmptyContent v-else-if="error" :name="t('photos', 'An error occurred')" />
<NcEmptyContent v-else-if="initializing" :name="t('photos', 'Loading folders …')">
<template #icon>
<NcLoadingIcon />
</template>
</NcEmptyContent>

<!-- Folder content -->
Expand All @@ -21,7 +23,7 @@
:class="{'photos-navigation--uploading': uploader.queue?.length > 0}"
:loading="loading"
:path="path"
:title="folder.basename.toString()"
:title="folder?.basename?.toString?.() || rootTitle"
:root-title="rootTitle"
@refresh="onRefresh">
<UploadPicker :accept="allowedMimes"
Expand All @@ -31,8 +33,10 @@
</HeaderNavigation>

<!-- Empty folder, should only happen via direct link -->
<NcEmptyContent v-if="isEmpty" key="emptycontent" illustration-name="empty">
{{ t('photos', 'No photos in here') }}
<NcEmptyContent v-if="isEmpty" key="emptycontent" :name="t('photos', 'No photos in here')">
<template #icon>
<FolderIcon />
</template>
</NcEmptyContent>

<div v-else
Expand All @@ -50,10 +54,11 @@
</template>

<script>
import { Folder as NcFolder, davParsePermissions } from '@nextcloud/files'
import { mapGetters } from 'vuex'
import { NcEmptyContent, NcLoadingIcon } from '@nextcloud/vue'
import { Upload, UploadPicker, getUploader } from '@nextcloud/upload'
import { Folder as NcFolder, davParsePermissions } from '@nextcloud/files'
import { NcEmptyContent } from '@nextcloud/vue'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import VirtualGrid from 'vue-virtual-grid'

import FileLegacy from '../components/FileLegacy.vue'
Expand All @@ -71,10 +76,12 @@ import getFileInfo from '../services/FileInfo.js'
export default {
name: 'Folders',
components: {
VirtualGrid,
FolderIcon,
HeaderNavigation,
NcEmptyContent,
NcLoadingIcon,
UploadPicker,
VirtualGrid,
},
mixins: [
AbortControllerMixin,
Expand Down Expand Up @@ -126,14 +133,18 @@ export default {
return this.files[this.folderId]
},
folderAsFolder() {
if (!this.folder) {
return null
}

return new NcFolder({
...this.folder,
source: decodeURI(this.folder.source),
permissions: davParsePermissions(this.folder.permissions),
})
},
folderContent() {
return this.folders[this.folderId]
return this.folders[this.folderId] || []
},
fileList() {
const list = this.folderContent
Expand Down
44 changes: 24 additions & 20 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-m
const WorkboxPlugin = require('workbox-webpack-plugin')
const { basename } = require('path')

const isDev = process.env.NODE_ENV === 'development'

webpackConfig.entry = {
main: path.join(__dirname, 'src', 'main.js'),
public: path.join(__dirname, 'src', 'public.js'),
Expand Down Expand Up @@ -89,27 +91,29 @@ webpackConfig.plugins.push(
})
)

// block creation of LICENSE.txt files now replaced with .license files
webpackConfig.optimization.minimizer = [new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
if (!isDev) {
// block creation of LICENSE.txt files now replaced with .license files
webpackConfig.optimization.minimizer = [new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
},
},
},
})]
})]

webpackConfig.plugins = [
...webpackConfig.plugins,
// Generate reuse license files
new WebpackSPDXPlugin({
override: {
// TODO: Remove if they fixed the license in the package.json
'@nextcloud/axios': 'GPL-3.0-or-later',
'@nextcloud/vue': 'AGPL-3.0-or-later',
'nextcloud-vue-collections': 'AGPL-3.0-or-later',
}
}),
]
webpackConfig.plugins = [
...webpackConfig.plugins,
// Generate reuse license files
new WebpackSPDXPlugin({
override: {
// TODO: Remove if they fixed the license in the package.json
'@nextcloud/axios': 'GPL-3.0-or-later',
'@nextcloud/vue': 'AGPL-3.0-or-later',
'nextcloud-vue-collections': 'AGPL-3.0-or-later',
}
}),
]
}

module.exports = webpackConfig
Loading