-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Observability] [Exploratory View] add chart creation context (#114784)…
… (#115704) * add chart creation context * add chart creation tooltip, remove outer panel, and change default chart type for synthetics data * adjust types * remove extra translations * add panel back * update chart creation time date format * update time format * adjust tests Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Dominique Clarke <[email protected]>
- Loading branch information
1 parent
43fb6d3
commit b919b41
Showing
8 changed files
with
145 additions
and
17 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
35 changes: 35 additions & 0 deletions
35
...servability/public/components/shared/exploratory_view/header/chart_creation_info.test.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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { screen } from '@testing-library/dom'; | ||
import { render } from '../rtl_helpers'; | ||
import { ChartCreationInfo } from './chart_creation_info'; | ||
|
||
const info = { | ||
to: 1634071132571, | ||
from: 1633406400000, | ||
lastUpdated: 1634071140788, | ||
}; | ||
|
||
describe('ChartCreationInfo', () => { | ||
it('renders chart creation info', async () => { | ||
render(<ChartCreationInfo {...info} />); | ||
|
||
expect(screen.getByText('Chart created')).toBeInTheDocument(); | ||
expect(screen.getByText('Oct 12, 2021 4:39 PM')).toBeInTheDocument(); | ||
expect(screen.getByText('Displaying from')).toBeInTheDocument(); | ||
expect(screen.getByText('Oct 5, 2021 12:00 AM → Oct 12, 2021 4:38 PM')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not display info when props are falsey', async () => { | ||
render(<ChartCreationInfo />); | ||
|
||
expect(screen.queryByText('Chart created')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('Displaying from')).not.toBeInTheDocument(); | ||
}); | ||
}); |
61 changes: 61 additions & 0 deletions
61
...ns/observability/public/components/shared/exploratory_view/header/chart_creation_info.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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import moment from 'moment'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui'; | ||
import type { ChartTimeRange } from './last_updated'; | ||
|
||
export function ChartCreationInfo(props: Partial<ChartTimeRange>) { | ||
const dateFormat = 'lll'; | ||
const from = moment(props.from).format(dateFormat); | ||
const to = moment(props.to).format(dateFormat); | ||
const created = moment(props.lastUpdated).format(dateFormat); | ||
|
||
return ( | ||
<> | ||
{props.lastUpdated && ( | ||
<> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiText size="xs"> | ||
<FormattedMessage | ||
id="xpack.observability.expView.seriesBuilder.creationTime" | ||
defaultMessage="Chart created" | ||
/> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={2}> | ||
<EuiText size="xs">{created}</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="xs" /> | ||
</> | ||
)} | ||
{props.to && props.from && ( | ||
<> | ||
<EuiFlexGroup alignItems="center"> | ||
<EuiFlexItem> | ||
<EuiText size="xs"> | ||
<FormattedMessage | ||
id="xpack.observability.expView.seriesBuilder.creationContext" | ||
defaultMessage="Displaying from" | ||
/> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={2}> | ||
<EuiText size="xs"> | ||
{from} → {to} | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
)} | ||
</> | ||
); | ||
} |
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