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

Split datatable renderer diff #8

Closed
wants to merge 6 commits into from
Closed
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
5 changes: 3 additions & 2 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,11 @@ of buckets to try to represent.

[horizontal]
[[visualization-visualize-chartslibrary]]`visualization:visualize:legacyChartsLibrary`::
Enables the legacy charts library for aggregation-based area, line, and bar charts in *Visualize*.
**The legacy XY charts are deprecated and will not be supported as of 7.16.**
The visualize editor uses a new XY charts library with improved performance, color palettes, fill capacity, and more. Enable this option if you prefer to use the legacy charts library.

[[visualization-visualize-pieChartslibrary]]`visualization:visualize:legacyPieChartsLibrary`::
Enables the legacy charts library for aggregation-based pie charts in *Visualize*.
The visualize editor uses new pie charts with improved performance, color palettes, label positioning, and more. Enable this option if you prefer to use to the legacy charts library.

[[visualization-colormapping]]`visualization:colorMapping`::
**This setting is deprecated and will not be supported as of 8.0.**
Expand Down
Binary file modified docs/spaces/images/edit-space-feature-visibility.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/spaces/images/edit-space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/user/dashboard/aggregation-based.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,3 @@ image:images/bar-chart-tutorial-2.png[Bar chart with sample logs data]




This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import cpy from 'cpy';
import del from 'del';
import { tap, filter } from 'rxjs/operators';
import { REPO_ROOT } from '@kbn/utils';
import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog, createReplaceSerializer } from '@kbn/dev-utils';
import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '../index';

import { allValuesFrom } from '../common';
Expand All @@ -29,6 +29,8 @@ expect.addSnapshotSerializer({
test: (value: any) => typeof value === 'string' && value.includes(REPO_ROOT),
});

expect.addSnapshotSerializer(createReplaceSerializer(/\w+-fastbuild/, '<platform>-fastbuild'));

