Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into nls/header-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed May 28, 2021
2 parents e558be1 + b575a45 commit fb86497
Show file tree
Hide file tree
Showing 125 changed files with 7,244 additions and 3,034 deletions.
1 change: 1 addition & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ yarn kbn watch-bazel
- @kbn/eslint-plugin-eslint
- @kbn/expect
- @kbn/i18n
- @kbn/io-ts-utils
- @kbn/legacy-logging
- @kbn/logging
- @kbn/mapbox-gl
Expand Down
9 changes: 0 additions & 9 deletions docs/user/alerting/rule-management.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ These operations can also be performed in bulk by multi-selecting rules and clic
[role="screenshot"]
image:images/bulk-mute-disable.png[The Manage rules button lets you mute/unmute, enable/disable, and delete in bulk]

[float]
[[importing-and-exporting-rules]]
=== Importing and exporting rules

To import and export rules, use the <<managing-saved-objects, Saved Objects Management UI>>.
After the succesful import the proper banner will be displayed:
[role="screenshot"]
image::images/rules-imported-banner.png[Rules import banner, width=50%]

[float]
=== Required permissions

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module",
"@kbn/i18n": "link:bazel-bin/packages/kbn-i18n/npm_module",
"@kbn/interpreter": "link:packages/kbn-interpreter",
"@kbn/io-ts-utils": "link:packages/kbn-io-ts-utils",
"@kbn/io-ts-utils": "link:bazel-bin/packages/kbn-io-ts-utils/npm_module",
"@kbn/legacy-logging": "link:bazel-bin/packages/kbn-legacy-logging/npm_module",
"@kbn/logging": "link:bazel-bin/packages/kbn-logging/npm_module",
"@kbn/monaco": "link:bazel-bin/packages/kbn-monaco/npm_module",
Expand Down Expand Up @@ -161,6 +161,7 @@
"@mapbox/mapbox-gl-draw": "1.3.0",
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
"@mapbox/vector-tile": "1.3.1",
"@reduxjs/toolkit": "^1.5.1",
"@scant/router": "^0.1.1",
"@slack/webhook": "^5.0.4",
"@turf/along": "6.0.1",
Expand All @@ -173,6 +174,7 @@
"@turf/distance": "6.0.1",
"@turf/helpers": "6.0.1",
"@turf/length": "^6.0.2",
"@types/redux-logger": "^3.0.8",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.4.0",
Expand Down Expand Up @@ -365,6 +367,7 @@
"redux": "^4.0.5",
"redux-actions": "^2.6.5",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"redux-observable": "^1.2.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ filegroup(
"//packages/kbn-eslint-plugin-eslint:build",
"//packages/kbn-expect:build",
"//packages/kbn-i18n:build",
"//packages/kbn-io-ts-utils:build",
"//packages/kbn-legacy-logging:build",
"//packages/kbn-logging:build",
"//packages/kbn-mapbox-gl:build",
Expand Down
85 changes: 85 additions & 0 deletions packages/kbn-io-ts-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")

PKG_BASE_NAME = "kbn-io-ts-utils"
PKG_REQUIRE_NAME = "@kbn/io-ts-utils"

SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*"
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

SRC_DEPS = [
"@npm//fp-ts",
"@npm//io-ts",
"@npm//lodash",
"@npm//tslib",
]

TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)

ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
7 changes: 1 addition & 6 deletions packages/kbn-io-ts-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@
"types": "./target/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true,
"scripts": {
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
}
"private": true
}
2 changes: 1 addition & 1 deletion packages/kbn-io-ts-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"incremental": true,
"outDir": "./target",
"stripInternal": false,
"declaration": true,
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-server-route-repository/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},
"dependencies": {
"@kbn/io-ts-utils": "link:../kbn-io-ts-utils"
}
}
25 changes: 24 additions & 1 deletion src/plugins/charts/common/palette.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import {
systemPalette,
PaletteOutput,
CustomPaletteState,
CustomPaletteArguments,
} from './palette';
import { functionWrapper } from 'src/plugins/expressions/common/expression_functions/specs/tests/utils';

describe('palette', () => {
const fn = functionWrapper(palette()) as (
context: null,
args?: { color?: string[]; gradient?: boolean; reverse?: boolean }
args?: Partial<CustomPaletteArguments>
) => PaletteOutput<CustomPaletteState>;

it('results a palette', () => {
Expand All @@ -39,6 +40,18 @@ describe('palette', () => {
});
});

describe('stop', () => {
it('sets stops', () => {
const result = fn(null, { color: ['red', 'green', 'blue'], stop: [1, 2, 3] });
expect(result.params!.stops).toEqual([1, 2, 3]);
});

it('defaults to pault_tor_14 colors', () => {
const result = fn(null);
expect(result.params!.colors).toEqual(defaultCustomColors);
});
});

describe('gradient', () => {
it('sets gradient', () => {
let result = fn(null, { gradient: true });
Expand Down Expand Up @@ -69,6 +82,16 @@ describe('palette', () => {
const result = fn(null);
expect(result.params!.colors).toEqual(defaultCustomColors);
});

it('keeps the stops order pristine when set', () => {
const stops = [1, 2, 3];
const result = fn(null, {
color: ['red', 'green', 'blue'],
stop: [1, 2, 3],
reverse: true,
});
expect(result.params!.stops).toEqual(stops);
});
});
});
});
Expand Down
60 changes: 58 additions & 2 deletions src/plugins/charts/common/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ export interface CustomPaletteArguments {
color?: string[];
gradient: boolean;
reverse?: boolean;
stop?: number[];
range?: 'number' | 'percent';
rangeMin?: number;
rangeMax?: number;
continuity?: 'above' | 'below' | 'all' | 'none';
}

export interface CustomPaletteState {
colors: string[];
gradient: boolean;
stops: number[];
range: 'number' | 'percent';
rangeMin: number;
rangeMax: number;
continuity?: 'above' | 'below' | 'all' | 'none';
}

export interface SystemPaletteArguments {
Expand Down Expand Up @@ -83,6 +93,35 @@ export function palette(): ExpressionFunctionDefinition<
}),
required: false,
},
stop: {
multi: true,
types: ['number'],
help: i18n.translate('charts.functions.palette.args.stopHelpText', {
defaultMessage:
'The palette color stops. When used, it must be associated with each color.',
}),
required: false,
},
continuity: {
types: ['string'],
options: ['above', 'below', 'all', 'none'],
default: 'above',
help: '',
},
rangeMin: {
types: ['number'],
help: '',
},
rangeMax: {
types: ['number'],
help: '',
},
range: {
types: ['string'],
options: ['number', 'percent'],
default: 'percent',
help: '',
},
gradient: {
types: ['boolean'],
default: false,
Expand All @@ -101,15 +140,32 @@ export function palette(): ExpressionFunctionDefinition<
},
},
fn: (input, args) => {
const { color, reverse, gradient } = args;
const {
color,
continuity,
reverse,
gradient,
stop,
range,
rangeMin = 0,
rangeMax = 100,
} = args;
const colors = ([] as string[]).concat(color || defaultCustomColors);

const stops = ([] as number[]).concat(stop || []);
if (stops.length > 0 && colors.length !== stops.length) {
throw Error('When stop is used, each color must have an associated stop value.');
}
return {
type: 'palette',
name: 'custom',
params: {
colors: reverse ? colors.reverse() : colors,
stops,
range: range ?? 'percent',
gradient,
continuity,
rangeMin,
rangeMax,
},
};
},
Expand Down
Loading

0 comments on commit fb86497

Please sign in to comment.