Skip to content

Commit

Permalink
New platform cleanup filters (#34555)
Browse files Browse the repository at this point in the history
* Delete label filter
* Delete risonDecode
* Deleted rison
* removed fieldType filter
* Deleted field type tests
* Replaced uriescape filter with use of encodeURIComponent
* Delete short dots filter
* Removed usages of moment filter (and moved it to watcher)
* Code review changes
  • Loading branch information
lizozom authored Apr 15, 2019
1 parent ed5ba0e commit 71d9c5a
Show file tree
Hide file tree
Showing 32 changed files with 62 additions and 635 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import _ from 'lodash';
import React from 'react';
import angular from 'angular';
import moment from 'moment';
import chrome from 'ui/chrome';
import dateMath from '@elastic/datemath';

Expand All @@ -32,7 +33,6 @@ import * as filterActions from '../doc_table/actions/filter';
import 'ui/listen';
import 'ui/visualize';
import 'ui/fixed_scroll';
import 'ui/filters/moment';
import 'ui/index_patterns';
import 'ui/state_management/app_state';
import { timefilter } from 'ui/timefilter';
Expand Down Expand Up @@ -792,6 +792,10 @@ function discoverController(
$scope.time = timefilter.getTime();
};

$scope.toMoment = function (datetime) {
return moment(datetime).format(config.get('dateFormat'));
};

$scope.updateRefreshInterval = function () {
$scope.refreshInterval = timefilter.getRefreshInterval();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<span
data-test-subj="docTableHeader-{{name}}"
>
{{name | shortDots}}
{{getShortDotsName(name)}}
<button
data-test-subj="docTableHeaderFieldSort_{{name}}"
id="docTableHeaderFieldSort{{name}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

import _ from 'lodash';
import 'ui/filters/short_dots';
import { shortenDottedString } from '../../../../common/utils/shorten_dotted_string';
import headerHtml from './table_header.html';
import { uiModules } from 'ui/modules';
const module = uiModules.get('app/discover');


module.directive('kbnTableHeader', function (shortDotsFilter, i18n) {
module.directive('kbnTableHeader', function (i18n) {
return {
restrict: 'A',
scope: {
Expand All @@ -38,6 +38,11 @@ module.directive('kbnTableHeader', function (shortDotsFilter, i18n) {
template: headerHtml,
controller: function ($scope, config) {
$scope.hideTimeColumn = config.get('doc_table:hideTimeColumn');
$scope.isShortDots = config.get('shortDots:enable');

$scope.getShortDotsName = function getShortDotsName(columnName) {
return $scope.isShortDots ? shortenDottedString(columnName) : columnName;
};

$scope.isSortableColumn = function isSortableColumn(columnName) {
return (
Expand All @@ -49,9 +54,10 @@ module.directive('kbnTableHeader', function (shortDotsFilter, i18n) {

$scope.tooltip = function (column) {
if (!$scope.isSortableColumn(column)) return '';
const name = $scope.isShortDots ? shortenDottedString(column) : column;
return i18n('kbn.docTable.tableHeader.sortByColumnTooltip', {
defaultMessage: 'Sort by {columnName}',
values: { columnName: shortDotsFilter(column) },
values: { columnName: name },
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import _ from 'lodash';
import $ from 'jquery';
import rison from 'rison-node';
import 'plugins/kibana/doc_viewer';
import 'ui/filters/uriescape';
import 'ui/filters/short_dots';
import { noWhiteSpace } from '../../../../common/utils/no_white_space';
import openRowHtml from './table_row/open.html';
import detailsHtml from './table_row/details.html';
Expand Down Expand Up @@ -95,6 +93,7 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl
$detailsTr.html(detailsHtml);

$detailsScope.row = $scope.row;
$detailsScope.uriEncodedId = encodeURIComponent($detailsScope.row._id);

$compile($detailsTr)($detailsScope);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<a
class="euiLink"
data-test-subj="docTableRowAction"
ng-href="#/doc/{{indexPattern.id}}/{{row._index}}/{{row._type}}/?id={{row._id | uriescape}}"
ng-href="#/doc/{{indexPattern.id}}/{{row._index}}/{{row._type}}/?id={{uriEncodedId}}"
i18n-id="kbn.docTable.tableRow.viewSingleDocumentLinkText"
i18n-default-message="View single document"
></a>
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h1 tabindex="0" id="kui_local_breadcrumb" class="kuiLocalBreadcrumb" ng-if="opt
<span
tooltip="{{::'kbn.discover.howToChangeTheTimeTooltip' | i18n: {defaultMessage: 'To change the time, click the clock icon in the navigation bar'} }}"
>
{{timeRange.from | moment}} - {{timeRange.to | moment}}
{{toMoment(timeRange.from)}} - {{toMoment(timeRange.to)}}
</span>

&mdash;
Expand Down
1 change: 0 additions & 1 deletion src/legacy/ui/public/agg_types/agg_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import '../filters/label';
import { IndexedArray } from '../indexed_array';
import { FieldParamType } from './param_types/field';
import { OptionedParamType } from './param_types/optioned';
Expand Down
1 change: 0 additions & 1 deletion src/legacy/ui/public/agg_types/buckets/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import _ from 'lodash';
import chrome from '../../chrome';
import moment from 'moment-timezone';
import '../../filters/field_type';
import '../directives/validate_date_interval';
import { BucketAggType } from './_bucket_agg_type';
import { TimeBuckets } from '../../time_buckets';
Expand Down
1 change: 0 additions & 1 deletion src/legacy/ui/public/agg_types/param_types/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { FieldParamEditor } from '../controls/field';
import '../directives/scroll_bottom';
import { BaseParamType } from './base';
import '../filters/sort_prefix_first';
import '../../filters/field_type';
import { IndexedArray } from '../../indexed_array';
import { toastNotifications } from '../../notify';
import { createLegacyClass } from '../../utils/legacy_class';
Expand Down
8 changes: 5 additions & 3 deletions src/legacy/ui/public/directives/field_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import $ from 'jquery';
import { template } from 'lodash';
import '../filters/short_dots';
import { shortenDottedString } from '../../../core_plugins/kibana/common/utils/shorten_dotted_string';
import booleanFieldNameIcon from './field_name_icons/boolean_field_name_icon.html';
import conflictFieldNameIcon from './field_name_icons/conflict_field_name_icon.html';
import dateFieldNameIcon from './field_name_icons/date_field_name_icon.html';
Expand All @@ -45,7 +45,7 @@ const compiledSourceFieldNameIcon = template(sourceFieldNameIcon);
const compiledStringFieldNameIcon = template(stringFieldNameIcon);
const compiledUnknownFieldNameIcon = template(unknownFieldNameIcon);

module.directive('fieldName', function ($compile, $rootScope, $filter, i18n) {
module.directive('fieldName', function ($compile, $rootScope, config, i18n) {
return {
restrict: 'AE',
scope: {
Expand Down Expand Up @@ -126,7 +126,9 @@ module.directive('fieldName', function ($compile, $rootScope, $filter, i18n) {
const results = $scope.field ? !$scope.field.rowCount && !$scope.field.scripted : false;
const scripted = $scope.field ? $scope.field.scripted : false;

const displayName = $filter('shortDots')(name);

const isShortDots = config.get('shortDots:enable');
const displayName = isShortDots ? shortenDottedString(name) : name;

$el
.attr('title', name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
input-focus
disable-input-focus="disableAutoFocus"
ng-model="filter"
ng-attr-placeholder="{{ finder.properties.nouns | label }} Filter..."
ng-attr-placeholder="{{ finder.getLabel() }} Filter..."
ng-keydown="finder.filterKeyDown($event)"
name="filter"
type="text"
Expand Down
6 changes: 5 additions & 1 deletion src/legacy/ui/public/directives/saved_object_finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import rison from 'rison-node';
import { keyMap } from '../utils/key_map';
import { SavedObjectRegistryProvider } from '../saved_objects/saved_object_registry';
import { uiModules } from '../modules';
import '../filters/label';

import savedObjectFinderTemplate from './partials/saved_object_finder.html';
import './input_focus';
import './paginate';
Expand Down Expand Up @@ -158,6 +158,10 @@ module.directive('savedObjectFinder', function ($location, kbnUrl, Private, conf
index: -1
};

self.getLabel = function () {
return _.words(self.properties.nouns).map(_.capitalize).join(' ');
};

//key handler for the filter text box
self.filterKeyDown = function ($event) {
switch (keyMap[$event.keyCode]) {
Expand Down
83 changes: 0 additions & 83 deletions src/legacy/ui/public/filters/__tests__/field_type.js

This file was deleted.

54 changes: 0 additions & 54 deletions src/legacy/ui/public/filters/__tests__/label.js

This file was deleted.

Loading

0 comments on commit 71d9c5a

Please sign in to comment.