Skip to content

Commit

Permalink
Index pattern management UI -> TypeScript (scripted_fields_table) (el…
Browse files Browse the repository at this point in the history
…astic#63247)

* Index pattern management UI -> TypeScript (scripted_fields_table)
  • Loading branch information
alexwizp authored and mattkime committed Apr 13, 2020
1 parent 857e08c commit b3b8e6d
Showing 23 changed files with 346 additions and 182 deletions.

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.

Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ import { shallow } from 'enzyme';
import { CallOuts } from '../call_outs';

describe('CallOuts', () => {
it('should render normally', async () => {
test('should render normally', () => {
const component = shallow(
<CallOuts
deprecatedLangsInUse={['php']}
@@ -34,7 +34,7 @@ describe('CallOuts', () => {
expect(component).toMatchSnapshot();
});

it('should render without any call outs', async () => {
test('should render without any call outs', () => {
const component = shallow(
<CallOuts deprecatedLangsInUse={[]} painlessDocLink="http://www.elastic.co/painlessDocs" />
);
Original file line number Diff line number Diff line change
@@ -20,16 +20,20 @@
import React from 'react';

import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';

export const CallOuts = ({ deprecatedLangsInUse, painlessDocLink }) => {
interface CallOutsProps {
deprecatedLangsInUse: string[];
painlessDocLink: string;
}

export const CallOuts = ({ deprecatedLangsInUse, painlessDocLink }: CallOutsProps) => {
if (!deprecatedLangsInUse.length) {
return null;
}

return (
<div>
<>
<EuiCallOut
title={
<FormattedMessage
@@ -60,6 +64,6 @@ export const CallOuts = ({ deprecatedLangsInUse, painlessDocLink }) => {
</p>
</EuiCallOut>
<EuiSpacer size="m" />
</div>
</>
);
};

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 { DeleteScritpedFieldConfirmationModal } from './confirmation_modal';

describe('DeleteScritpedFieldConfirmationModal', () => {
test('should render normally', () => {
const component = shallow(
<DeleteScritpedFieldConfirmationModal
field={{ name: '', script: '', lang: '' }}
deleteField={() => {}}
hideDeleteConfirmationModal={() => {}}
/>
);

expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { EUI_MODAL_CONFIRM_BUTTON, EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';

import { ScriptedFieldItem } from '../../types';

interface DeleteScritpedFieldConfirmationModalProps {
field: ScriptedFieldItem;
hideDeleteConfirmationModal: (
event?: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLButtonElement>
) => void;
deleteField: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}

export const DeleteScritpedFieldConfirmationModal = ({
field,
hideDeleteConfirmationModal,
deleteField,
}: DeleteScritpedFieldConfirmationModalProps) => {
const title = i18n.translate('kbn.management.editIndexPattern.scripted.deleteFieldLabel', {
defaultMessage: "Delete scripted field '{fieldName}'?",
values: { fieldName: field.name },
});
const cancelButtonText = i18n.translate(
'kbn.management.editIndexPattern.scripted.deleteField.cancelButton',
{ defaultMessage: 'Cancel' }
);
const confirmButtonText = i18n.translate(
'kbn.management.editIndexPattern.scripted.deleteField.deleteButton',
{ defaultMessage: 'Delete' }
);

return (
<EuiOverlayMask>
<EuiConfirmModal
title={title}
onCancel={hideDeleteConfirmationModal}
onConfirm={deleteField}
cancelButtonText={cancelButtonText}
confirmButtonText={confirmButtonText}
defaultFocusedButton={EUI_MODAL_CONFIRM_BUTTON}
/>
</EuiOverlayMask>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

export { DeleteScritpedFieldConfirmationModal } from './confirmation_modal';
Original file line number Diff line number Diff line change
@@ -20,10 +20,10 @@
import React from 'react';
import { shallow } from 'enzyme';

import { Header } from '../header';
import { Header } from './header';

describe('Header', () => {
it('should render normally', async () => {
test('should render normally', () => {
const component = shallow(<Header addScriptedFieldUrl="" />);

expect(component).toMatchSnapshot();
Original file line number Diff line number Diff line change
@@ -18,13 +18,15 @@
*/

import React from 'react';
import PropTypes from 'prop-types';

import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';

export const Header = ({ addScriptedFieldUrl }) => (
interface HeaderProps {
addScriptedFieldUrl: string;
}

export const Header = ({ addScriptedFieldUrl }: HeaderProps) => (
<EuiFlexGroup alignItems="center">
<EuiFlexItem>
<EuiTitle size="s">
@@ -56,7 +58,3 @@ export const Header = ({ addScriptedFieldUrl }) => (
</EuiFlexItem>
</EuiFlexGroup>
);

Header.propTypes = {
addScriptedFieldUrl: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
@@ -20,3 +20,4 @@
export { Table } from './table';
export { Header } from './header';
export { CallOuts } from './call_outs';
export { DeleteScritpedFieldConfirmationModal } from './confirmation_modal';

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

Loading

0 comments on commit b3b8e6d

Please sign in to comment.