const log = new ToolingLog({
level: 'error',
writeTo: {
Expand Down Expand Up @@ -130,7 +132,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(foo.cache.getModuleCount()).toBe(6);
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/packages/kbn-ui-shared-deps/src/public_path_module_creator.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
Expand All @@ -153,7 +155,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
<absolute path>/node_modules/@kbn/optimizer/postcss.config.js,
<absolute path>/node_modules/css-loader/package.json,
<absolute path>/node_modules/style-loader/package.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/packages/kbn-ui-shared-deps/src/public_path_module_creator.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.scss,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
Expand All @@ -173,7 +175,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {

expect(baz.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/packages/kbn-ui-shared-deps/src/public_path_module_creator.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/bazel-out/<platform>-fastbuild/bin/packages/kbn-ui-shared-deps/target/public_path_module_creator.js,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/kibana.json,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/worker/entry_point_creator.ts,
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-optimizer/src/optimizer/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class Watcher {

private readonly watchpack = new Watchpack({
aggregateTimeout: 0,
ignored: /node_modules\/([^\/]+[\/])*(?!package.json)([^\/]+)$/,
});

private readonly change$ = Rx.fromEvent<[string]>(this.watchpack, 'change').pipe(share());
Expand Down
81 changes: 27 additions & 54 deletions packages/kbn-optimizer/src/worker/populate_bundle_cache_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import Fs from 'fs';
import Path from 'path';
import { inspect } from 'util';

Expand All @@ -21,20 +22,6 @@ import {
getModulePath,
} from './webpack_helpers';

function tryToResolveRewrittenPath(from: string, toResolve: string) {
try {
return require.resolve(toResolve);
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
throw new Error(
`attempted to rewrite bazel-out path [${from}] to [${toResolve}] but couldn't find the rewrite target`
);
}

throw error;
}
}

/**
* sass-loader creates about a 40% overhead on the overall optimizer runtime, and
* so this constant is used to indicate to assignBundlesToWorkers() that there is
Expand All @@ -44,6 +31,20 @@ function tryToResolveRewrittenPath(from: string, toResolve: string) {
*/
const EXTRA_SCSS_WORK_UNITS = 100;

const isBazelPackageCache = new Map<string, boolean>();
function isBazelPackage(pkgJsonPath: string) {
const cached = isBazelPackageCache.get(pkgJsonPath);
if (typeof cached === 'boolean') {
return cached;
}

const path = parseFilePath(Fs.realpathSync(pkgJsonPath, 'utf-8'));
const match = !!path.matchDirs('bazel-out', /-fastbuild$/, 'bin', 'packages');
isBazelPackageCache.set(pkgJsonPath, match);

return match;
}

export class PopulateBundleCachePlugin {
constructor(private readonly workerConfig: WorkerConfig, private readonly bundle: Bundle) {}

Expand Down Expand Up @@ -71,44 +72,16 @@ export class PopulateBundleCachePlugin {
let path = getModulePath(module);
let parsedPath = parseFilePath(path);

const bazelOut = parsedPath.matchDirs(
'bazel-out',
/-fastbuild$/,
'bin',
'packages',
/.*/,
'target'
);

// if the module is referenced from one of our packages and resolved to the `bazel-out` dir
// we should rewrite our reference to point to the source file so that we can track the
// modified time of that file rather than the built output which is rebuilt all the time
// without actually changing
if (bazelOut) {
const packageDir = parsedPath.dirs[bazelOut.endIndex - 1];
const subDirs = parsedPath.dirs.slice(bazelOut.endIndex + 1);
path = tryToResolveRewrittenPath(
path,
Path.join(
workerConfig.repoRoot,
'packages',
packageDir,
'src',
...subDirs,
parsedPath.filename
? Path.basename(parsedPath.filename, Path.extname(parsedPath.filename))
: ''
)
const bazelOutIndex = parsedPath.dirs.indexOf('bazel-out');
if (bazelOutIndex >= 0) {
path = Path.resolve(
this.workerConfig.repoRoot,
...parsedPath.dirs.slice(bazelOutIndex),
parsedPath.filename ?? ''
);
parsedPath = parseFilePath(path);
}

if (parsedPath.matchDirs('bazel-out')) {
throw new Error(
`a bazel-out dir is being referenced by module [${path}] and not getting rewritten to its source location`
);
}

if (!parsedPath.dirs.includes('node_modules')) {
referencedFiles.add(path);

Expand All @@ -125,13 +98,13 @@ export class PopulateBundleCachePlugin {

const nmIndex = parsedPath.dirs.lastIndexOf('node_modules');
const isScoped = parsedPath.dirs[nmIndex + 1].startsWith('@');
referencedFiles.add(
Path.join(
parsedPath.root,
...parsedPath.dirs.slice(0, nmIndex + 1 + (isScoped ? 2 : 1)),
'package.json'
)
const pkgJsonPath = Path.join(
parsedPath.root,
...parsedPath.dirs.slice(0, nmIndex + 1 + (isScoped ? 2 : 1)),
'package.json'
);

referencedFiles.add(isBazelPackage(pkgJsonPath) ? path : pkgJsonPath);
continue;
}

Expand Down
6 changes: 1 addition & 5 deletions src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ export const IGNORE_FILE_GLOBS = [
*
* @type {Array}
*/
export const KEBAB_CASE_DIRECTORY_GLOBS = [
'packages/*',
'x-pack',
'packages/kbn-optimizer/src/__fixtures__/mock_repo/packages/kbn-ui-shared-deps',
];
export const KEBAB_CASE_DIRECTORY_GLOBS = ['packages/*', 'x-pack'];

/**
* These patterns are matched against directories and indicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IRouter } from 'kibana/server';
import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { getRequestAbortedSignal } from '../lib';
import { getKbnServerError } from '../../../kibana_utils/server';
import { getKbnServerError, reportServerError } from '../../../kibana_utils/server';
import type { ConfigSchema } from '../../config';
import { termsEnumSuggestions } from './terms_enum';
import { termsAggSuggestions } from './terms_agg';
Expand Down Expand Up @@ -65,7 +65,8 @@ export function registerValueSuggestionsRoute(router: IRouter, config$: Observab
);
return response.ok({ body });
} catch (e) {
throw getKbnServerError(e);
const kbnErr = getKbnServerError(e);
return reportServerError(response, kbnErr);
}
}
);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kibana_utils/server/report_server_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class KbnServerError extends KbnError {
* @returns `KbnServerError`
*/
export function getKbnServerError(e: Error) {
if (e instanceof KbnServerError) return e;
return new KbnServerError(
e.message ?? 'Unknown error',
e instanceof ResponseError ? e.statusCode : 500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const FilterRatioAgg = (props) => {
query={model.numerator}
onChange={handleNumeratorQueryChange}
indexPatterns={[indexPattern]}
data-test-subj="filterRatioNumeratorInput"
/>
</EuiFormRow>
</EuiFlexItem>
Expand All @@ -124,6 +125,7 @@ export const FilterRatioAgg = (props) => {
query={model.denominator}
onChange={handleDenominatorQueryChange}
indexPatterns={[indexPattern]}
data-test-subj="filterRatioDenominatorInput"
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export const IndexPattern = ({
content={
<FormattedMessage
id="visTypeTimeseries.indexPattern.detailLevelHelpText"
defaultMessage="Controls the auto interval based on the time range. The default interval is affected by the advanced settings {histogramTargetBars} and {histogramMaxBars}."
defaultMessage="Controls the auto and gte intervals based on the time range. The default interval is affected by the advanced settings {histogramTargetBars} and {histogramMaxBars}."
values={{
histogramTargetBars: UI_SETTINGS.HISTOGRAM_MAX_BARS,
histogramMaxBars: UI_SETTINGS.HISTOGRAM_BAR_TARGET,
Expand Down Expand Up @@ -352,7 +352,7 @@ export const IndexPattern = ({
disabled={
disabled ||
isEntireTimeRangeActive(model, isTimeSeries) ||
!(model[intervalName] === AUTO_INTERVAL || !model[intervalName])
!(isAutoInterval(model[intervalName]) || isGteInterval(model[intervalName]))
}
min={0}
max={maxBarsUiSettings}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import { fetchIndexPattern, isStringTypeIndexPattern } from '../../../common/ind

type QueryBarWrapperProps = Pick<QueryStringInputProps, 'query' | 'onChange'> & {
indexPatterns: IndexPatternValue[];
'data-test-subj'?: string;
};

export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrapperProps) {
export function QueryBarWrapper({
query,
onChange,
indexPatterns,
'data-test-subj': dataTestSubj,
}: QueryBarWrapperProps) {
const { indexPatterns: indexPatternsService } = getDataStart();
const [indexes, setIndexes] = useState<QueryStringInputProps['indexPatterns']>([]);

Expand Down Expand Up @@ -58,6 +64,7 @@ export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrap
onChange={onChange}
indexPatterns={indexes}
{...coreStartContext}
dataTestSubj={dataTestSubj}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('getBucketSize', () => {
body: {
timerange: {
min: '2017-01-01T00:00:00.000Z',
max: '2017-01-01T01:00:00.000Z',
max: '2017-07-01T01:00:00.000Z',
},
},
} as VisTypeTimeseriesVisDataRequest;
Expand All @@ -29,9 +29,10 @@ describe('getBucketSize', () => {

test('returns auto calculated buckets', () => {
const result = getBucketSize(req, 'auto', capabilities, 100);
const expectedValue = 86400; // 24h

expect(result).toHaveProperty('bucketSize', 30);
expect(result).toHaveProperty('intervalString', '30s');
expect(result).toHaveProperty('bucketSize', expectedValue);
expect(result).toHaveProperty('intervalString', `${expectedValue}s`);
});

test('returns overridden buckets (1s)', () => {
Expand All @@ -56,16 +57,23 @@ describe('getBucketSize', () => {
});

test('returns overridden buckets (>=2d)', () => {
const result = getBucketSize(req, '>=2d', capabilities, 100);
const result = getBucketSize(req, '>=2d', capabilities, 1000);

expect(result).toHaveProperty('bucketSize', 86400 * 2);
expect(result).toHaveProperty('intervalString', '2d');
});

test('returns overridden buckets (>=10s)', () => {
const result = getBucketSize(req, '>=10s', capabilities, 100);
test('returns overridden buckets (>=5d)', () => {
const result = getBucketSize(req, '>=5d', capabilities, 100);

expect(result).toHaveProperty('bucketSize', 30);
expect(result).toHaveProperty('intervalString', '30s');
expect(result).toHaveProperty('bucketSize', 432000);
expect(result).toHaveProperty('intervalString', '5d');
});

test('returns overridden buckets for 1 bar and >=1d interval', () => {
const result = getBucketSize(req, '>=1d', capabilities, 1);

expect(result).toHaveProperty('bucketSize', 2592000);
expect(result).toHaveProperty('intervalString', '2592000s');
});
});
Loading