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

SingleStat: add a gauge migration call to action button in the editor #18604

Merged
merged 10 commits into from
Aug 18, 2019

Conversation

ryantxu
Copy link
Member

@ryantxu ryantxu commented Aug 16, 2019

First step towards #14554

This adds a notice to the singlestat panel asking to be migrated to gauge:
image

TODO: Help wanted!

  • actually migrate! how do we get an event from angular to react context?
  • refine language / wording
  • Add warnings that some settings will be lost: (when configured)
    • singlestat
    • prefix / suffix
    • datalink


// debugger;
// const panel = this.panel as PanelModel;
// importPanelPlugin('gauge').then( gauge => {
Copy link
Member Author

Choose a reason for hiding this comment

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

this does not work... we need the DashboardPanel to call its update function

I'm not sure how to best get an event there

@torkelo
Copy link
Member

torkelo commented Aug 17, 2019

Made some progress. Figured out a way to trigger panel plugin type change from within an angular panel and made a start on the migration. But then I discovered that the migration handler is not executed on panel type change only on plugin load.

So might have to change something in how the migration handler is executed or trigger it from the angular code before panel change.

@ryantxu
Copy link
Member Author

ryantxu commented Aug 18, 2019

Excellent -- works great. I changed from using the

  .setMigrationHandler(gaugePanelMigrationCheck);

To:

  .setPanelChangeHandler(gaugePanelChangedCheck)

And then needed to rework how the change hander gets triggered so that it passes angular properties along

