From 53f7c964ff464edd1c77b3712b7f3abbf5870dc6 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 4 Nov 2020 17:17:49 +0100 Subject: [PATCH 1/5] Add upload editor in files sidebar mode Signed-off-by: Vincent Petry --- src/FilesSidebarTabApp.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue index 9030defa171..c3085521f62 100644 --- a/src/FilesSidebarTabApp.vue +++ b/src/FilesSidebarTabApp.vue @@ -41,6 +41,7 @@ @@ -60,6 +61,7 @@ import { signalingKill } from './utils/webrtc/index' import { getCurrentUser } from '@nextcloud/auth' import { loadState } from '@nextcloud/initial-state' import Axios from '@nextcloud/axios' +import UploadEditor from './components/UploadEditor' import CallButton from './components/TopBar/CallButton' import ChatView from './components/ChatView' import duplicateSessionHandler from './mixins/duplicateSessionHandler' @@ -73,6 +75,7 @@ export default { components: { CallButton, ChatView, + UploadEditor, }, mixins: [ From 911e5e802c61489bf010b8a10b87f0db1ebac4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 6 Nov 2020 19:28:28 +0100 Subject: [PATCH 2/5] Add store action to discard an upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- src/components/UploadEditor.vue | 1 + src/store/fileUploadStore.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/components/UploadEditor.vue b/src/components/UploadEditor.vue index 085eae08b7f..85e98fd63af 100644 --- a/src/components/UploadEditor.vue +++ b/src/components/UploadEditor.vue @@ -122,6 +122,7 @@ export default { methods: { handleDismiss() { + this.$store.dispatch('discardUpload', this.currentUploadId) this.modalDismissed = true }, diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 19d27732352..4fba4a980d9 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -181,6 +181,10 @@ const mutations = { } } }, + + discardUpload(state, uploadId) { + Vue.delete(state.uploads, uploadId) + }, } const actions = { @@ -204,6 +208,15 @@ const actions = { }) }, + /** + * Discards an upload + * @param {object} param0 Commit and state + * @param {object} uploadId The unique uploadId + */ + discardUpload({ commit, state, getters }, uploadId) { + commit('discardUpload', { uploadId }) + }, + /** * Uploads the files to the root directory of the user * @param {object} param0 Commit, state and getters From 2232ab2f87a9704ca4c0e5bdfd7dddae177e3def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 6 Nov 2020 20:06:54 +0100 Subject: [PATCH 3/5] Clear state when starting or discarding uploads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The upload editor is shown based on both "showUploadEditor" (set in the store) and "modalDismissed" (set in the component). As "modalDismissed" is initially false and "showUploadEditor" was not cleared after an upload started or was discarded this caused the upload editor to be immediately shown if mounted again (for example, when joining a conversation in the Files app sidebar) if a previous upload was initialised. Signed-off-by: Daniel Calviño Sánchez --- src/store/fileUploadStore.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 4fba4a980d9..ff87ac1a15a 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -214,6 +214,11 @@ const actions = { * @param {object} uploadId The unique uploadId */ discardUpload({ commit, state, getters }, uploadId) { + if (state.currentUploadId === uploadId) { + commit('setCurrentUploadId', undefined) + commit('showUploadEditor', false) + } + commit('discardUpload', { uploadId }) }, @@ -223,6 +228,11 @@ const actions = { * @param {object} uploadId The unique uploadId */ async uploadFiles({ commit, dispatch, state, getters }, uploadId) { + if (state.currentUploadId === uploadId) { + commit('setCurrentUploadId', undefined) + commit('showUploadEditor', false) + } + EventBus.$emit('uploadStart') // Tag the previously indexed files and add the temporary messages to the From af013c8a8b2b09ad81ecc558d7d5530d3d099d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 6 Nov 2020 21:16:35 +0100 Subject: [PATCH 4/5] Remove no longer needed "modalDismissed" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As "showUploadEditor" is now properly updated in the store when an upload starts or discarded the "modalDismissed" property of the component is redundant and can be removed. Signed-off-by: Daniel Calviño Sánchez --- src/components/UploadEditor.vue | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/components/UploadEditor.vue b/src/components/UploadEditor.vue index 85e98fd63af..bc9c5978482 100644 --- a/src/components/UploadEditor.vue +++ b/src/components/UploadEditor.vue @@ -79,12 +79,6 @@ export default { Plus, }, - data() { - return { - modalDismissed: false, - } - }, - computed: { token() { return this.$store.getters.getToken() @@ -101,12 +95,8 @@ export default { return [] }, - showUploadEditor() { - return this.$store.getters.showUploadEditor - }, - showModal() { - return this.showUploadEditor && !this.modalDismissed + return this.$store.getters.showUploadEditor }, addMoreAriaLabel() { @@ -114,21 +104,13 @@ export default { }, }, - watch: { - currentUploadId() { - this.modalDismissed = false - }, - }, - methods: { handleDismiss() { this.$store.dispatch('discardUpload', this.currentUploadId) - this.modalDismissed = true }, handleUpload() { this.$store.dispatch('uploadFiles', this.currentUploadId) - this.modalDismissed = true }, /** * Clicks the hidden file input when clicking the correspondent ActionButton, From 87918f2cc365933d8bb25dd463579d68172fa548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 6 Nov 2020 21:20:15 +0100 Subject: [PATCH 5/5] Remove no longer needed "showUploadEditor" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As "showUploadEditor" is true only when "currentUploadId" is set and false otherwise there is no need to use a separate variable. Signed-off-by: Daniel Calviño Sánchez --- src/components/UploadEditor.vue | 2 +- src/store/fileUploadStore.js | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/components/UploadEditor.vue b/src/components/UploadEditor.vue index bc9c5978482..63dc05664b0 100644 --- a/src/components/UploadEditor.vue +++ b/src/components/UploadEditor.vue @@ -96,7 +96,7 @@ export default { }, showModal() { - return this.$store.getters.showUploadEditor + return !!this.currentUploadId }, addMoreAriaLabel() { diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index ff87ac1a15a..d341653eea3 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -34,7 +34,6 @@ const state = { uploads: { }, currentUploadId: undefined, - showUploadEditor: false, } const getters = { @@ -87,10 +86,6 @@ const getters = { currentUploadId: (state) => { return state.currentUploadId }, - - showUploadEditor: (state) => { - return state.showUploadEditor - }, } const mutations = { @@ -168,11 +163,6 @@ const mutations = { state.currentUploadId = currentUploadId }, - // Shows hides the upload editor - showUploadEditor(state, show) { - state.showUploadEditor = show - }, - removeFileFromSelection(state, fileId) { const uploadId = state.currentUploadId for (const key in state.uploads[uploadId].files) { @@ -192,8 +182,6 @@ const actions = { initialiseUpload({ commit, dispatch }, { uploadId, token, files }) { // Set last upload id commit('setCurrentUploadId', uploadId) - // Show upload editor - commit('showUploadEditor', true) files.forEach(file => { // Get localurl for previews @@ -216,7 +204,6 @@ const actions = { discardUpload({ commit, state, getters }, uploadId) { if (state.currentUploadId === uploadId) { commit('setCurrentUploadId', undefined) - commit('showUploadEditor', false) } commit('discardUpload', { uploadId }) @@ -230,7 +217,6 @@ const actions = { async uploadFiles({ commit, dispatch, state, getters }, uploadId) { if (state.currentUploadId === uploadId) { commit('setCurrentUploadId', undefined) - commit('showUploadEditor', false) } EventBus.$emit('uploadStart')