Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Mar 7, 2019

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 #27752.

Before
image

After

image

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.
@andrewvc andrewvc added bug Fixes for quality problems that affect the customer experience review Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability labels Mar 7, 2019
@andrewvc andrewvc self-assigned this Mar 7, 2019
@andrewvc andrewvc requested review from justinkambic and dov0211 March 7, 2019 01:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@andrewvc
Copy link
Contributor Author

andrewvc commented Mar 7, 2019

Part of me thinks we should just have two columns, but that would use a ton of space.

@andrewvc andrewvc mentioned this pull request Mar 7, 2019
7 tasks
Copy link
Contributor

@justinkambic justinkambic left a 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}'`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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', {
Copy link
Contributor

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.

@cchaos
Copy link
Contributor

cchaos commented Mar 7, 2019

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:

Name of the thing
id of the thing (no link)

@andrewvc
Copy link
Contributor Author

andrewvc commented Mar 7, 2019

@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?

@cchaos
Copy link
Contributor

cchaos commented Mar 7, 2019

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:

[Unnamed monitor]
id of the thing

@andrewvc
Copy link
Contributor Author

andrewvc commented Mar 7, 2019

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.

@cchaos
Copy link
Contributor

cchaos commented Mar 7, 2019

cc @gchaps For guidance on what unnamed items should actually be called?

@gchaps
Copy link
Contributor

gchaps commented Mar 7, 2019

I'd use Unnamed, but give the text some kind of style change. Because the user could actually have used the named Unnamed.

[Unnamed]
id of the thing

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@andrewvc
Copy link
Contributor Author

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:

  1. the name/id column (since the name can change over time with a stable ID)
  2. the status indicator, which should always be current I think. Would like some feedback on this point from @dov0211 @makwarth and @justinkambic

@andrewvc andrewvc added WIP Work in progress and removed review labels Mar 12, 2019
@andrewvc
Copy link
Contributor Author

As a heads up, I've moved this PR to WIP as I work through these larger changes.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@dov0211
Copy link

dov0211 commented Mar 14, 2019

I had looked at this PR
Looks like there is a problem with the error table
image

Also, why should we display the ID when a name is defined?
image

@andrewvc
Copy link
Contributor Author

@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 yml config files, which is the only way to do it today. However, once we have centralized config it won't be useful.

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.

@andrewvc
Copy link
Contributor Author

After meeting with @dov0211 and @justinkambic we decided to only have the name field shown. Since IDs will be hidden with the upcoming management UI, they need not live in most tables. We'll keep them available, for now, on the monitor detail pages, but will potentially de-emphasize them in the future.

@andrewvc
Copy link
Contributor Author

@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 id{key, url} and replacing it with a simple string since only 6.7 needed that.

Those two refactors account for most of the code changes here.

@andrewvc andrewvc added review and removed WIP Work in progress labels Mar 26, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@justinkambic justinkambic left a 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>
Copy link
Contributor

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
Copy link
Contributor

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 }) => {
Copy link
Contributor

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>}
Copy link
Contributor

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,
Copy link
Contributor

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 is null
  • Only dateRangeEnd is null
  • !dateRangeStart && !dateRangeEnd
    where dateRangeStart and/or dateRangeEnd are null?

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(
Copy link
Contributor

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@dov0211
Copy link

dov0211 commented Apr 10, 2019

Found the following error in the UI in the error table
image

with the following exception

Error: Cannot return null for non-nullable field LatestMonitor.name.
at completeValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:631:13)
at completeValueWithLocatedError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:580:21)
at completeValueCatchingError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:550:12)
at resolveField (/Users/dov/kibana/node_modules/graphql/execution/execute.js:497:10)
at /Users/dov/kibana/node_modules/graphql/execution/execute.js:364:18
at Array.reduce ()
at executeFields (/Users/dov/kibana/node_modules/graphql/execution/execute.js:361:42)
at collectAndExecuteSubfields (/Users/dov/kibana/node_modules/graphql/execution/execute.js:772:10)
at completeObjectValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:762:10)
at completeValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:660:12)
at completeValueWithLocatedError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:580:21)
at completeValueCatchingError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:556:21)
at resolveField (/Users/dov/kibana/node_modules/graphql/execution/execute.js:497:10)
at /Users/dov/kibana/node_modules/graphql/execution/execute.js:364:18
at Array.reduce ()
at executeFields (/Users/dov/kibana/node_modules/graphql/execution/execute.js:361:42)
at collectAndExecuteSubfields (/Users/dov/kibana/node_modules/graphql/execution/execute.js:772:10)
at completeObjectValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:762:10)
at completeValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:660:12)
at completeValue (/Users/dov/kibana/node_modules/graphql/execution/execute.js:629:21)
at completeValueWithLocatedError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:580:21)
at completeValueCatchingError (/Users/dov/kibana/node_modules/graphql/execution/execute.js:550:12)

@alvarolobato alvarolobato added :uptime and removed Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.2.0 labels Jun 19, 2019
@alvarolobato
Copy link

This work will be addressed during #38786

@elasticmachine
Copy link
Contributor

💔 Build Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience review v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants