fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Review frontend usage of `normalizeEmptyValues()`

Open lukeheath opened this issue 3 years ago • 5 comments

On the HostDetailsPage and DeviceUserPage we're using a function called normalizeEmptyValues() to normalize the object we're displaying. The problem with this function is that we're losing all typing on the resulting object. Typescript thinks every property is a string, regardless of what it actually is, which is causing problems further down the line.

I'm starting this thread so we can identify the benefit of using normalizeEmptyValues() (why it was implemented) and work out a solution that will allow us to keep proper interfaces on these pages.

lukeheath avatar Aug 30 '22 17:08 lukeheath

@fleetdm/frontend Would y'all please take a look at this? I'm curious if anyone recalls why the noramlizeEmptyValues() function was added, and if we can brainstorm an approach that doesn't lose typing.

lukeheath avatar Aug 30 '22 17:08 lukeheath

I'm afraid younger me was responsible for this.

We should definitely rework our approach. I'll take a closer look and follow up with more comments.

gillespi314 avatar Aug 30 '22 19:08 gillespi314

Notes and todos from 7127 will help to improve this situation. See also my comments to 7460.

gillespi314 avatar Aug 30 '22 20:08 gillespi314

Sounds good, thanks for the audit trail!

So looks like the purpose of the normalization function is to replace any falsey values with ---. However, that introduces typing mismatches that are causing issues.

lukeheath avatar Aug 31 '22 18:08 lukeheath

@ghernandez345 This came up on recent work to the Host details page. Going to add this to our frontend sync agenda

RachelElysia avatar Mar 04 '24 15:03 RachelElysia