From 965a46291b0d8f5784196f62f1ec10dc6b3b2d6a Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 8 Jun 2017 15:55:17 +0100 Subject: [PATCH] Only fetch labels for uploaded docs, not files --- .../Features/Uploads/FileSystemImportManager.coffee | 8 ++++++-- .../Features/Uploads/ProjectUploadController.coffee | 2 +- .../directives/aceEditor/labels/LabelsManager.coffee | 5 +++-- .../ide/file-tree/controllers/FileTreeController.coffee | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/services/web/app/coffee/Features/Uploads/FileSystemImportManager.coffee b/services/web/app/coffee/Features/Uploads/FileSystemImportManager.coffee index 04c7c3bcc7..f491807e9d 100644 --- a/services/web/app/coffee/Features/Uploads/FileSystemImportManager.coffee +++ b/services/web/app/coffee/Features/Uploads/FileSystemImportManager.coffee @@ -96,9 +96,13 @@ module.exports = FileSystemImportManager = FileTypeManager.isBinary name, path, (error, isBinary) => return callback(error) if error? if isBinary - FileSystemImportManager.addFile user_id, project_id, folder_id, name, path, replace, callback + FileSystemImportManager.addFile user_id, project_id, folder_id, name, path, replace, (err, entity) -> + entity?.type = 'file' + callback(err, entity) else - FileSystemImportManager.addDoc user_id, project_id, folder_id, name, path, replace, callback + FileSystemImportManager.addDoc user_id, project_id, folder_id, name, path, replace, (err, entity) -> + entity?.type = 'doc' + callback(err, entity) _isSafeOnFileSystem: (path, callback = (err, isSafe)->)-> diff --git a/services/web/app/coffee/Features/Uploads/ProjectUploadController.coffee b/services/web/app/coffee/Features/Uploads/ProjectUploadController.coffee index 209faec104..ff8c5aa827 100644 --- a/services/web/app/coffee/Features/Uploads/ProjectUploadController.coffee +++ b/services/web/app/coffee/Features/Uploads/ProjectUploadController.coffee @@ -50,5 +50,5 @@ module.exports = ProjectUploadController = logger.log project_id: project_id, file_path: path, file_name: name, folder_id: folder_id "uploaded file" - res.send success: true, entity_id: entity?._id + res.send success: true, entity_id: entity?._id, entity_type: entity?.type diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee index e4aa96d15e..5b58cd905c 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee @@ -31,8 +31,9 @@ define [ if entity.type == 'doc' delete @state.documents[entity.id] - @$scope.$on 'file:upload:complete', (e, entityId) => - @loadDocLabelsFromServer(entityId) + @$scope.$on 'file:upload:complete', (e, upload) => + if upload.entity_type == 'doc' + @loadDocLabelsFromServer(upload.entity_id) onChange = (change) => if change.remote diff --git a/services/web/public/coffee/ide/file-tree/controllers/FileTreeController.coffee b/services/web/public/coffee/ide/file-tree/controllers/FileTreeController.coffee index 0eeb86c9c1..8d23394e39 100644 --- a/services/web/public/coffee/ide/file-tree/controllers/FileTreeController.coffee +++ b/services/web/public/coffee/ide/file-tree/controllers/FileTreeController.coffee @@ -135,7 +135,7 @@ define [ $timeout (() -> uploadCount-- if response.success - $rootScope.$broadcast 'file:upload:complete', response.entity_id + $rootScope.$broadcast 'file:upload:complete', response if uploadCount == 0 and response? and response.success $modalInstance.close("done") ), 250