Просмотр исходного кода

Merge pull request #2624 from overleaf/hb-warning-nearing-file-limit

Show warning near or above file limit in upload modal

GitOrigin-RevId: 75e7c41e526ccde9516f7caf6ef1b9cbc59c2439
Hugh O'Brien 6 лет назад
Родитель
Сommit
d20518fdd4

+ 5 - 1
services/web/app/views/project/editor/new-file-modal.pug

@@ -1,7 +1,7 @@
 script(type='text/ng-template', id='newFileModalTemplate')
 	.modal-header
 		h3 Add Files
-	.modal-body.modal-new-file
+	.modal-body.modal-new-file(ng-if="file_count < 2000")
 		table
 			tr
 				td.modal-new-file--list
@@ -190,6 +190,10 @@ script(type='text/ng-template', id='newFileModalTemplate')
 					!= moduleIncludes("newFileModal:panel", locals)
 
 	.modal-footer
+		.modal-footer-left.approaching-file-limit(ng-if="file_count > 1900 && file_count < 2000")
+			|	#{translate("project_approaching_file_limit")} ({{file_count}}/2000)
+		.alert.alert-warning.at-file-limit(ng-if="file_count >= 2000")
+			|	#{translate("project_has_too_many_files")}
 		button.btn.btn-default(
 			ng-disabled="state.inflight"
 			ng-click="cancel()"

+ 8 - 0
services/web/frontend/js/ide/file-tree/FileTreeManager.js

@@ -167,6 +167,14 @@ define([
       return entities
     }
 
+    getFullCount() {
+      const entities = []
+      this.forEachEntity(function(e) {
+        return entities.push(e)
+      })
+      return entities.length
+    }
+
     getMultiSelectedEntityChildNodes() {
       // use pathnames with a leading slash to avoid
       // problems with reserved Object properties

+ 1 - 0
services/web/frontend/js/ide/file-tree/controllers/FileTreeController.js

@@ -143,6 +143,7 @@ define(['base'], function(App) {
     projectFeatures,
     userFeatures
   ) {
+    $scope.file_count = ide.fileTreeManager.getFullCount()
     $scope.type = type
     $scope.parent_folder = parent_folder
     $scope.state = {

+ 10 - 0
services/web/frontend/stylesheets/app/editor/file-tree.less

@@ -338,3 +338,13 @@
 .modal-new-file--body-upload {
   padding-top: 20px;
 }
+
+.modal-footer {
+  .approaching-file-limit {
+    font-weight: bold;
+  }
+
+  .at-file-limit {
+    text-align: left;
+  }
+}