Merge pull request #5025 from w33ble/farewell-zeroclipboard-and-thanks-for-all-the-fish

Remove ng-clip and zeroclipboard
This commit is contained in:
Jonathan Budzenski 2015-09-23 15:58:51 -05:00
commit f74eafe5f7
14 changed files with 3 additions and 187 deletions

View file

@ -72,8 +72,7 @@ in your Web page.
NOTE: A user must have Kibana access in order to view embedded dashboards.
Click the *Share* button to display HTML code to embed the dashboard in another Web page, along with a direct link to
the dashboard. Click the copy button image:images/Clipboard.png[Copy to Clipboard button] next to either option to copy
the code or the link to your clipboard.
the dashboard. You can select the text in either option to copy the code or the link to your clipboard.
[float]
[[embedding-dashboards]]

View file

@ -107,7 +107,6 @@
"minimatch": "2.0.10",
"mkdirp": "0.5.1",
"moment": "2.10.6",
"ng-clip": "0.2.6",
"raw-loader": "0.5.1",
"request": "2.61.0",
"requirefrom": "0.2.0",
@ -120,8 +119,7 @@
"url-loader": "0.5.6",
"webpack": "1.12.1",
"webpack-directory-name-as-main": "1.0.0",
"whatwg-fetch": "0.9.0",
"zeroclipboard": "2.2.0"
"whatwg-fetch": "0.9.0"
},
"devDependencies": {
"Nonsense": "0.1.2",

View file

@ -4,7 +4,6 @@
<div class="form-group">
<label>
Vis State
<kbn-clipboard copy="visStateJson"></kbn-clipboard>
</label>
<pre>{{visStateJson}}</pre>
</div>

View file

@ -3,8 +3,6 @@ define(function (require) {
require('ui/registry/spy_modes').register(VisDetailsSpyProvider);
function VisDetailsSpyProvider(Notifier, $filter, $rootScope, config) {
require('ui/clipboard');
return {
name: 'debug',
display: 'Debug',

View file

@ -10,7 +10,6 @@ define(function (require) {
require('ui/config');
require('ui/notify');
require('ui/typeahead');
require('ui/clipboard');
require('plugins/kibana/dashboard/directives/grid');
require('plugins/kibana/dashboard/components/panel/panel');

View file

@ -3,8 +3,7 @@
<p>
<div class="input-group">
<label>
Embed this dashboard.
<kbn-clipboard copy="opts.shareData().embed"></kbn-clipboard>
Embed this dashboard
<small>Add to your html source. Note all clients must still be able to access kibana</small>
</label>
<div class="form-control" disabled>{{opts.shareData().embed}}</div>
@ -15,7 +14,6 @@
<div class="input-group">
<label>
Share a link
<kbn-clipboard copy="opts.shareData().link"></kbn-clipboard>
</label>
<div class="form-control" disabled>{{opts.shareData().link}}</div>
</div>

View file

@ -5,7 +5,6 @@ define(function (require) {
require('plugins/kibana/visualize/editor/agg_filter');
require('ui/visualize');
require('ui/clipboard');
require('ui/collapsible_sidebar');
require('ui/routes')

View file

@ -4,7 +4,6 @@
<div class="form-group">
<label>
Embed this visualization.
<kbn-clipboard copy="conf.shareData().embed"></kbn-clipboard>
<small>Add to your html source. Note all clients must still be able to access kibana</small>
</label>
<div class="form-control" disabled>{{conf.shareData().embed}}</div>
@ -15,7 +14,6 @@
<div class="form-group">
<label>
Share a link
<kbn-clipboard copy="conf.shareData().link"></kbn-clipboard>
</label>
<div class="form-control" disabled>{{conf.shareData().link}}</div>
</div>

View file

@ -1,100 +0,0 @@
var angular = require('angular');
var _ = require('lodash');
var sinon = require('auto-release-sinon');
var expect = require('expect.js');
var $ = require('jquery');
var ngMock = require('ngMock');
require('ui/clipboard');
describe('Clipboard directive', function () {
var $scope;
var $rootScope;
var $compile;
var $interpolate;
var el;
var tips;
function init() {
// load the application
ngMock.module('kibana');
ngMock.inject(function (_$rootScope_, _$compile_, _$interpolate_) {
$rootScope = _$rootScope_;
$compile = _$compile_;
$interpolate = _$interpolate_;
$rootScope.text = 'foo';
el = $compile('<kbn-clipboard copy="text"></kbn-clipboard>')($rootScope);
$scope = el.scope();
$scope.$digest();
});
}
describe.skip('With flash disabled', function () {
beforeEach(function () {
sinon.stub(window.ZeroClipboard, 'isFlashUnusable', _.constant(true));
init();
});
it('should be an empty element', function () {
expect(el.children()).to.have.length(0);
});
it('should not show the tooltip', function () {
var clip = el.find('[tooltip]');
expect(clip).to.have.length(0);
});
it('should not show the clipboard button', function () {
var clip = el.find('[clip-copy]');
expect(clip).to.have.length(0);
});
});
describe.skip('With flash enabled', function () {
beforeEach(function () {
sinon.stub(window.ZeroClipboard, 'isFlashUnusable', _.constant(false));
init();
});
it('should contain an element with clip-copy', function () {
var clip = el.find('[clip-copy]');
expect(clip).to.have.length(1);
});
it('should have a tooltip', function () {
var clip = el.find('[tooltip]');
expect(clip).to.have.length(1);
var clipText = $interpolate($(clip).attr('tooltip'))();
expect(clipText).to.be('Copy to clipboard');
});
it('should change the tooltip text when clicked, back when mouse leaves', function () {
el.mouseenter();
el.click();
$scope.$digest();
var clipText = $interpolate($('[tooltip]', el).attr('tooltip'))();
expect(clipText).to.be('Copied!');
el.mouseleave();
$scope.$digest();
clipText = $interpolate($('[tooltip]', el).attr('tooltip'))();
expect(clipText).to.be('Copy to clipboard');
});
it('should unbind all handlers on destroy', function () {
var handlers = $._data(el.get(0), 'events');
expect(Object.keys(handlers)).to.have.length(2);
$scope.$destroy();
expect(Object.keys(handlers)).to.have.length(0);
});
});
});

View file

@ -1,11 +0,0 @@
<span>
<a
ng-if="!disabled"
tooltip="{{shownText}}"
tooltip-placement="{{tipPlacement}}"
tooltip-animation="false"
tooltip-popup-delay="0"
tooltip-append-to-body="true">
<i class="fa" ng-class="icon" clip-copy="copyText"></i>
</a>
</span>

View file

@ -1,47 +0,0 @@
define(function (require) {
var ZeroClipboard = require('ng-clip');
var $ = require('jquery');
var html = require('ui/clipboard/clipboard.html');
require('ui/modules')
.get('kibana')
.directive('kbnClipboard', function ($compile, $timeout) {
return {
restrict: 'E',
template: html,
replace: true,
scope: {
copyText: '=copy'
},
transclude: true,
link: function ($scope, $el, attr) {
if (ZeroClipboard.isFlashUnusable()) {
$scope.disabled = true;
return;
}
$scope.tipPlacement = attr.tipPlacement || 'top';
$scope.tipText = attr.tipText || 'Copy to clipboard';
$scope.tipConfirm = attr.tipConfirm = 'Copied!';
$scope.icon = attr.icon || 'fa-clipboard';
$scope.shownText = $scope.tipText;
$el.on('click', function () {
$scope.shownText = $scope.tipConfirm;
// Reposition tooltip to account for text length change
$('a', $el).mouseenter();
});
$el.on('mouseleave', function () {
$scope.shownText = $scope.tipText;
});
$scope.$on('$destroy', function () {
$el.off('click');
$el.off('mouseleave');
});
}
};
});
});

View file

@ -48,7 +48,6 @@ module.exports = function (grunt) {
'Nonsense@0.1.2': ['Public-Domain'],
'pkginfo@0.2.3': ['MIT'],
'uglify-js@2.2.5': ['BSD'],
'zeroclipboard@2.2.0': ['MIT'],
}
}
};

View file

@ -1,4 +0,0 @@
require('angular');
require('zeroclipboard');
require('node_modules/ng-clip/src/ngClip');
require('ui/modules').get('kibana', ['ngClipboard']);

View file

@ -1,9 +0,0 @@
// ng-clip expects ZeroClipboard to be global, but it's UMD, so it never is
window.ZeroClipboard = require('node_modules/zeroclipboard/dist/ZeroClipboard.js');
window.ZeroClipboard.SWF_URL = require('file!node_modules/zeroclipboard/dist/ZeroClipboard.swf');
window.ZeroClipboard.config({
swfPath: window.ZeroClipboard.SWF_URL,
});
module.exports = window.ZeroClipboard;