[Osquery] Fix Saved Query mapping (#105398)

This commit is contained in:
Patryk Kopyciński 2021-07-13 21:07:23 +03:00 committed by GitHub
parent d65743cc3c
commit c88213b095
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 15 deletions

View file

@ -6,7 +6,7 @@
*/
import { find } from 'lodash/fp';
import { EuiCodeBlock, EuiFormRow, EuiComboBox, EuiText } from '@elastic/eui';
import { EuiCodeBlock, EuiFormRow, EuiComboBox, EuiTextColor } from '@elastic/eui';
import React, {
forwardRef,
useCallback,
@ -19,6 +19,7 @@ import { SimpleSavedObject } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { useHistory, useLocation } from 'react-router-dom';
import styled from 'styled-components';
import { useSavedQueries } from './use_saved_queries';
@ -26,6 +27,17 @@ export interface SavedQueriesDropdownRef {
clearSelection: () => void;
}
const TextTruncate = styled.div`
overflow: hidden;
text-overflow: ellipsis;
`;
const StyledEuiCodeBlock = styled(EuiCodeBlock)`
.euiCodeBlock__line {
white-space: nowrap;
}
`;
interface SavedQueriesDropdownProps {
disabled?: boolean;
onChange: (
@ -88,12 +100,12 @@ const SavedQueriesDropdownComponent = forwardRef<
({ value }) => (
<>
<strong>{value.id}</strong>
<EuiText size="s" color="subdued">
<p className="euiTextColor--subdued">{value.description}</p>
</EuiText>
<EuiCodeBlock language="sql" fontSize="m" paddingSize="s">
{value.query}
</EuiCodeBlock>
<TextTruncate>
<EuiTextColor color="subdued">{value.description}</EuiTextColor>
</TextTruncate>
<StyledEuiCodeBlock language="sql" fontSize="m" paddingSize="s">
{value.query.split('\n').join(' ')}
</StyledEuiCodeBlock>
</>
),
[]
@ -145,7 +157,7 @@ const SavedQueriesDropdownComponent = forwardRef<
selectedOptions={selectedOptions}
onChange={handleSavedQueryChange}
renderOption={renderOption}
rowHeight={90}
rowHeight={110}
/>
</EuiFormRow>
);

View file

@ -56,7 +56,7 @@ export const useUpdateSavedQuery = ({ savedQueryId }: UseUpdateSavedQueryProps)
i18n.translate('xpack.osquery.editSavedQuery.successToastMessageText', {
defaultMessage: 'Successfully updated "{savedQueryName}" query',
values: {
savedQueryName: payload.attributes?.name ?? '',
savedQueryName: payload.attributes?.id ?? '',
},
})
);

View file

@ -24,7 +24,7 @@ export const savedQuerySavedObjectMappings: SavedObjectsType['mappings'] = {
type: 'date',
},
created_by: {
type: 'text',
type: 'keyword',
},
platform: {
type: 'keyword',
@ -36,7 +36,7 @@ export const savedQuerySavedObjectMappings: SavedObjectsType['mappings'] = {
type: 'date',
},
updated_by: {
type: 'text',
type: 'keyword',
},
interval: {
type: 'keyword',
@ -57,19 +57,19 @@ export const packSavedObjectMappings: SavedObjectsType['mappings'] = {
type: 'text',
},
name: {
type: 'text',
type: 'keyword',
},
created_at: {
type: 'date',
},
created_by: {
type: 'text',
type: 'keyword',
},
updated_at: {
type: 'date',
},
updated_by: {
type: 'text',
type: 'keyword',
},
queries: {
properties: {
@ -77,7 +77,7 @@ export const packSavedObjectMappings: SavedObjectsType['mappings'] = {
type: 'keyword',
},
interval: {
type: 'text',
type: 'keyword',
},
},
},