K-Phoen / backstage-plugin-grafana

Grafana plugin for Backstage
Apache License 2.0
53 stars 28 forks source link

Export isAlertSelectorAvailable #52

Closed MarcBuch closed 1 year ago

MarcBuch commented 1 year ago

In addition to isDashboardSelectorAvailable, it would be great to export isAlertSelectorAvailable as well.

Why?

This allows the usage of EntitySwitch on the EntityPage. Instead of throwing an error, if there are not Grafana annotations, the card then is simply not rendered.

EntitySwitch Example

<EntitySwitch>
  <EntitySwitch.Case if={isDashboardSelectorAvailable}>
    <Grid item xs={3}>
      <EntityGrafanaDashboardsCard />
    </Grid>
  </EntitySwitch.Case>
</EntitySwitch>
<EntitySwitch>
  <EntitySwitch.Case if={isAlertSelectorAvailable}>
    <Grid item xs={3}>
      <EntityGrafanaDashboardsCard />
    </Grid>
  </EntitySwitch.Case>
</EntitySwitch>
K-Phoen commented 1 year ago

Thanks! :)