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

isDashboardSelectorAvailable should be a boolean #69

Open
clemcvlcs opened this issue Jun 2, 2023 · 2 comments
Open

isDashboardSelectorAvailable should be a boolean #69

clemcvlcs opened this issue Jun 2, 2023 · 2 comments

Comments

@clemcvlcs
Copy link

I'd like to hide theEntityGrafanaDashboardsCard if the annotation is not defined for the entity.
This is commonly done in other plugin with someting similar to:

    <EntitySwitch>
      <EntitySwitch.Case if={isDashboardSelectorAvailable}>
        <Grid item sm={6}>
          <EntityGrafanaDashboardsCard />
        </Grid>
      </EntitySwitch.Case>
    </EntitySwitch>

But here, the snippet does not work since isDashboardSelectorAvailable is not a boolean for some reasons.
I believe we should have someting like

// src/components/grafanaData.ts
export const isDashboardSelectorAvailable = (entity: Entity) => Boolean(entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] || entity?.metadata.annotations?.[GRAFANA_ANNOTATION_TAG_SELECTOR]);

instead of

// src/components/grafanaData.ts
export const isDashboardSelectorAvailable = (entity: Entity) => entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] || entity?.metadata.annotations?.[GRAFANA_ANNOTATION_TAG_SELECTOR];

What do you think ?
Please let me know if you want me to open a PR.

Thanks in advance

@Vity01
Copy link

Vity01 commented Jun 27, 2023

@K-Phoen could you please fix that?

@Shandur
Copy link

Shandur commented Jul 20, 2023

Agree on having some Boolean function, maybe a new one like isDashboardSelectorApplicable to avoid breaking changes.
I workaround the issue in the following way:

<EntitySwitch.Case if={e => !!isDashboardSelectorAvailable(e)}>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants