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

App Plugins: support react pages and tabs #16586

Merged
merged 53 commits into from
May 2, 2019

Conversation

ryantxu
Copy link
Member

@ryantxu ryantxu commented Apr 15, 2019

fixes #16433

This issue has grown as I keep poking on it. I'm not sure if I should split it up or just keep it together. Let me know what makes sense.

This PR includes:

  • AppRootPage: a single component that gets all request to /a/{plugin-id/*
  • PluginConfigTab: a way for apps (and eventually datasources, maybe panels) to add a tab on the existing plugin page
  • Migrates the angular PluginEditCtrl to react PluginPage. edit has always felt funny for everything except apps, since it just shows the readme. I took "edit" out of the URL
  • Loads the existing app ConfigCtrl within the react tabs -- seems to work!
  • migrated angular DashImportListCtrl to react DashboardImporter. Only used for apps right now
  • improved the PluginMeta to support the properties used by these pages. specifically dependencies and secureJsonData

I think it is close to ready to go, but would love someone else with apps to test it :)

Screenshots:
image

image

The app is configured with:

export const plugin = new AppPlugin()
  .setRootPage(ExampleRootPage)
  .addConfigTab({
    title: 'Tab 1',
    icon: 'fa fa-info',
    body: ExampleTab1,
    id: 'tab1',
  })
  .addConfigTab({
    title: 'Tab 2',
    icon: 'fa fa-user',
    body: ExampleTab2,
    id: 'tab2',
  });

TODO:

  • Open popup after clicking 'Update Available!' blocker
  • Maybe someone with more react skilz should thunkify PluginDashboards.tsx and/or merge it with DataSourceDashboards.tsx
  • Once OK, remove

* grafana/master:
  Update jwt regexp to include = (grafana#16521)
  Chore: docs fixes underscore formatting (grafana#16516)
  Fix: Pass missing maxDataPoints to query in Explore (grafana#16513)
  Fix: Recalculate intervals in Explore on run queries (grafana#16510)
  devenv: add elasticsearch v6 filebeat integration (grafana#16493)
  devenv: add worldmap panel panels for elasticsearch (grafana#16313)
@ryantxu
Copy link
Member Author

ryantxu commented Apr 15, 2019

Consider: #16528 (comment) when looking at the constructor

* grafana/master:
  Panel Plugins: pass query request/response to react panel plugins (grafana#16577)
  Explore: Adds logs highlighting in Explore on keypress (grafana#16596)
  Build: adding dependency used by extensions (grafana#16622)
  TimePicker: Re-add apply button in time picker (grafana#16619)
  Chore: refactor auth proxy (grafana#16504)
  Docs: updated help for changelog cli task (grafana#16615)
  replace dep with go modules (grafana#16017)
  Docs: Updated changelog for 6.1.4
  Heatmap: Fixed auto decimals when bucket name is not number but contains dots, fixes grafana#13019 (grafana#16609)
  build: partially replace gometalinter with golangci-lint (grafana#16610)
  Explore & Dashboard: New Refresh picker (grafana#16505)
* grafana/master:
  PanelQueryRunner: move error handling to QueryRunnerOptions (grafana#16654)
  refactor: Merge PanelChrome and DataPanel, do query execution in PanelQueryRunner (grafana#16632)
  Search: Fixed search issue introduced in recent PR (grafana#16652)
  Cloudwatch: fix for flaky tests (grafana#16649)
  UI: Remove old icons (grafana#16335)
  Search: Fixes search limits and adds a page parameter (grafana#16458)
  Chore: Upgrade lodash to v4.17.11 (grafana#16645)
  Chore: Lock dependencies (grafana#16644)
  tech: replace bmizerany/assert with stretchr/testify (grafana#16625)
  Chore: update yarn.lock (grafana#16637)
* grafana/master:
  build: restore postgres integration tests (grafana#16801)
  docs: explain correct access control model of GCS buckets (grafana#16792)
  Chore: Fixed no implicit any Typescript errors (grafana#16799)
  Feature: introduce LdapActiveSyncEnabled setting (grafana#16787)
  Plugins: ReactPanelPlugin to VizPanelPlugin (grafana#16779)
  UX: Improve Grafana usage for smaller screens  (grafana#16783)
  ThresholdEditor: Minor style fix for smaller screens (grafana#16791)
  Build: Use isolated modules for ts-jest (grafana#16786)
  LDAP Refactoring to support syncronizing more than one user at a time. (grafana#16705)
  build: removes unused vendored files
  (fix/explore): remove vertical-align looks better for long logs (grafana#16736)
  Chore: bump jQuery to 3.4.0 in grafana/ui (grafana#16781)
  Devenv: Updated home dashboard and added new influxdb test dashboard
  Chore: Lowered implicit anys limit to 5946
  RefreshPicker: minor design update (grafana#16774)
* grafana/master:
  Plugins: rename vizPlugin to panelPlugin (grafana#16802)
  Plugins: move app/feature/plugin properties into PluginMeta (grafana#16809)
  Plugins: move PanelPluginMeta to grafana/ui (grafana#16804)
  Plugins: move datasource specific meta out of the main meta type (grafana#16803)
  updates changelog for 6.1.6
  Fix: Fetch histogram series from other api route (grafana#16768)
  phantomjs: set web-security to true
  Chore: Lowered implicit anys limit to 5668
@ryantxu ryantxu marked this pull request as ready for review May 1, 2019 22:06
src: 'public/app/features/plugins/partials/update_instructions.html',
scope: modalScope,
});
};
Copy link
Member Author

Choose a reason for hiding this comment

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

@torkelo -- this is my one real blocker, everything else just needs testing from someone else running apps :)

Any ideas? is there a way to make a new $scope? or to show-modal with a react component? update_instructions would be pretty easy to convert

@ryantxu ryantxu changed the title WIP: support react pages for apps App Plugins: support react pages and tabs May 1, 2019
@ryantxu ryantxu requested a review from torkelo May 1, 2019 22:42
@ryantxu
Copy link
Member Author

ryantxu commented May 1, 2019

It would be great to get help testing this from someone running a bunch of plugins and apps. This keeps still has both versions running so it is easy to compare:

New: React:
http://localhost:3333/plugins/example-app/

Old: Angular:
http://localhost:3333/plugins/example-app/edit

ryantxu and others added 6 commits May 2, 2019 08:45
* grafana/master:
  Datasources: add support for POST HTTP verb for InfluxDB (grafana#16690)
  Add pattern validation in configs (grafana#16837)
  Search: Enable filtering dashboards in search by current folder (grafana#16790)
  FormLabel: allow any rather than just a string for tooltip (grafana#16841)
* grafana/master:
  Add Windows MSI generation to build process (grafana#16502)
…ct-app-pages

* 'react-app-pages' of github.com:ryantxu/grafana:
  Apps: Fix showing update instructions modal
@ryantxu
Copy link
Member Author

ryantxu commented May 2, 2019

I think this is ready to go -- maybe someone with more react skilz should thunkify PluginDashboards.tsx and/or merge it with DataSourceDashboards.tsx, but I think that could happen later.

The part I think needs testing is the config page of existing apps. It works fine for everything I have tried, but if apps got sneaky with the ConfigCtrl it may not work now.

We should keep the concept of AppRootPage and ConfgTabs alpha for now, so I don't think this has anything we need to report externally yet.

Copy link
Member

@torkelo torkelo left a comment

Choose a reason for hiding this comment

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

Looks good, great work! tested with Wordping & percona app & example app

@ryantxu ryantxu merged commit 013f1b8 into grafana:master May 2, 2019
@ryantxu ryantxu deleted the react-app-pages branch May 2, 2019 17:15
@ryantxu
Copy link
Member Author

ryantxu commented May 2, 2019

@daniellee @briangann -- this PR changed the container for app ConfigCtrl elements to react. Before 6.2, it would be good to check any apps you have on your systems to make sure they still work as expected :)

ryantxu added a commit to ryantxu/grafana that referenced this pull request May 2, 2019
* grafana/master:
  App Plugins: support react pages and tabs (grafana#16586)
ryantxu added a commit to ryantxu/grafana that referenced this pull request May 3, 2019
* grafana/master:
  Chore: Lowered implicit anys limit to 5623
  TestData: Add dashboards to testdata (grafana#16855)
  Input Datasource: convert from angular config to react ConfigEditor (grafana#16856)
  DataSources: minor typescript cleanups and comments (grafana#16860)
  TestDataDatasource: Add config editor (grafana#16861)
  App Plugins: support react pages and tabs (grafana#16586)
  Add Windows MSI generation to build process (grafana#16502)
  Datasources: add support for POST HTTP verb for InfluxDB (grafana#16690)
  Add pattern validation in configs (grafana#16837)
  Search: Enable filtering dashboards in search by current folder (grafana#16790)
ryantxu added a commit to ryantxu/grafana that referenced this pull request May 3, 2019
…MetricPanelCtrl

* grafana/master: (24 commits)
  CSV: escape quotes in toCSV  (grafana#16874)
  Dashboard: Lazy load out of view panels (grafana#15554)
  LDAP: Added reload endpoint for LDAP config (grafana#15470)
  PluginsList: Removed icons and updated snapshots (grafana#16872)
  Panels: Fixed issue with panel type change and data updates (grafana#16871)
  Chore: fix modes for non-executable files (grafana#16864)
  DataSourceSettings: Minor fix for uncontrolled input (grafana#16863)
  Chore: Lowered implicit anys limit to 5623
  TestData: Add dashboards to testdata (grafana#16855)
  Input Datasource: convert from angular config to react ConfigEditor (grafana#16856)
  DataSources: minor typescript cleanups and comments (grafana#16860)
  TestDataDatasource: Add config editor (grafana#16861)
  App Plugins: support react pages and tabs (grafana#16586)
  Add Windows MSI generation to build process (grafana#16502)
  Datasources: add support for POST HTTP verb for InfluxDB (grafana#16690)
  Add pattern validation in configs (grafana#16837)
  Search: Enable filtering dashboards in search by current folder (grafana#16790)
  FormLabel: allow any rather than just a string for tooltip (grafana#16841)
  prometheus: fix regression after adding support for tracing headers (grafana#16829)
  area/circleci: Speed up circleci build process for branches and pr (grafana#16778)
  ...
ryantxu added a commit to ryantxu/grafana that referenced this pull request May 3, 2019
* grafana/master: (44 commits)
  CSV: escape quotes in toCSV  (grafana#16874)
  Dashboard: Lazy load out of view panels (grafana#15554)
  LDAP: Added reload endpoint for LDAP config (grafana#15470)
  PluginsList: Removed icons and updated snapshots (grafana#16872)
  Panels: Fixed issue with panel type change and data updates (grafana#16871)
  Chore: fix modes for non-executable files (grafana#16864)
  DataSourceSettings: Minor fix for uncontrolled input (grafana#16863)
  Chore: Lowered implicit anys limit to 5623
  TestData: Add dashboards to testdata (grafana#16855)
  Input Datasource: convert from angular config to react ConfigEditor (grafana#16856)
  DataSources: minor typescript cleanups and comments (grafana#16860)
  TestDataDatasource: Add config editor (grafana#16861)
  App Plugins: support react pages and tabs (grafana#16586)
  Add Windows MSI generation to build process (grafana#16502)
  Datasources: add support for POST HTTP verb for InfluxDB (grafana#16690)
  Add pattern validation in configs (grafana#16837)
  Search: Enable filtering dashboards in search by current folder (grafana#16790)
  FormLabel: allow any rather than just a string for tooltip (grafana#16841)
  prometheus: fix regression after adding support for tracing headers (grafana#16829)
  area/circleci: Speed up circleci build process for branches and pr (grafana#16778)
  ...
@bergquist bergquist added this to the 6.2-beta1 milestone May 8, 2019
@tharinduc
Copy link

Hi @ryantxu ,

How can I use this fix of plugins with tabs as navigation in my AngularJs plugins? I recently joined a new company and they have a requirement like this but they have all their plugins built using AngularJs.

@torkelo
Copy link
Member

torkelo commented Sep 4, 2019

we only support react plugins for this

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.

Migrate app pages to react
4 participants