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

Azure Monitor: Fix subscription selector when changing data sources #56284

Merged
merged 4 commits into from Oct 5, 2022

Conversation

andresmgot
Copy link
Contributor

What this PR does / why we need it:

When changing the data source, the list of subscriptions will change. This PR includes two fixes to adapt the Azure Resource Graph editor to that situation:

  • useRef does not change when using the editor in the template variable section (because the editor does not get re-mounted). I have changed that solution to use useMemo instead.
  • I changed the logic so if the new list of subscriptions does not contain the ones in the query, it removes the ones that are not available.
Screencast.from.04-10-22.12.47.35.webm

Which issue(s) this PR fixes:

Fixes #55193

Special notes for your reviewer:

@andresmgot andresmgot added add to changelog backport v9.1.x Bot will automatically open backport PR backport v9.2.x Mark PR for automatic backport to v9.2.x labels Oct 4, 2022
@andresmgot andresmgot added this to the 9.1.8 milestone Oct 4, 2022
@andresmgot andresmgot requested a review from a team as a code owner October 4, 2022 11:03
@andresmgot andresmgot requested review from asimpson and aangelisc and removed request for a team October 4, 2022 11:03
@grafanabot grafanabot added datasource/Azure Azure Monitor Datasource area/frontend labels Oct 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

Backend code coverage report for PR #56284
No changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

Frontend code coverage report for PR #56284

Plugin Main PR Difference
grafana-azure-monitor-datasource 76.27% 76.27% 0%

@grafanabot
Copy link
Contributor

Copy link
Contributor

@aangelisc aangelisc left a comment

Choose a reason for hiding this comment

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

Great work! A really nice touch with checking on the intersection of subscriptions 👍

});
render(<ArgQueryEditor {...defaultProps} onChange={onChange} query={query} />);
expect(await screen.findByTestId('azure-monitor-arg-query-editor-with-experimental-ui')).toBeInTheDocument();
expect(onChange).not.toHaveBeenCalledWith(expect.objectContaining({ subscriptions: ['foo'] }));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This assertion is unneeded as there's no reference to subscriptions: ['foo'] in this test.

@grafanabot
Copy link
Contributor

@andresmgot andresmgot merged commit 2cdbd05 into main Oct 5, 2022
@andresmgot andresmgot deleted the azMonARGSubs branch October 5, 2022 14:59
grafanabot pushed a commit that referenced this pull request Oct 5, 2022
grafanabot pushed a commit that referenced this pull request Oct 5, 2022
andresmgot added a commit that referenced this pull request Oct 6, 2022
…56284) (#56409)

(cherry picked from commit 2cdbd05)

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
papagian pushed a commit that referenced this pull request Oct 11, 2022
…56284) (#56408)

(cherry picked from commit 2cdbd05)

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend backport v9.1.x Bot will automatically open backport PR backport v9.2.x Mark PR for automatic backport to v9.2.x datasource/Azure Azure Monitor Datasource enterprise-failed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Monitor: ARG template variable not updating sub picker values when switching amongst Azure Monitor ds
3 participants