diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 637f2235d..6b008a3df 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -958,7 +958,7 @@ desktop/views/components/drive.file.vue: unmark-as-sensitive: "閲覧注意を解除" copy-url: "URLをコピー" download: "ダウンロード" - else-files: "その他..." + else-files: "その他" set-as-avatar: "アイコンに設定" set-as-banner: "バナーに設定" open-in-app: "アプリで開く" @@ -969,6 +969,7 @@ desktop/views/components/drive.file.vue: copied-url-to-clipboard: "URLをクリップボードにコピーしました" desktop/views/components/drive.folder.vue: + upload-folder: "既定アップロード先" unable-to-process: "操作を完了できません" circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" unhandled-error: "不明なエラー" @@ -980,6 +981,8 @@ desktop/views/components/drive.folder.vue: rename: "名前を変更" rename-folder: "フォルダ名の変更" input-new-folder-name: "新しいフォルダ名を入力してください" + else-folders: "その他" + set-as-upload-folder: "既定アップロード先に設定" desktop/views/components/drive.vue: search: "検索" @@ -1143,6 +1146,9 @@ common/views/components/drive-settings.vue: max: "容量" in-use: "使用中" stats: "統計" + default-upload-folder: "既定のアップロード先フォルダ" + default-upload-folder-name: "フォルダ" + change-default-upload-folder: "フォルダを変更" common/views/components/mute-and-block.vue: mute-and-block: "ミュートとブロック" diff --git a/src/client/app/common/scripts/post-form.ts b/src/client/app/common/scripts/post-form.ts index 7cd2e7c31..1d93b4c26 100644 --- a/src/client/app/common/scripts/post-form.ts +++ b/src/client/app/common/scripts/post-form.ts @@ -245,7 +245,7 @@ export default (opts) => ({ }, upload(file) { - (this.$refs.uploader as any).upload(file); + (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder); }, onChangeUploadings(uploads) { diff --git a/src/client/app/common/views/components/messaging-room.form.vue b/src/client/app/common/views/components/messaging-room.form.vue index 1dfb0589e..74e30d29e 100644 --- a/src/client/app/common/views/components/messaging-room.form.vue +++ b/src/client/app/common/views/components/messaging-room.form.vue @@ -158,7 +158,7 @@ export default Vue.extend({ }, upload(file) { - (this.$refs.uploader as any).upload(file); + (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder); }, onUploaded(file) { diff --git a/src/client/app/common/views/components/settings/drive.vue b/src/client/app/common/views/components/settings/drive.vue index 7bdc806ae..9b049c98e 100644 --- a/src/client/app/common/views/components/settings/drive.vue +++ b/src/client/app/common/views/components/settings/drive.vue @@ -11,6 +11,12 @@
{{ $t('stats') }}
+ +
+
{{ $t('default-upload-folder') }}
+ {{ $t('default-upload-folder-name') }} + {{ $t('change-default-upload-folder') }} +
@@ -26,7 +32,8 @@ export default Vue.extend({ return { fetching: true, usage: null, - capacity: null + capacity: null, + uploadFolderName: null }; }, @@ -40,10 +47,25 @@ export default Vue.extend({ l: 0.5 }) }; - } + }, + + uploadFolder: { + get() { return this.$store.state.settings.uploadFolder; }, + set(value) { this.$store.dispatch('settings/set', { key: 'uploadFolder', value }); } + }, }, mounted() { + if (this.uploadFolder == null) { + this.uploadFolderName = this.$t('@._settings.root'); + } else { + this.$root.api('drive/folders/show', { + folderId: this.uploadFolder + }).then(folder => { + this.uploadFolderName = folder.name; + }); + } + this.$root.api('drive').then(info => { this.capacity = info.capacity; this.usage = info.usage; @@ -152,6 +174,13 @@ export default Vue.extend({ chart.render(); }); + }, + + chooseUploadFolder() { + this.$chooseDriveFolder().then(folder => { + this.uploadFolder = folder ? folder.id : null; + this.uploadFolderName = folder ? folder.name : this.$t('@._settings.root'); + }) } } }); diff --git a/src/client/app/common/views/widgets/post-form.vue b/src/client/app/common/views/widgets/post-form.vue index e180290f9..5e577c9a4 100644 --- a/src/client/app/common/views/widgets/post-form.vue +++ b/src/client/app/common/views/widgets/post-form.vue @@ -122,7 +122,7 @@ export default define({ }, upload(file) { - (this.$refs.uploader as any).upload(file); + (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder); }, onDragover(e) { diff --git a/src/client/app/desktop/views/components/drive.folder.vue b/src/client/app/desktop/views/components/drive.folder.vue index bc74ed431..cf59d51b0 100644 --- a/src/client/app/desktop/views/components/drive.folder.vue +++ b/src/client/app/desktop/views/components/drive.folder.vue @@ -20,6 +20,9 @@ {{ folder.name }}

+

+ {{ $t('upload-folder') }} +

@@ -73,6 +76,14 @@ export default Vue.extend({ text: this.$t('@.delete'), icon: ['far', 'trash-alt'], action: this.deleteFolder + }, null, { + type: 'nest', + text: this.$t('contextmenu.else-folders'), + menu: [{ + type: 'item', + text: this.$t('contextmenu.set-as-upload-folder'), + action: this.setAsUploadFolder + }] }], { closed: () => { this.isContextmenuShowing = false; @@ -213,6 +224,13 @@ export default Vue.extend({ deleteFolder() { this.$root.api('drive/folders/delete', { folderId: this.folder.id + }).then(() => { + if (this.$store.state.settings.uploadFolder === this.folder.id) { + this.$store.dispatch('settings/set', { + key: 'uploadFolder', + value: null + }); + } }).catch(err => { switch(err.id) { case 'b0fc8a17-963c-405d-bfbc-859a487295e1': @@ -229,7 +247,14 @@ export default Vue.extend({ }); } }); - } + }, + + setAsUploadFolder() { + this.$store.dispatch('settings/set', { + key: 'uploadFolder', + value: this.folder.id + }); + }, } }); @@ -279,4 +304,10 @@ export default Vue.extend({ margin-left 2px text-align left + > .upload + margin 4px 4px + font-size 0.8em + text-align right + color var(--desktopDriveFolderFg) + diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 852d2c393..f5c89e24f 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -38,6 +38,7 @@ const defaultSettings = { homeProfiles: {}, mobileHomeProfiles: {}, deckProfiles: {}, + uploadFolder: null, }; const defaultDeviceSettings = {