-
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
[Uptime] Fix Name/ID column label on overview #32603
Conversation
This column was named `ID` even though it preferentially shows the monitor name. This patch replaces the table heading with the text `Name / ID` and adds a disambiguating title to the links. Additionally, it italicizes IDs to help distinguish them from names. Goes toward resolving elastic#27752.
Pinging @elastic/uptime |
💚 Build Succeeded |
Part of me thinks we should just have two columns, but that would use a ton of space. |
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.
This change is definitely nicer than what we're currently doing IMO.
We should get feedback from someone on @elastic/design as well.
I left a few comments asking for changes that are debatable.
return ( | ||
<Link | ||
to={`/monitor/${id}`} | ||
title={`Name: ${name ? "'" + name + "'" : 'N/A'}, ID: '${id}'`} |
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.
title={`Name: ${name ? "'" + name + "'" : 'N/A'}, ID: '${id}'`} | |
title={`Name: ${name ? `"${name}"` : 'N/A'}\nID: "${id}"`} |
I think it's better to consistently use the template-style string definition.
Additionally, I think it's nicer and easier to read the title if we add a newline. WDYT?
@@ -79,16 +80,20 @@ export const MonitorList = ({ dangerColor, loading, monitors, primaryColor }: Mo | |||
}, | |||
{ | |||
field: 'ping.monitor.id', | |||
name: i18n.translate('xpack.uptime.monitorList.idColumnLabel', { | |||
defaultMessage: 'ID', | |||
name: i18n.translate('xpack.uptime.monitorList.nameIdColumnLabel', { |
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.
Thank you for updating key. Can you please add a description as well?
The key for it is description
, it's a sibling of defaultMessage
and it takes a string.
I don't think it's necessary to italicize the link if it's an ID. It's not obvious that that's what it is signifying. I think the actual text itself is pretty recognizable as names are more human-readable words and id's are a mash of letters, numbers and dashes. Is there any chance that there can be both a name and ID? If so, I'd guess that you'd want to display both in which case, I'd stack them like:
|
@cchaos all items have an ID, it is recommended that all items have both a Name and an ID. I do like the stacking. It brings up an additional question: in the case where there's no name how would you handle the linking? |
Then you can just add the link to the ID instead. Unless you really want to re-enforce creating names, then you can maybe do:
|
I prefer the re-enforcement of the naming. Also, I think it's weird that sometimes IDs are linked, and sometimes they are not, so I'll go with the bracketed solution you propose. |
cc @gchaps For guidance on what unnamed items should actually be called? |
I'd use Unnamed, but give the text some kind of style change. Because the user could actually have used the named Unnamed.
|
💔 Build Failed |
💔 Build Failed |
Thanks for the help @cchaos and @gchaps . This is going to slip 7.0 because I'm realizing we need this change across both the monitor and error list. (CC @dov0211 ) That means refactoring some APIs and the way we query things. We'll need to switch to a two-phase query where we search the time slice indicated by the picker to generate charts etc, but then issue a second query to get the most recent state for things like:
|
As a heads up, I've moved this PR to WIP as I work through these larger changes. |
💔 Build Failed |
@dov0211 yes, this is definitely an in-progress PR. The question of whether to display the ID is a good one. The ID is useful for users using Would love to hear some alternative ideas (and see mocks) that would work for both camps. One idea is that we could hide the IDs for centrally configured monitors. |
After meeting with @dov0211 and @justinkambic we decided to only have the |
@justinkambic @dov0211 the monitor name is now shown on both the monitor list and the error list. This also reworks how we calculate the name, pulling the latest name value, so even if a user changes the name, the correct value is shown. This also refactors some internals to be more clean, removing the notion of Those two refactors account for most of the code changes here. |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
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.
There're a few broken unit tests that need some snapshot refreshes.
I'm considering making a PR to update our README with a Contributing checklist so that contributors (and me) can more easily get their PRs production-ready. WDYT?
export const MonitorNameID = (id: string, monitor: LatestMonitor) => { | ||
const name = get(monitor, 'ping.monitor.name'); | ||
return ( | ||
<div> |
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'm assuming you have a <div>
here because React requires there to be a single root-level element. Unless there's a stylistic reason for <div>
, it is probably better to use Fragment here.
/** | ||
* Fetches the latest version of each monitor, regardless of time picker settings | ||
* This is important because we usually want to display the latest name and other info | ||
* for a given monitor |
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 comment + params description
name?: string | null; | ||
} | ||
|
||
export const MonitorName: React.SFC<MonitorNameProps> = ({ id, name }) => { |
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.
++ on this being its own component
return ( | ||
<div> | ||
<EuiLink href={`#/monitor/${id}`} className="ut-monitor-name"> | ||
{name ? name : <em>[Unnamed]</em>} |
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.
This needs to be translated. Something like this is what we'll need:
{name ? (
name
) : (
<em>
{i18n.translate('few', {
defaultMessage: '[Unnamed]',
description:
'This is the default text we show when an uptime monitor has no name defined',
})}
</em>
)}
@@ -7,8 +7,8 @@ | |||
import { get, set } from 'lodash'; | |||
|
|||
export const getFilteredQuery = ( | |||
dateRangeStart: string, | |||
dateRangeEnd: string, | |||
dateRangeStart: string | null, |
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.
Can you add some unit tests to cover the contingencies introduced in this PR?
It looks like we'd need tests to cover
- Only
dateRangeStart
isnull
- Only
dateRangeEnd
isnull
!dateRangeStart && !dateRangeEnd
wheredateRangeStart
and/ordateRangeEnd
arenull
?
Snapshot tests are sufficient, just making sure that the returned value for each matches what you're expecting.
These functions are prime contenders for defect injection so having them well-tested averts problems and makes future additions easier. We're adding even more complexity for the time being, so this would be a big help.
|
||
const monitorIds = flatten( |
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.
Out of scope for this PR but what would you think of extracting this ancillary business logic to additional helper functions? There's a lot of untested code like this in these adapter files, and they're getting taller over time.
💔 Build Failed |
This work will be addressed during #38786 |
💔 Build Failed |
This column was named
ID
even though it preferentially shows the monitor name. This patch replaces the table heading with the textName / ID
and adds a disambiguating title to the links. Additionally, it italicizes IDs to help distinguish them from names.Goes toward resolving #27752.
Before
After