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

Euify management edit-index-pattern component. #47448

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 { EuiCallOut } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

interface Props {
conflictFields: any;
}

export const Alerts = ({ conflictFields }: Props) => {
return (
<EuiCallOut
title={
<FormattedMessage
id="kbn.management.editIndexPattern.mappingConflictHeader"
defaultMessage="Mapping conflict"
/>
}
color="warning"
iconType="bolt"
>
<FormattedMessage
id="kbn.management.editIndexPattern.mappingConflictLabel"
defaultMessage="{conflictFieldsLength, plural, one {A field is} other {# fields are}} defined as several types (string, integer, etc) across the indices that match this pattern. You may still be able to use these conflict fields in parts of Kibana, but they will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data."
values={{
conflictFieldsLength: conflictFields.length,
}}
/>
</EuiCallOut>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 { EuiBadge } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

interface Props {
indexPattern: any;
}

export const Badges = ({ indexPattern }: Props) => {
return (
<p>
{indexPattern.timeFieldName ? (
<EuiBadge color="warning">
<FormattedMessage
id="kbn.management.editIndexPattern.timeFilterHeader"
defaultMessage="Time Filter field name: {timeFieldName}"
values={{
timeFieldName: indexPattern.timeFieldName,
}}
/>
</EuiBadge>
) : null}
{indexPattern.tags && indexPattern.tags.length
? indexPattern.tags.map((tag: any, i: number) => {
return (
<EuiBadge key={i} color="hollow">
{tag.name}
</EuiBadge>
);
})
: null}
</p>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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 { EuiText, EuiLink, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

interface Props {
indexPattern: any;
}

export const GuideText = ({ indexPattern }: Props) => {
return (
<EuiText>
<p>
<FormattedMessage
id="kbn.management.editIndexPattern.timeFilterLabel.timeFilterDetail"
defaultMessage="This page lists every field in the {indexPatternTitle} index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch {apiLink}."
values={{
indexPatternTitle: <strong>{indexPattern.title}</strong>,
apiLink: (
<EuiLink
target="_blank"
href="http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html"
>
<FormattedMessage
id="kbn.management.editIndexPattern.timeFilterLabel.mappingAPILink"
defaultMessage="Mapping API"
/>
<EuiIcon type="link" />
</EuiLink>
),
}}
/>
Comment on lines +32 to +50
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it "link to the mapping api" to be a value instead of a separate component. It's because in some languages like Korean and Japanese, link cannot be placed at the end of the explanation text.

I've fixed the language files in the below.

</p>
</EuiText>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
* under the License.
*/

import './index_header';
export { IndexHeader } from './index_header';
export { Badges } from './badges';
export { GuideText } from './guide_text';
export { Alerts } from './alerts';
export { Tabs } from './tabs';
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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 { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiButtonEmpty, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

interface Props {
defaultIndex: boolean;
indexPatternTitle: string;
setDefault: any;
refreshFields: any;
removePattern: any;
Comment on lines +27 to +29
Copy link
Contributor Author

@sainthkh sainthkh Oct 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are angular functions and should be re-written later. So, they should be left as any.

indexPattern and conflictedFields in other components are any type for the same reason.

These any types will be fixed in later PRs.

}

export const IndexHeader = ({
defaultIndex,
indexPatternTitle,
setDefault,
refreshFields,
removePattern,
}: Props) => {
return (
<div>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiTitle size="m">
<h1 data-test-subj="indexPatternTitle">
{defaultIndex ? <EuiIcon type="starFilled" size="xl" /> : null}
{indexPatternTitle}
</h1>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup alignItems="center">
<EuiButtonEmpty
onClick={() => setDefault()}
size="s"
aria-label={i18n.translate('kbn.management.editIndexPattern.setDefaultAria', {
defaultMessage: 'Set as default index',
})}
title={i18n.translate('kbn.management.editIndexPattern.setDefaultTooltip', {
defaultMessage: 'Set as default index',
})}
data-test-subj="setDefaultIndexPatternButton"
>
<EuiIcon type="starFilled" size="l"></EuiIcon>
</EuiButtonEmpty>
<EuiButtonEmpty
onClick={() => refreshFields()}
aria-label={i18n.translate('kbn.management.editIndexPattern.refreshAria', {
defaultMessage: 'Reload field list',
})}
title={i18n.translate('kbn.management.editIndexPattern.refreshTooltip', {
defaultMessage: 'Refresh field list',
})}
>
<EuiIcon type="refresh" size="l"></EuiIcon>
</EuiButtonEmpty>
<EuiButtonEmpty
color="danger"
onClick={() => removePattern()}
aria-label={i18n.translate('kbn.management.editIndexPattern.removeAria', {
defaultMessage: 'Remove index pattern',
})}
title={i18n.translate('kbn.management.editIndexPattern.removeTooltip', {
defaultMessage: 'Remove index pattern',
})}
data-test-subj="deleteIndexPatternButton"
>
<EuiIcon type="trash" size="l"></EuiIcon>
</EuiButtonEmpty>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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, { useState } from 'react';
import { EuiFieldSearch } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

interface Props {
$scope: any;
}

export const SearchField = ({ $scope }: Props) => {
const [text, setText] = useState<string>($scope.fieldFilter || '');

return (
<EuiFieldSearch
fullWidth={true}
placeholder={i18n.translate('kbn.management.editIndexPattern.fields.filterPlaceholder', {
defaultMessage: 'Filter',
})}
aria-label={i18n.translate('kbn.management.editIndexPattern.fields.filterAria', {
defaultMessage: 'Filter',
})}
data-test-subj="indexPatternFieldFilter"
value={text}
onChange={event => {
const newText = event.target.value;
setText(newText);
$scope.fieldFilter = newText;
$scope.$apply();
}}
/>
);
};
Loading