Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/render_complete 👉 src/plugins/kibana_utils #44743

Merged
merged 10 commits into from
Sep 25, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import './lib/pager';

import { getLimitedSearchResultsMessage } from './doc_table_strings';

uiModules
.get('app/discover')
uiModules.get('app/discover')
Copy link
Contributor Author

@sainthkh sainthkh Sep 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkime I reverted to old code. But according to the JavaScript Styleguide, it is recommended to use prettier. I guess that the our goal is to change the entire code base with prettier like the previous version of this commit.

Later, I should break the commit when there are changes by prettier to help others distinguish what's done by me and what's done by prettier.

If you're new to prettier, you can learn how to set up in this article. You'll soon wonder how you wrote code without this.

(Edit: I removed note because it's somewhat fixed after reinstall.)

.directive('docTable', function (config, getAppState, pagerFactory, $filter) {
return {
restrict: 'E',
Expand All @@ -53,13 +52,13 @@ uiModules
inspectorAdapters: '=?',
},
link: function ($scope, $el) {
$scope.$watch('minimumVisibleRows', minimumVisibleRows => {
$scope.$watch('minimumVisibleRows', (minimumVisibleRows) => {
$scope.limit = Math.max(minimumVisibleRows || 50, $scope.limit || 50);
});

$scope.persist = {
sorting: $scope.sorting,
columns: $scope.columns,
columns: $scope.columns
};

const limitTo = $filter('limitTo');
Expand All @@ -68,9 +67,7 @@ uiModules
$scope.pageOfItems = limitTo($scope.hits, $scope.pager.pageSize, $scope.pager.startIndex);
};

$scope.limitedResultsWarning = getLimitedSearchResultsMessage(
config.get('discover:sampleSize')
);
$scope.limitedResultsWarning = getLimitedSearchResultsMessage(config.get('discover:sampleSize'));

$scope.addRows = function () {
$scope.limit += 50;
Expand Down Expand Up @@ -119,8 +116,9 @@ uiModules
calculateItemsOnPage();
};

$scope.shouldShowLimitedResultsWarning = () =>
!$scope.pager.hasNextPage && $scope.pager.totalItems < $scope.totalHitCount;
},
$scope.shouldShowLimitedResultsWarning = () => (
!$scope.pager.hasNextPage && $scope.pager.totalItems < $scope.totalHitCount
);
}
};
});
16 changes: 9 additions & 7 deletions src/legacy/ui/public/render_complete/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import { uiModules } from '../modules';
import { RenderCompleteHelper } from '../../../../plugins/kibana_utils/public';

uiModules.get('kibana').directive('renderComplete', () => ({
controller($scope, $element) {
const el = $element[0];
const renderCompleteHelper = new RenderCompleteHelper(el);
uiModules
.get('kibana')
.directive('renderComplete', () => ({
controller($scope, $element) {
const el = $element[0];
const renderCompleteHelper = new RenderCompleteHelper(el);

$scope.$on('$destroy', renderCompleteHelper.destroy);
},
}));
$scope.$on('$destroy', renderCompleteHelper.destroy);
}
}));
21 changes: 10 additions & 11 deletions src/legacy/ui/public/vislib/lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/publ

const markdownIt = new MarkdownIt({
html: false,
linkify: true,
linkify: true
});


/**
* Handles building all the components of the visualization
*
Expand All @@ -54,9 +55,7 @@ export class Handler {
this.visConfig = visConfig;
this.data = visConfig.data;

this.categoryAxes = visConfig
.get('categoryAxes')
.map(axisArgs => new Axis(visConfig, axisArgs));
this.categoryAxes = visConfig.get('categoryAxes').map(axisArgs => new Axis(visConfig, axisArgs));
this.valueAxes = visConfig.get('valueAxes').map(axisArgs => new Axis(visConfig, axisArgs));
this.chartTitle = new ChartTitle(visConfig);
this.alerts = new Alerts(this, visConfig.get('alerts'));
Expand All @@ -72,7 +71,11 @@ export class Handler {

this.layout = new Layout(visConfig);
this.binder = new Binder();
this.renderArray = _.filter([this.layout, this.chartTitle, this.alerts], Boolean);
this.renderArray = _.filter([
this.layout,
this.chartTitle,
this.alerts
], Boolean);

this.renderArray = this.renderArray
.concat(this.valueAxes)
Expand Down Expand Up @@ -190,10 +193,7 @@ export class Handler {
* child element removed
*/
removeAll(el) {
return d3
.select(el)
.selectAll('*')
.remove();
return d3.select(el).selectAll('*').remove();
}

/**
Expand All @@ -206,8 +206,7 @@ export class Handler {
error(message) {
this.removeAll(this.el);

const div = d3
.select(this.el)
const div = d3.select(this.el)
.append('div')
// class name needs `chart` in it for the polling checkSize function
// to continuously call render on resize
Expand Down
Loading