forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tic#59945) Backports the following commits to 7.x: - [Logs UI] Add expandable rows with category examples (elastic#54586)
- Loading branch information
1 parent
bd4c3ad
commit b438a53
Showing
51 changed files
with
1,365 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_category_examples.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
|
||
import { | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
timeRangeRT, | ||
routeTimingMetadataRT, | ||
} from '../../shared'; | ||
|
||
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_EXAMPLES_PATH = | ||
'/api/infra/log_analysis/results/log_entry_category_examples'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLogEntryCategoryExamplesRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
// the category to fetch the examples for | ||
categoryId: rt.number, | ||
// the number of examples to fetch | ||
exampleCount: rt.number, | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
// the time range to fetch the category examples from | ||
timeRange: timeRangeRT, | ||
}), | ||
}); | ||
|
||
export type GetLogEntryCategoryExamplesRequestPayload = rt.TypeOf< | ||
typeof getLogEntryCategoryExamplesRequestPayloadRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
const logEntryCategoryExampleRT = rt.type({ | ||
dataset: rt.string, | ||
message: rt.string, | ||
timestamp: rt.number, | ||
}); | ||
|
||
export type LogEntryCategoryExample = rt.TypeOf<typeof logEntryCategoryExampleRT>; | ||
|
||
export const getLogEntryCategoryExamplesSuccessReponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: rt.type({ | ||
examples: rt.array(logEntryCategoryExampleRT), | ||
}), | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogEntryCategoryExamplesSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoryExamplesSuccessReponsePayloadRT | ||
>; | ||
|
||
export const getLogEntryCategoryExamplesResponsePayloadRT = rt.union([ | ||
getLogEntryCategoryExamplesSuccessReponsePayloadRT, | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type GetLogEntryCategoryExamplesReponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoryExamplesResponsePayloadRT | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './row_expansion_button'; |
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/infra/public/components/basic_table/row_expansion_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiButtonIcon } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React, { useCallback } from 'react'; | ||
|
||
export const RowExpansionButton = <Item extends any>({ | ||
isExpanded, | ||
item, | ||
onCollapse, | ||
onExpand, | ||
}: { | ||
isExpanded: boolean; | ||
item: Item; | ||
onCollapse: (item: Item) => void; | ||
onExpand: (item: Item) => void; | ||
}) => { | ||
const handleClick = useCallback(() => (isExpanded ? onCollapse(item) : onExpand(item)), [ | ||
isExpanded, | ||
item, | ||
onCollapse, | ||
onExpand, | ||
]); | ||
|
||
return ( | ||
<EuiButtonIcon | ||
onClick={handleClick} | ||
aria-label={isExpanded ? collapseAriaLabel : expandAriaLabel} | ||
iconType={isExpanded ? 'arrowUp' : 'arrowDown'} | ||
/> | ||
); | ||
}; | ||
|
||
const collapseAriaLabel = i18n.translate('xpack.infra.table.collapseRowLabel', { | ||
defaultMessage: 'Collapse', | ||
}); | ||
|
||
const expandAriaLabel = i18n.translate('xpack.infra.table.expandRowLabel', { | ||
defaultMessage: 'Expand', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.