From 67401cea92bedfddb82c049d7746ed53f31ad9c8 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Wed, 15 Aug 2018 06:46:35 -0600 Subject: [PATCH] Eui 3.6.0 (#21968) * bump EUI to 3.6.0 * replace CopyButton with EuiCopy * remove snapshot file from deleted CopyButton component --- package.json | 2 +- .../__snapshots__/copy_button.test.js.snap | 20 ----- .../home/components/tutorial/copy_button.js | 75 ------------------- .../components/tutorial/copy_button.test.js | 32 -------- .../home/components/tutorial/instruction.js | 16 +++- .../kibana/public/home/copy_to_clipboard.js | 66 ---------------- x-pack/package.json | 2 +- .../actions_section.test.js.snap | 6 ++ .../rule_editor_flyout.test.js.snap | 3 + .../scope_expression.test.js.snap | 4 + .../__snapshots__/scope_section.test.js.snap | 5 ++ x-pack/yarn.lock | 6 +- yarn.lock | 6 +- 13 files changed, 39 insertions(+), 204 deletions(-) delete mode 100644 src/core_plugins/kibana/public/home/components/tutorial/__snapshots__/copy_button.test.js.snap delete mode 100644 src/core_plugins/kibana/public/home/components/tutorial/copy_button.js delete mode 100644 src/core_plugins/kibana/public/home/components/tutorial/copy_button.test.js delete mode 100644 src/core_plugins/kibana/public/home/copy_to_clipboard.js diff --git a/package.json b/package.json index acea26b357c6..19711039f7ca 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "url": "https://github.com/elastic/kibana.git" }, "dependencies": { - "@elastic/eui": "3.4.0", + "@elastic/eui": "3.6.0", "@elastic/filesaver": "1.1.2", "@elastic/numeral": "2.3.2", "@elastic/ui-ace": "0.2.3", diff --git a/src/core_plugins/kibana/public/home/components/tutorial/__snapshots__/copy_button.test.js.snap b/src/core_plugins/kibana/public/home/components/tutorial/__snapshots__/copy_button.test.js.snap deleted file mode 100644 index 4663dc1347d4..000000000000 --- a/src/core_plugins/kibana/public/home/components/tutorial/__snapshots__/copy_button.test.js.snap +++ /dev/null @@ -1,20 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`render 1`] = ` - - - Copy snippet - - -`; diff --git a/src/core_plugins/kibana/public/home/components/tutorial/copy_button.js b/src/core_plugins/kibana/public/home/components/tutorial/copy_button.js deleted file mode 100644 index f58fff4fd234..000000000000 --- a/src/core_plugins/kibana/public/home/components/tutorial/copy_button.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { - EuiButton, - EuiToolTip, -} from '@elastic/eui'; -import { copyToClipboard } from '../../copy_to_clipboard'; - -const UNCOPIED_MSG = 'Copy to clipboard'; -const COPIED_MSG = 'Copied'; - -export class CopyButton extends React.Component { - - constructor(props) { - super(props); - - this.state = { - tooltipText: UNCOPIED_MSG - }; - } - - copySnippet = () => { - const isCopied = copyToClipboard(this.props.textToCopy); - if (isCopied) { - this.setState({ - tooltipText: COPIED_MSG, - }); - } - } - - resetTooltipText = () => { - this.setState({ - tooltipText: UNCOPIED_MSG, - }); - } - - render() { - return ( - - - Copy snippet - - - ); - } -} - -CopyButton.propTypes = { - textToCopy: PropTypes.string.isRequired, -}; diff --git a/src/core_plugins/kibana/public/home/components/tutorial/copy_button.test.js b/src/core_plugins/kibana/public/home/components/tutorial/copy_button.test.js deleted file mode 100644 index a74b66d9b92d..000000000000 --- a/src/core_plugins/kibana/public/home/components/tutorial/copy_button.test.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import React from 'react'; -import { shallow } from 'enzyme'; - -import { - CopyButton, -} from './copy_button'; - -test('render', () => { - const component = shallow(); - expect(component).toMatchSnapshot(); -}); diff --git a/src/core_plugins/kibana/public/home/components/tutorial/instruction.js b/src/core_plugins/kibana/public/home/components/tutorial/instruction.js index 1322cb7cdc8d..4ffd18c6d75d 100644 --- a/src/core_plugins/kibana/public/home/components/tutorial/instruction.js +++ b/src/core_plugins/kibana/public/home/components/tutorial/instruction.js @@ -20,13 +20,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Content } from './content'; -import { CopyButton } from './copy_button'; import { EuiCodeBlock, EuiFlexGroup, EuiFlexItem, EuiSpacer, + EuiCopy, + EuiButton, } from '@elastic/eui'; export function Instruction({ commands, paramValues, textPost, textPre, replaceTemplateStrings }) { @@ -56,9 +57,18 @@ export function Instruction({ commands, paramValues, textPost, textPre, replaceT if (commands) { const cmdText = commands.map(cmd => { return replaceTemplateStrings(cmd, paramValues); }).join('\n'); copyButton = ( - + > + {(copy) => ( + + Copy snippet + + )} + ); commandBlock = (
diff --git a/src/core_plugins/kibana/public/home/copy_to_clipboard.js b/src/core_plugins/kibana/public/home/copy_to_clipboard.js deleted file mode 100644 index cacb559042f0..000000000000 --- a/src/core_plugins/kibana/public/home/copy_to_clipboard.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -function createHiddenTextElement(text) { - const textElement = document.createElement('span'); - textElement.textContent = text; - textElement.style.all = 'unset'; - // prevents scrolling to the end of the page - textElement.style.position = 'fixed'; - textElement.style.top = 0; - textElement.style.clip = 'rect(0, 0, 0, 0)'; - // used to preserve spaces and line breaks - textElement.style.whiteSpace = 'pre'; - // do not inherit user-select (it may be `none`) - textElement.style.webkitUserSelect = 'text'; - textElement.style.MozUserSelect = 'text'; - textElement.style.msUserSelect = 'text'; - textElement.style.userSelect = 'text'; - return textElement; -} - -export function copyToClipboard(text) { - let isCopied = true; - const range = document.createRange(); - const selection = window.getSelection(); - const elementToBeCopied = createHiddenTextElement(text); - - document.body.appendChild(elementToBeCopied); - range.selectNode(elementToBeCopied); - selection.removeAllRanges(); - selection.addRange(range); - - if (!document.execCommand('copy')) { - isCopied = false; - console.warn('Unable to copy to clipboard.'); // eslint-disable-line no-console - } - - if (selection) { - if (typeof selection.removeRange === 'function') { - selection.removeRange(range); - } else { - selection.removeAllRanges(); - } - } - - document.body.removeChild(elementToBeCopied); - - return isCopied; -} diff --git a/x-pack/package.json b/x-pack/package.json index 1b5195a7714b..3f4593d459b4 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -79,7 +79,7 @@ "yargs": "4.7.1" }, "dependencies": { - "@elastic/eui": "3.4.0", + "@elastic/eui": "3.6.0", "@elastic/node-crypto": "0.1.2", "@elastic/node-phantom-simple": "2.2.4", "@elastic/numeral": "2.3.2", diff --git a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/actions_section.test.js.snap b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/actions_section.test.js.snap index 58af7022fc52..35f10f8cd724 100644 --- a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/actions_section.test.js.snap +++ b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/actions_section.test.js.snap @@ -30,6 +30,7 @@ exports[`ActionsSection renders with no actions selected 1`] = ` compressed={false} disabled={false} id="skip_result_cb" + indeterminate={false} label="Skip result (recommended)" onChange={[MockFunction]} /> @@ -68,6 +69,7 @@ exports[`ActionsSection renders with no actions selected 1`] = ` compressed={false} disabled={false} id="skip_model_update_cb" + indeterminate={false} label="Skip model update" onChange={[MockFunction]} /> @@ -118,6 +120,7 @@ exports[`ActionsSection renders with skip_result and skip_model_update selected compressed={false} disabled={false} id="skip_result_cb" + indeterminate={false} label="Skip result (recommended)" onChange={[Function]} /> @@ -156,6 +159,7 @@ exports[`ActionsSection renders with skip_result and skip_model_update selected compressed={false} disabled={false} id="skip_model_update_cb" + indeterminate={false} label="Skip model update" onChange={[Function]} /> @@ -206,6 +210,7 @@ exports[`ActionsSection renders with skip_result selected 1`] = ` compressed={false} disabled={false} id="skip_result_cb" + indeterminate={false} label="Skip result (recommended)" onChange={[MockFunction]} /> @@ -244,6 +249,7 @@ exports[`ActionsSection renders with skip_result selected 1`] = ` compressed={false} disabled={false} id="skip_model_update_cb" + indeterminate={false} label="Skip model update" onChange={[MockFunction]} /> diff --git a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/rule_editor_flyout.test.js.snap b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/rule_editor_flyout.test.js.snap index 5b05a0eb0fb1..bb7b79c4a3de 100644 --- a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/rule_editor_flyout.test.js.snap +++ b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/rule_editor_flyout.test.js.snap @@ -133,6 +133,7 @@ exports[`RuleEditorFlyout renders the flyout after adding a condition to a rule compressed={false} disabled={true} id="enable_conditions_checkbox" + indeterminate={false} label="Add numeric conditions for when the rule applies. Multiple conditions are combined using AND." onChange={[Function]} /> @@ -367,6 +368,7 @@ exports[`RuleEditorFlyout renders the flyout after setting the rule to edit 1`] compressed={false} disabled={true} id="enable_conditions_checkbox" + indeterminate={false} label="Add numeric conditions for when the rule applies. Multiple conditions are combined using AND." onChange={[Function]} /> @@ -587,6 +589,7 @@ exports[`RuleEditorFlyout renders the flyout for creating a rule with conditions compressed={false} disabled={true} id="enable_conditions_checkbox" + indeterminate={false} label="Add numeric conditions for when the rule applies. Multiple conditions are combined using AND." onChange={[Function]} /> diff --git a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_expression.test.js.snap b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_expression.test.js.snap index 9ad80b38ed0b..dcbec7d00959 100644 --- a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_expression.test.js.snap +++ b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_expression.test.js.snap @@ -20,6 +20,7 @@ exports[`ScopeExpression renders when empty list of filter IDs is supplied 1`] = compressed={false} disabled={false} id="scope_cb_domain" + indeterminate={false} onChange={[Function]} /> @@ -58,6 +59,7 @@ exports[`ScopeExpression renders when enabled set to false 1`] = ` compressed={false} disabled={false} id="scope_cb_domain" + indeterminate={false} onChange={[Function]} /> @@ -211,6 +213,7 @@ exports[`ScopeExpression renders when filter ID and type supplied 1`] = ` compressed={false} disabled={false} id="scope_cb_domain" + indeterminate={false} onChange={[Function]} /> @@ -364,6 +367,7 @@ exports[`ScopeExpression renders when no filter ID or type supplied 1`] = ` compressed={false} disabled={false} id="scope_cb_domain" + indeterminate={false} onChange={[Function]} /> diff --git a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_section.test.js.snap b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_section.test.js.snap index 2db4f0c742f4..637cc2025bee 100644 --- a/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_section.test.js.snap +++ b/x-pack/plugins/ml/public/components/rule_editor/__snapshots__/scope_section.test.js.snap @@ -19,6 +19,7 @@ exports[`ScopeSection false canGetFilters privilege show NoPermissionCallOut whe compressed={false} disabled={false} id="enable_scope_checkbox" + indeterminate={false} label="Add a filter list to limit where the rule applies." onChange={[MockFunction]} /> @@ -51,6 +52,7 @@ exports[`ScopeSection renders when enabled with no scope supplied 1`] = ` compressed={false} disabled={false} id="enable_scope_checkbox" + indeterminate={false} label="Add a filter list to limit where the rule applies." onChange={[MockFunction]} /> @@ -97,6 +99,7 @@ exports[`ScopeSection renders when enabled with scope supplied 1`] = ` compressed={false} disabled={false} id="enable_scope_checkbox" + indeterminate={false} label="Add a filter list to limit where the rule applies." onChange={[MockFunction]} /> @@ -143,6 +146,7 @@ exports[`ScopeSection renders when not enabled 1`] = ` compressed={false} disabled={false} id="enable_scope_checkbox" + indeterminate={false} label="Add a filter list to limit where the rule applies." onChange={[MockFunction]} /> @@ -172,6 +176,7 @@ exports[`ScopeSection show NoFilterListsCallOut when no filter list IDs 1`] = ` compressed={false} disabled={false} id="enable_scope_checkbox" + indeterminate={false} label="Add a filter list to limit where the rule applies." onChange={[MockFunction]} /> diff --git a/x-pack/yarn.lock b/x-pack/yarn.lock index 26f9180e17de..25ec11ec1211 100644 --- a/x-pack/yarn.lock +++ b/x-pack/yarn.lock @@ -10,9 +10,9 @@ esutils "^2.0.2" js-tokens "^3.0.0" -"@elastic/eui@3.4.0": - version "3.4.0" - resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-3.4.0.tgz#8eb661b56fc84a27682e008ef9d6913d1b519c07" +"@elastic/eui@3.6.0": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-3.6.0.tgz#ce55a321510dfeb20ca0b46061cbbd29a70b91cd" dependencies: classnames "^2.2.5" core-js "^2.5.1" diff --git a/yarn.lock b/yarn.lock index 6018a86d1522..5ff2bc54a6f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -81,9 +81,9 @@ version "0.0.0" uid "" -"@elastic/eui@3.4.0": - version "3.4.0" - resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-3.4.0.tgz#8eb661b56fc84a27682e008ef9d6913d1b519c07" +"@elastic/eui@3.6.0": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-3.6.0.tgz#ce55a321510dfeb20ca0b46061cbbd29a70b91cd" dependencies: classnames "^2.2.5" core-js "^2.5.1"