-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Infra UI] Add date picker to asset details #164450
[Infra UI] Add date picker to asset details #164450
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
baec8be
to
ea4bf91
Compare
<EuiIconTip | ||
aria-label={i18n.translate( | ||
'xpack.infra.metrics.nodeDetails.processesHeader.tooltipLabel', | ||
<EuiFlexGroup direction="column" gutterSize="m"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use flexbox instead of having <EuiSpacer size="m" />
to separate each section
@@ -218,14 +228,6 @@ const ProcessesTableBody = ({ items, currentTime }: TableBodyProps) => ( | |||
</> | |||
); | |||
|
|||
const StyledTableBody = euiStyled(EuiTableBody)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
euiStyled is marked as deprecated.
overflow: hidden; | ||
text-overflow: ellipsis; | ||
`; | ||
const CodeLine = ({ command }: { command: string }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
euiStyled is deprecated. Created this new component in order to replace it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changing those!
const [hostFlyoutState, setHostFlyoutState] = useHostFlyoutUrlState(); | ||
|
||
return source ? ( | ||
<AssetDetails | ||
asset={{ id: name, name }} | ||
assetType="host" | ||
dateRange={searchCriteria.dateRange} | ||
dateRange={parsedDateRange} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, we make sure the flyout will always open with the same date range. Previously, if the date picker had relative dates, each time the flyout opened a new absolute date would be calculated.
align-self: center; | ||
`} | ||
> | ||
<EuiEmptyPrompt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing with an EUI component
{!hideDatePicker && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiSuperDatePicker | ||
start={dateRange.from} | ||
end={dateRange.to} | ||
showUpdateButton={false} | ||
onTimeChange={onTimeChange} | ||
width="full" | ||
/> | ||
</EuiFlexItem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't want to mess with other components that use the anomalies table. We might want to refactor this component in the future and split content and date picker into separate components
// Retrocompatibility | ||
const handleTabStateChange = ({ dateRange: newDateRange }: TabState) => { | ||
if (newDateRange) { | ||
setTimeRange({ | ||
from: newDateRange.from, | ||
to: newDateRange.to, | ||
interval: parsedTimeRange.interval, | ||
}); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this once we start storing the asset details state in the URL.
…-picker-to-asset-details
21e007d
to
8c1e5c7
Compare
@elasticmachine merge upstream |
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
x-pack/plugins/infra/public/components/asset_details/content/content.tsx
Show resolved
Hide resolved
({ | ||
range, | ||
preventDefault, | ||
}: Parameters<NonNullable<LensEmbeddableInput['onBrushEnd']>>[0]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to add an alias for this type to make it a bit easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! 👏 The new date picker works fine and the date value persists between the tabs. I have some questions as I think I found 2 issues that we can check:
In case the user changes the time range inside the flyout it persists when he opens the details page but when the back button is pressed the flyout loads with the default time range (not the selected one when the user left the page to see the details page):
Screen.Recording.2023-08-24.at.12.11.22.mov
When the user selects the date inside the flyout and refreshes the page/shares the URL the time range does not persist
Screen.Recording.2023-08-24.at.12.07.51.mov
I am not sure about that but sometimes when using "now" as "to" date it is converted to relative data and sometimes it stays as "now". Usually, when the "from" date is changed it changes to the relative date instead of "now" so what should be the expected behavior (should we use "now" or we should always convert to the relative date?):
Screen.Recording.2023-08-24.at.12.46.03.mov
Screen.Recording.2023-08-24.at.12.47.08.mov
overflow: hidden; | ||
text-overflow: ellipsis; | ||
`; | ||
const CodeLine = ({ command }: { command: string }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changing those!
initialDateRange: TimeRange; | ||
} | ||
|
||
export function useDateRangeProvider({ initialDateRange }: UseAssetDetailsStateProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we have the date range persisted in the URL (the case of the flyout for example) should we first get the date range from the URL value (passed to the asset details component) and if we don't have it to fallback to default (the value selected in the host view / the 15m default)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're completely right. I totally forgot to store the date range in the URL state.
]); | ||
}); | ||
|
||
describe('#Date picker', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ❤️
FlyoutTabIds.OVERVIEW, | ||
FlyoutTabIds.LOGS, | ||
FlyoutTabIds.METADATA, | ||
FlyoutTabIds.PROCESSES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the processes tab results affected by the new dates as in the process list API it will always check for 1-minute interval 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind I saw that we plan to add a tooltip to explain that in this issue so I guess it should be fine.
Thanks @mykolaharmash and @jennypavlova for reviewing the PR.
That's an interesting use case. To achieve that we'd have to have a context provider to share the state between Hosts and Node Details. It's similar to this #164300, but the other way around. Perhaps we can rephrase that ticket to cover this use case?
Working on this.
Gotcha. The second video shows the problem. Will check |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! I tried the navigation again and now the full page is setting the last one hour based on the "to" date - not the whole interval set in the flyout:
nav_to_full_page.mov
Is that intentional or it should be changed?
But going back to the flyout is fixed (the selected dates before navigating to the full page view are shown) the URL sharing and persisting after refresh as well 🎉
@@ -64,9 +64,11 @@ export const useMetricsTime = () => { | |||
parseRange(urlState.time || DEFAULT_TIMERANGE) | |||
); | |||
|
|||
const updateTimeRange = useCallback((range: MetricsTimeInput) => { | |||
const updateTimeRange = useCallback((range: MetricsTimeInput, parseDate = true) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe we can always pass a parsed date to this function so here we can simplify the logic, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to change this function so much. We won't use it after this #164147 is done
@jennypavlova , thanks for thoroughly testing things! The link was doing what the inventory does: end date - 1h. I've fixed it and added a test to validate it. |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 Thank you for the fixes!
closes: #160378
Summary
This PR adds a date-picker to the Asset Details (full page and flyout)
Flyout
Full page view
Setting a date range
full_page_date_picker.mov
Brush event filter
chart_date_filter.mov
Bonus
The uptime link was removed since the UI won't work.
How to test
Infrastructure
>Hosts
Infrastructure
>Hosts
- With Show: Host selected, click on a waffle item to open the flyout, click on Open as page and check if the new Node Details page opened with the same date range from the Inventory UI
Validate if the date picker value is applied to all tabs that have the component (Overview, Metadata, Processes, Logs, Anomalies)
Validate if the date range changes when selecting a time range in the charts (in the flyout, the date range from the Hosts View must not change)