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

fix(visibility): Look for field meta on data['meta']['fields'] #77951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gggritso
Copy link
Member

@gggritso gggritso commented Sep 23, 2024

Discover responses look like this:

{
  data: [
    {
      'eps()': 0.01087819860850493,
    },
  ],
  meta: {
    fields: {
      'eps()': 'rate',
    },
    units: {
      'eps()': '1/second',
    },
  }
}

You can see that field types are on the meta.fields object. However, the field renderers look for field types like this:

const fieldType = meta[fieldName] || meta.fields[fieldName];

They're just looking for keys on meta itself! This is because Discover data fetchers do this:

const {fields, ...otherMeta} = data.meta ?? {};
return {
  ...data,
  meta: {...fields, ...otherMeta},
};

I don't know why! I'm curious to know why. However, regardless of why, field renderers should attempt to find field definitions on the data.meta.fields object, if it exists. This makes it easier to use field renderes on Discover responses regardless of context (e.g., in the new data visualization widget components)

This is the newer server response format! Field types appear on that
field, if present.
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 23, 2024
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
static/app/utils/discover/fieldRenderers.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #77951      +/-   ##
==========================================
- Coverage   78.12%   78.12%   -0.01%     
==========================================
  Files        6995     6995              
  Lines      310205   310219      +14     
  Branches    50760    50763       +3     
==========================================
+ Hits       242352   242359       +7     
- Misses      56133    56138       +5     
- Partials    11720    11722       +2     

@gggritso gggritso marked this pull request as ready for review September 23, 2024 16:11
@gggritso gggritso requested a review from a team as a code owner September 23, 2024 16:11
@gggritso gggritso requested a review from a team September 23, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant