Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-54252
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Jan 9, 2020
2 parents 390254d + 7479e2b commit 4f7225b
Show file tree
Hide file tree
Showing 210 changed files with 3,166 additions and 2,801 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'off',
},
},

/**
* Files that require Apache 2.0 headers, settings
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 35 additions & 30 deletions docs/spaces/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
[[xpack-spaces]]
== Spaces

Spaces enable you to organize your dashboards and other saved
objects into meaningful categories. Once inside a space, you see only
the dashboards and saved objects that belong to that space.
Spaces enable you to organize your dashboards and other saved
objects into meaningful categories. Once inside a space, you see only
the dashboards and saved objects that belong to that space.

{kib} creates a default space for you.
After you create your own
spaces, you're asked to choose a space when you log in to Kibana. You can change your
{kib} creates a default space for you.
After you create your own
spaces, you're asked to choose a space when you log in to Kibana. You can change your
current space at any time by using the menu in the upper left.

[role="screenshot"]
Expand All @@ -29,24 +29,24 @@ Kibana supports spaces in several ways. You can:
[[spaces-managing]]
=== View, create, and delete spaces

Go to **Management > Spaces** for an overview of your spaces. This view provides actions
Go to **Management > Spaces** for an overview of your spaces. This view provides actions
for you to create, edit, and delete spaces.

[role="screenshot"]
image::spaces/images/space-management.png["Space management"]

[float]
==== Create or edit a space
==== Create or edit a space

You can create as many spaces as you like. Click *Create a space* and provide a name,
URL identifier, optional description.
You can create as many spaces as you like. Click *Create a space* and provide a name,
URL identifier, optional description.

The URL identifier is a short text string that becomes part of the
{kib} URL when you are inside that space. {kib} suggests a URL identifier based
The URL identifier is a short text string that becomes part of the
{kib} URL when you are inside that space. {kib} suggests a URL identifier based
on the name of your space, but you can customize the identifier to your liking.
You cannot change the space identifier once you create the space.

{kib} also has an <<spaces-api, API>>
{kib} also has an <<spaces-api, API>>
if you prefer to create spaces programatically.

[role="screenshot"]
Expand All @@ -55,22 +55,22 @@ image::spaces/images/edit-space.png["Space management"]
[float]
==== Delete a space

Deleting a space permanently removes the space and all of its contents.
Deleting a space permanently removes the space and all of its contents.
Find the space on the *Spaces* overview page and click the trash icon in the Actions column.
You can't delete the default space, but you can customize it to your liking.

[float]
[[spaces-control-feature-visibility]]
=== Control feature access based on user needs

You have control over which features are visible in each space.
For example, you might hide Dev Tools
You have control over which features are visible in each space.
For example, you might hide Dev Tools
in your "Executive" space or show Stack Monitoring only in your "Admin" space.
You can define which features to show or hide when you add or edit a space.

Controlling feature
visibility is not a security feature. To secure access
to specific features on a per-user basis, you must configure
Controlling feature
visibility is not a security feature. To secure access
to specific features on a per-user basis, you must configure
<<xpack-security-authorization, Kibana Security>>.

[role="screenshot"]
Expand All @@ -80,10 +80,10 @@ image::spaces/images/edit-space-feature-visibility.png["Controlling features vis
[[spaces-control-user-access]]
=== Control feature access based on user privileges

When using Kibana with security, you can configure applications and features
based on your users’ privileges. This means different roles can have access
to different features in the same space.
Power users might have privileges to create and edit visualizations and dashboards,
When using Kibana with security, you can configure applications and features
based on your users’ privileges. This means different roles can have access
to different features in the same space.
Power users might have privileges to create and edit visualizations and dashboards,
while analysts or executives might have Dashboard and Canvas with read-only privileges.
See <<adding_kibana_privileges>> for details.

Expand All @@ -106,7 +106,7 @@ interface.
. Import your saved objects.
. (Optional) Delete objects in the export space that you no longer need.

{kib} also has beta <<saved-objects-api-import, import>> and
{kib} also has beta <<saved-objects-api-import, import>> and
<<saved-objects-api-export, export>> APIs if you want to automate this process.

[float]
Expand All @@ -115,17 +115,22 @@ interface.

You can create a custom experience for users by configuring the {kib} landing page on a per-space basis.
The landing page can route users to a specific dashboard, application, or saved object as they enter each space.
To configure the landing page, use the `defaultRoute` setting in <<kibana-general-settings, Management > Advanced settings>>.

To configure the landing page, use the default route setting in <<kibana-general-settings, Management > Advanced settings>>.
For example, you might set the default route to `/app/kibana#/dashboards`.

[role="screenshot"]
image::spaces/images/spaces-configure-landing-page.png["Configure space-level landing page"]


[float]
[[spaces-delete-started]]
=== Disable and version updates

Spaces are automatically enabled in {kib}. If you don't want use this feature,
Spaces are automatically enabled in {kib}. If you don't want use this feature,
you can disable it
by setting `xpack.spaces.enabled` to `false` in your
by setting `xpack.spaces.enabled` to `false` in your
`kibana.yml` configuration file.

If you are upgrading your
version of {kib}, the default space will contain all of your existing saved objects.

If you are upgrading your
version of {kib}, the default space will contain all of your existing saved objects.
7 changes: 5 additions & 2 deletions packages/kbn-config-schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ __Usage:__
const valueSchema = schema.boolean({ defaultValue: false });
```

__Notes:__
* The `schema.boolean()` also supports a string as input if it equals `'true'` or `'false'` (case-insensitive).

#### `schema.literal()`

Validates input data as a [string](https://www.typescriptlang.org/docs/handbook/advanced-types.html#string-literal-types), [numeric](https://www.typescriptlang.org/docs/handbook/advanced-types.html#numeric-literal-types) or boolean literal.
Expand Down Expand Up @@ -397,7 +400,7 @@ const valueSchema = schema.byteSize({ min: '3kb' });
```

__Notes:__
* The string value for `schema.byteSize()` and its options supports the following prefixes: `b`, `kb`, `mb`, `gb` and `tb`.
* The string value for `schema.byteSize()` and its options supports the following optional suffixes: `b`, `kb`, `mb`, `gb` and `tb`. The default suffix is `b`.
* The number value is treated as a number of bytes and hence should be a positive integer, e.g. `100` is equal to `'100b'`.
* Currently you cannot specify zero bytes with a string format and should use number `0` instead.

Expand All @@ -417,7 +420,7 @@ const valueSchema = schema.duration({ defaultValue: '70ms' });
```

__Notes:__
* The string value for `schema.duration()` supports the following prefixes: `ms`, `s`, `m`, `h`, `d`, `w`, `M` and `Y`.
* The string value for `schema.duration()` supports the following optional suffixes: `ms`, `s`, `m`, `h`, `d`, `w`, `M` and `Y`. The default suffix is `ms`.
* The number value is treated as a number of milliseconds and hence should be a positive integer, e.g. `100` is equal to `'100ms'`.

#### `schema.conditional()`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/kbn-config-schema/src/byte_size_value/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import { ByteSizeValue } from '.';

describe('parsing units', () => {
test('number string (bytes)', () => {
expect(ByteSizeValue.parse('123').getValueInBytes()).toBe(123);
});

test('bytes', () => {
expect(ByteSizeValue.parse('123b').getValueInBytes()).toBe(123);
});
Expand All @@ -37,12 +41,8 @@ describe('parsing units', () => {
expect(ByteSizeValue.parse('1gb').getValueInBytes()).toBe(1073741824);
});

test('throws an error when no unit specified', () => {
expect(() => ByteSizeValue.parse('123')).toThrowError('could not parse byte size value');
});

test('throws an error when unsupported unit specified', () => {
expect(() => ByteSizeValue.parse('1tb')).toThrowError('could not parse byte size value');
expect(() => ByteSizeValue.parse('1tb')).toThrowErrorMatchingSnapshot();
});
});

Expand Down
14 changes: 9 additions & 5 deletions packages/kbn-config-schema/src/byte_size_value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ export class ByteSizeValue {
public static parse(text: string): ByteSizeValue {
const match = /([1-9][0-9]*)(b|kb|mb|gb)/.exec(text);
if (!match) {
throw new Error(
`could not parse byte size value [${text}]. Value must be a safe positive integer.`
);
const number = Number(text);
if (typeof number !== 'number' || isNaN(number)) {
throw new Error(
`Failed to parse [${text}] as byte value. Value must be either number of bytes, or follow the format <count>[b|kb|mb|gb] ` +
`(e.g., '1024kb', '200mb', '1gb'), where the number is a safe positive integer.`
);
}
return new ByteSizeValue(number);
}

const value = parseInt(match[1], 0);
Expand All @@ -49,8 +54,7 @@ export class ByteSizeValue {
constructor(private readonly valueInBytes: number) {
if (!Number.isSafeInteger(valueInBytes) || valueInBytes < 0) {
throw new Error(
`Value in bytes is expected to be a safe positive integer, ` +
`but provided [${valueInBytes}]`
`Value in bytes is expected to be a safe positive integer, but provided [${valueInBytes}].`
);
}
}
Expand Down
15 changes: 9 additions & 6 deletions packages/kbn-config-schema/src/duration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ const timeFormatRegex = /^(0|[1-9][0-9]*)(ms|s|m|h|d|w|M|Y)$/;
function stringToDuration(text: string) {
const result = timeFormatRegex.exec(text);
if (!result) {
throw new Error(
`Failed to parse [${text}] as time value. ` +
`Format must be <count>[ms|s|m|h|d|w|M|Y] (e.g. '70ms', '5s', '3d', '1Y')`
);
const number = Number(text);
if (typeof number !== 'number' || isNaN(number)) {
throw new Error(
`Failed to parse [${text}] as time value. Value must be a duration in milliseconds, or follow the format ` +
`<count>[ms|s|m|h|d|w|M|Y] (e.g. '70ms', '5s', '3d', '1Y'), where the duration is a safe positive integer.`
);
}
return numberToDuration(number);
}

const count = parseInt(result[1], 0);
Expand All @@ -40,8 +44,7 @@ function stringToDuration(text: string) {
function numberToDuration(numberMs: number) {
if (!Number.isSafeInteger(numberMs) || numberMs < 0) {
throw new Error(
`Failed to parse [${numberMs}] as time value. ` +
`Value should be a safe positive integer number.`
`Value in milliseconds is expected to be a safe positive integer, but provided [${numberMs}].`
);
}

Expand Down
18 changes: 17 additions & 1 deletion packages/kbn-config-schema/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,23 @@ export const internals = Joi.extend([
base: Joi.boolean(),
coerce(value: any, state: State, options: ValidationOptions) {
// If value isn't defined, let Joi handle default value if it's defined.
if (value !== undefined && typeof value !== 'boolean') {
if (value === undefined) {
return value;
}

// Allow strings 'true' and 'false' to be coerced to booleans (case-insensitive).

// From Joi docs on `Joi.boolean`:
// > Generates a schema object that matches a boolean data type. Can also
// > be called via bool(). If the validation convert option is on
// > (enabled by default), a string (either "true" or "false") will be
// converted to a boolean if specified.
if (typeof value === 'string') {
const normalized = value.toLowerCase();
value = normalized === 'true' ? true : normalized === 'false' ? false : value;
}

if (typeof value !== 'boolean') {
return this.createError('boolean.base', { value }, state, options);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4f7225b

Please sign in to comment.