Skip to content

Commit

Permalink
feat(files): add uploader
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 17, 2023
1 parent a8fc62f commit 179ecd1
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<Home :size="20" />
</template>
</NcBreadcrumb>

<!-- Forward the actions slot -->
<template #actions>
<slot name="actions" />
</template>
</NcBreadcrumbs>
</template>

Expand Down
1 change: 0 additions & 1 deletion apps/files/src/components/FilesListHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default {
},
computed: {
enabled() {
console.debug('Enabled', this.header.id)
return this.header.enabled(this.currentFolder, this.currentView)
},
},
Expand Down
32 changes: 32 additions & 0 deletions apps/files/src/store/uploader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { defineStore } from 'pinia'
import type { UploaderStore } from '../types'

import { getUploader } from '@nextcloud/upload'
const uploader = getUploader()

export const useUploaderStore = defineStore('uploader', {
state: () => ({
queue: uploader.queue,
} as UploaderStore),
})
4 changes: 4 additions & 0 deletions apps/files/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ export interface RenamingStore {
renamingNode?: Node
newName: string
}

// Uploader store
export interface UploaderStore {
}
18 changes: 16 additions & 2 deletions apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
<NcAppContent data-cy-files-content>
<div class="files-list__header">
<!-- Current folder breadcrumbs -->
<BreadCrumbs :path="dir" @reload="fetchContent" />
<BreadCrumbs :path="dir" @reload="fetchContent">
<template #actions>
<!-- Uploader -->
<UploadPicker v-if="currentFolder"
:destination="currentFolder"
:multiple="true"
@uploaded="onUpload" />
</template>
</BreadCrumbs>

<!-- Secondary loading indicator -->
<NcLoadingIcon v-if="isRefreshing" class="files-list__refresh-icon" />
Expand Down Expand Up @@ -71,6 +79,7 @@ import { Folder, Node } from '@nextcloud/files'
import { join } from 'path'
import { orderBy } from 'natural-orderby'
import { translate } from '@nextcloud/l10n'
import { UploadPicker } from '@nextcloud/upload'
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
Expand Down Expand Up @@ -99,6 +108,7 @@ export default Vue.extend({
NcEmptyContent,
NcIconSvgWrapper,
NcLoadingIcon,
UploadPicker,
},
mixins: [
Expand Down Expand Up @@ -310,10 +320,14 @@ export default Vue.extend({
* @param {number} fileId the file id to get
* @return {Folder|File}
*/
getNode(fileId) {
getNode(fileId) {
return this.filesStore.getNode(fileId)
},
onUpload(...args) {
console.debug(args)
},
t: translate,
},
})
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Preview/MimeIconProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function searchfileName(string $fileName): null|string {
}
}

// Previously, we used to pass thi through Theming
// Previously, we used to pass this through Theming
// But it was only used to colour icons containing
// 0082c9. Since with vue we moved to inline svg icons,
// we can just use the default core icons.
Expand Down
130 changes: 130 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^2.1.2",
"@nextcloud/sharing": "^0.1.0",
"@nextcloud/upload": "^1.0.0-beta.11",
"@nextcloud/vue": "^8.0.0-beta.2",
"@nextcloud/vue-dashboard": "^2.0.1",
"@skjnldsv/sanitize-svg": "^1.0.2",
Expand Down

0 comments on commit 179ecd1

Please sign in to comment.