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

[7.x] De-angularize DocViewer table layout (#43240) #44065

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,28 @@ const partialFormattedCache = new WeakMap();
// Takes a hit, merges it with any stored/scripted fields, and with the metaFields
// returns a formatted version
export function formatHitProvider(indexPattern: IndexPattern, defaultFormat: any) {
function convert(hit: Record<string, any>, val: any, fieldName: string) {
function convert(hit: Record<string, any>, val: any, fieldName: string, type: string = 'html') {
const field = indexPattern.fields.byName[fieldName];
if (!field) return defaultFormat.convert(val, 'html');
if (!field) return defaultFormat.convert(val, type);
const parsedUrl = {
origin: window.location.origin,
pathname: window.location.pathname,
};
return field.format.getConverterFor('html')(val, field, hit, parsedUrl);
return field.format.getConverterFor(type)(val, field, hit, parsedUrl);
}

function formatHit(hit: Record<string, any>) {
function formatHit(hit: Record<string, any>, type: string = 'html') {
if (type === 'text') {
// formatHit of type text is for react components to get rid of <span ng-non-bindable>
// since it's currently just used at the discover's doc view table, caching is not necessary
const flattened = indexPattern.flattenHit(hit);
const result: Record<string, any> = {};
for (const [key, value] of Object.entries(flattened)) {
result[key] = convert(hit, value, key, type);
}
return result;
}

const cached = formattedCache.get(hit);
if (cached) {
return cached;
Expand Down
102 changes: 0 additions & 102 deletions src/legacy/core_plugins/kbn_doc_views/public/views/table.html

This file was deleted.

77 changes: 0 additions & 77 deletions src/legacy/core_plugins/kbn_doc_views/public/views/table.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
* under the License.
*/

import { uiModules } from 'ui/modules';
const module = uiModules.get('apps/doc_views');
import _ from 'lodash';
import { addDocView } from 'ui/registry/doc_views';
import { i18n } from '@kbn/i18n';
import { DocViewTable } from './table/table';

// Simple filter to allow using ng-bind-html without explicitly calling $sce.trustAsHtml in a controller
// (See http://goo.gl/mpj9o2)
module.filter('trustAsHtml', function ($sce) {
return $sce.trustAsHtml;
addDocView({
title: i18n.translate('kbnDocViews.table.tableTitle', {
defaultMessage: 'Table',
}),
order: 10,
component: DocViewTable,
});
Loading