From 9c491bd92653b7be0a48aed4bdd3e7a1b9a2bcab Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Thu, 21 Dec 2017 15:31:44 -0800 Subject: [PATCH] Remove unused pattern-checker directive. --- .../__tests__/pattern_checker.js | 95 ------------------- src/ui/public/pattern_checker/index.js | 1 - .../pattern_checker/pattern_checker.html | 2 - .../public/pattern_checker/pattern_checker.js | 52 ---------- .../pattern_checker/pattern_checker.less | 3 - 5 files changed, 153 deletions(-) delete mode 100644 src/ui/public/pattern_checker/__tests__/pattern_checker.js delete mode 100644 src/ui/public/pattern_checker/index.js delete mode 100644 src/ui/public/pattern_checker/pattern_checker.html delete mode 100644 src/ui/public/pattern_checker/pattern_checker.js delete mode 100644 src/ui/public/pattern_checker/pattern_checker.less diff --git a/src/ui/public/pattern_checker/__tests__/pattern_checker.js b/src/ui/public/pattern_checker/__tests__/pattern_checker.js deleted file mode 100644 index 0e0e80ffc3977..0000000000000 --- a/src/ui/public/pattern_checker/__tests__/pattern_checker.js +++ /dev/null @@ -1,95 +0,0 @@ -import ngMock from 'ng_mock'; -import expect from 'expect.js'; -import _ from 'lodash'; -import sinon from 'sinon'; - -describe('pattern checker', function () { - let $httpBackend; - let $compile; - let $rootScope; - let apiResponse; - let $timeout; - const notifyFatalStub = sinon.stub(); - - beforeEach(ngMock.module('kibana')); - - beforeEach(ngMock.module(function ($provide) { - notifyFatalStub.reset(); - - $provide.value('Notifier', function () { - this.fatal = notifyFatalStub; - }); - })); - - beforeEach(ngMock.inject(function ($injector) { - $httpBackend = $injector.get('$httpBackend'); - $compile = $injector.get('$compile'); - $rootScope = $injector.get('$rootScope'); - $timeout = $injector.get('$timeout'); - - apiResponse = $httpBackend.when('POST', /\/api\/kibana\/.*\/_count/); - })); - - it('should display the number of documents in a given index pattern', function () { - apiResponse.respond(200, { count: 1 }); - - const element = $compile('')($rootScope); - - $httpBackend.flush(); - $rootScope.$digest(); - expect(_.contains(element.html(), `1 results`)).to.be.ok(); - }); - - it('should poll the api for changes to the document count and update the ui', function () { - apiResponse.respond(200, { count: 1 }); - - const element = $compile('')($rootScope); - - $httpBackend.flush(); - $rootScope.$digest(); - expect(_.contains(element.html(), `1 results`)).to.be.ok(); - - apiResponse.respond(200, { count: 2 }); - $timeout.flush(); - $httpBackend.flush(); - $rootScope.$digest(); - expect(_.contains(element.html(), `2 results`)).to.be.ok(); - }); - - it('should display 0 results when API responds with 404', function () { - apiResponse.respond(404); - - const element = $compile('')($rootScope); - - $httpBackend.flush(); - $rootScope.$digest(); - expect(_.contains(element.html(), `0 results`)).to.be.ok(); - }); - - it('should throw a fatal notificaiton for any error other than a 404', function () { - apiResponse.respond(500, 'Bad things happened'); - - $compile('')($rootScope); - - $httpBackend.flush(); - $rootScope.$digest(); - - expect(notifyFatalStub.called).to.be.ok(); - }); - - it('should stop polling when the scope is destroyed', function () { - apiResponse.respond(200, { count: 1 }); - - const element = $compile('')($rootScope); - const scope = element.scope(); - - $httpBackend.flush(); - $rootScope.$digest(); - expect(_.contains(element.html(), `1 results`)).to.be.ok(); - - scope.$destroy(); - $timeout.flush(); - $httpBackend.verifyNoOutstandingRequest(); - }); - -}); diff --git a/src/ui/public/pattern_checker/index.js b/src/ui/public/pattern_checker/index.js deleted file mode 100644 index 985720accc617..0000000000000 --- a/src/ui/public/pattern_checker/index.js +++ /dev/null @@ -1 +0,0 @@ -import './pattern_checker'; diff --git a/src/ui/public/pattern_checker/pattern_checker.html b/src/ui/public/pattern_checker/pattern_checker.html deleted file mode 100644 index 1ae4f725400bb..0000000000000 --- a/src/ui/public/pattern_checker/pattern_checker.html +++ /dev/null @@ -1,2 +0,0 @@ - -
Querying {{checker.pattern}}... {{checker.resultCount}} results
diff --git a/src/ui/public/pattern_checker/pattern_checker.js b/src/ui/public/pattern_checker/pattern_checker.js deleted file mode 100644 index 52e0ebe221965..0000000000000 --- a/src/ui/public/pattern_checker/pattern_checker.js +++ /dev/null @@ -1,52 +0,0 @@ -import { uiModules } from 'ui/modules'; -import { callAfterBindingsWorkaround } from 'ui/compat'; -import template from './pattern_checker.html'; -import './pattern_checker.less'; -import chrome from 'ui/chrome'; - -const module = uiModules.get('kibana'); - -module.directive('patternChecker', function () { - return { - restrict: 'E', - template: template, - controllerAs: 'checker', - bindToController: true, - scope: { - pattern: '=' - }, - controller: callAfterBindingsWorkaround(function (Notifier, $scope, $timeout, $http) { - let validationTimeout; - - const notify = new Notifier({ - location: 'Add Data' - }); - - this.validateInstall = () => { - $http.post(chrome.addBasePath(`/api/kibana/${this.pattern}/_count`)) - .then( - (response) => { - this.resultCount = response.data.count; - }, - (error) => { - if (error.status === 404) { - this.resultCount = 0; - } - else { - notify.fatal(error); - } - } - ) - .then(() => { - validationTimeout = $timeout(this.validateInstall, 5000); - }); - }; - - $scope.$on('$destroy', () => { - $timeout.cancel(validationTimeout); - }); - - this.validateInstall(); - }) - }; -}); diff --git a/src/ui/public/pattern_checker/pattern_checker.less b/src/ui/public/pattern_checker/pattern_checker.less deleted file mode 100644 index a7037ee5cf17b..0000000000000 --- a/src/ui/public/pattern_checker/pattern_checker.less +++ /dev/null @@ -1,3 +0,0 @@ -pattern-checker .spinner { - padding: 0 1em; -}