Преглед на файлове

AMBARI-15598. Introduce "Copy Path to clipboard" feature for Files browser view UI (pallavkul)

Pallav Kulshreshtha преди 9 години
родител
ревизия
e35eaba8fb

+ 14 - 0
contrib/views/files/src/main/resources/ui/app/controllers/files.js

@@ -83,6 +83,20 @@ export default Ember.Controller.extend({
     return this.get('sortedContent');
   }),
 
+  selectedFilePathsText: function () {
+    var entities = this.get('fileSelectionService.files');
+    var multiplePaths = [];
+
+    if (entities.length === 0) {
+      return this.get('path');
+    } else {
+      multiplePaths = entities.map((entity) => {
+        return entity.get('path');
+      });
+      return multiplePaths.join(', ');
+    }
+  }.property('fileSelectionService.files.[]', 'path'),
+
   actions: {
     sortFiles: function(sortColumn) {
       if (sortColumn['sortOrder'] !== 0) {

+ 8 - 0
contrib/views/files/src/main/resources/ui/app/templates/files.hbs

@@ -42,6 +42,14 @@
       {{#if hasTrashPath}}
         {{#link-to 'files' (query-params path=trashPath) class="btn btn-sm btn-default"}}{{fa-icon "trash"}}{{/link-to}}
       {{/if}}
+      {{#copy-button
+        clipboardText=selectedFilePathsText
+        success="success"
+        error="error"
+        class="btn btn-sm btn-default"
+        }}
+          <i class="fa fa-clipboard"></i>
+      {{/copy-button}}
       <a href="#" {{action 'refreshCurrentRoute'}} class="btn btn-sm btn-default">{{fa-icon "refresh"}}</a>
       {{files-breadcrumb path=path}}
     </div>

+ 2 - 1
contrib/views/files/src/main/resources/ui/bower.json

@@ -13,7 +13,8 @@
     "bootstrap-treeview": "~1.2.0",
     "moment": "~2.11.1",
     "font-awesome": "~4.5.0",
-    "ember-uploader": "~0.3.11"
+    "ember-uploader": "~0.3.11",
+    "clipboard": "~1.5.5"
   },
   "resolutions": {
     "ember": "2.2.0"

+ 1 - 0
contrib/views/files/src/main/resources/ui/package.json

@@ -39,6 +39,7 @@
     "ember-cli-release": "0.2.8",
     "ember-cli-sri": "^2.0.0",
     "ember-cli-uglify": "^1.2.0",
+    "ember-cli-clipboard": "^0.3.1",
     "ember-collection": "git://github.com/emberjs/ember-collection.git#bf752508a501161791e3f3b9a546c9b97d5c387a",
     "ember-data": "2.3.0",
     "ember-disable-proxy-controllers": "^1.0.1",