@@ -165,7 +165,7 @@ describe('PanelModel', () => {
it('should call react onPanelTypeChanged', () => {
expect(onPanelTypeChanged.mock.calls.length).toBe(1);
expect(onPanelTypeChanged.mock.calls[0][1]).toBe('table');
expect(onPanelTypeChanged.mock.calls[0][2].fieldOptions).toBeDefined();
expect(onPanelTypeChanged.mock.calls[0][2].angular).toBeDefined();
Copy link
Member Author

Choose a reason for hiding this comment

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

This changes the test to make sure an angular object is passed to it.

I don't think the previous expectation is correct -- the old properties when changing from an angular panel would never have fieldOptons, but the setup (changed in the PR) applied defaults before asking the onPanelTypeChanged callback what it should do

// switch
this.type = pluginId;
this.plugin = newPlugin;
this.applyPluginOptionDefaults(newPlugin);
Copy link
Member Author

Choose a reason for hiding this comment

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

Biggest change here is that applyPluginOptionDefaults is called after newPlugin.onPanelTypeChanged

This also passes the whole panel object in when switching from angular panels (the angular options are not really stored on oldOptions.options, rather in oldOptions directly)

@ryantxu ryantxu changed the title WIP: add a gauge migration button to singlestat panel SingleStatt: add a gauge migration button to singlestat panel Aug 18, 2019
@ryantxu ryantxu changed the title SingleStatt: add a gauge migration button to singlestat panel SingleStat: add a gauge migration call to action button in the editor Aug 18, 2019
@ryantxu ryantxu merged commit 21948e8 into grafana:master Aug 18, 2019
@ryantxu ryantxu deleted the singlestat-to-gauge branch August 18, 2019 22:01
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 18, 2019
…rame

* grafana/master:
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
  Docker: switch docker image to alpine base with phantomjs support (grafana#18468)
  Backend: Adds support for HTTP/2 (grafana#18358)
  Explore: Fixes error when switching from prometheus to loki data sources (grafana#18599)
  TimePicker: Set time to to 23:59:59 when setting To time using calendar (grafana#18595)
  Prometheus: Return labels in query results (grafana#18535)
  Docs: Update changelog and docs for annotation region change (grafana#18593)
  Refactor: move KeyValue and deprecation warning to @grafana/data (grafana#18582)
  Annotations: use a single row to represent a region (grafana#17673)
  Docs: Update upgrading guide (grafana#18547)
  Docs: Adds tests requirement to bugs checklist (grafana#18576)
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 18, 2019
* grafana/master:
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
  Docker: switch docker image to alpine base with phantomjs support (grafana#18468)
  Backend: Adds support for HTTP/2 (grafana#18358)
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 18, 2019
* grafana/master:
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 19, 2019
* grafana/master: (202 commits)
  Azure Monitor and Log Analytics converted and separated into components (grafana#18259)
  Rewrite user profile edit to react (grafana#17917)
  Docs: remove codecov badge (grafana#18623)
  Prometheus: Prevents panel editor crash when switching to Prometheus datasource (grafana#18616)
  Chore: Rename Popper to Popover (grafana#18543)
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
  Docker: switch docker image to alpine base with phantomjs support (grafana#18468)
  Backend: Adds support for HTTP/2 (grafana#18358)
  Explore: Fixes error when switching from prometheus to loki data sources (grafana#18599)
  TimePicker: Set time to to 23:59:59 when setting To time using calendar (grafana#18595)
  Prometheus: Return labels in query results (grafana#18535)
  Docs: Update changelog and docs for annotation region change (grafana#18593)
  Refactor: move KeyValue and deprecation warning to @grafana/data (grafana#18582)
  Annotations: use a single row to represent a region (grafana#17673)
  Docs: Update upgrading guide (grafana#18547)
  Docs: Adds tests requirement to bugs checklist (grafana#18576)
  DataFrame: convert from row based to a columnar value format (grafana#18391)
  Packages: Temporarily skip canary releases if packages build fail (grafana#18577)
  ...
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 21, 2019
* grafana/master:
  SingleStat: use DataFrame results rather than TimeSeries/TableData (grafana#18580)
  TestData: attach labels to series results (grafana#18653)
  Singlestat: Disable new singlestat gauge usage (grafana#18610)
  Explore: Fixes query field layout in splitted view for Safari browsers (grafana#18654)
  MSI: new long file names are causing error building MSI (grafana#18646)
  Auth: change the error HTTP status codes (grafana#18584)
  Refactor: EmptyListCTA (grafana#18516)
  Build: Upgrade to go 1.12.9 (grafana#18638)
  Chore: Revert React 16.9.0 bump (grafana#18634)
  Azure Monitor and Log Analytics converted and separated into components (grafana#18259)
  Rewrite user profile edit to react (grafana#17917)
  Docs: remove codecov badge (grafana#18623)
  Prometheus: Prevents panel editor crash when switching to Prometheus datasource (grafana#18616)
  Chore: Rename Popper to Popover (grafana#18543)
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
ryantxu added a commit to ryantxu/grafana that referenced this pull request Aug 23, 2019
* grafana/master:
  SingleStat2: save options to defaults not override (grafana#18666)
  Packages: Fix path import from grafana/data (grafana#18667)
  SingleStat: use DataFrame results rather than TimeSeries/TableData (grafana#18580)
  TestData: attach labels to series results (grafana#18653)
  Singlestat: Disable new singlestat gauge usage (grafana#18610)
  Explore: Fixes query field layout in splitted view for Safari browsers (grafana#18654)
  MSI: new long file names are causing error building MSI (grafana#18646)
  Auth: change the error HTTP status codes (grafana#18584)
  Refactor: EmptyListCTA (grafana#18516)
  Build: Upgrade to go 1.12.9 (grafana#18638)
  Chore: Revert React 16.9.0 bump (grafana#18634)
  Azure Monitor and Log Analytics converted and separated into components (grafana#18259)
  Rewrite user profile edit to react (grafana#17917)
  Docs: remove codecov badge (grafana#18623)
  Prometheus: Prevents panel editor crash when switching to Prometheus datasource (grafana#18616)
  Chore: Rename Popper to Popover (grafana#18543)
  SingleStat: add a gauge migration call to action button in the editor (grafana#18604)
  Build: update revive dependency (grafana#18585)
  LDAP: multildap + ldap integration (grafana#18588)
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

Successfully merging this pull request may close these issues.

None yet

2 participants