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

Index pattern management UI -> TypeScript (scripted_fields_table) #63247

Merged
merged 5 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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

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
Expand Up @@ -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']}
Expand All @@ -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" />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ import React from 'react';
import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';
import PropTypes from 'prop-types';

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
Expand Down Expand Up @@ -60,6 +66,11 @@ export const CallOuts = ({ deprecatedLangsInUse, painlessDocLink }) => {
</p>
</EuiCallOut>
<EuiSpacer size="m" />
</div>
</>
);
};

CallOuts.propTypes = {
deprecatedLangsInUse: PropTypes.array.isRequired,
painlessDocLink: PropTypes.string.isRequired,
};

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,71 @@
/*
* 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 { 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>
);
};

DeleteScritpedFieldConfirmationModal.propTypes = {
field: PropTypes.object.isRequired,
hideDeleteConfirmationModal: PropTypes.func.isRequired,
deleteField: PropTypes.func.isRequired,
};
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
Expand Up @@ -23,7 +23,7 @@ import { shallow } from 'enzyme';
import { Header } from '../header';

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

expect(component).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elasti

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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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