Closed Gowee closed 3 years ago
PanelPlugin.setOptions
comes with PanelOptionsEditorBuilder.addCustomEditor
which preserves most of the flexibility of PanelPlugin.setEditor
. So the limitation does not exist.
Fixed in the new release v0.3.0-beta. #7
Starting Grafana 7.0,
PanelPlugin.setEditor
andPanelPlugin.setDefaults
are deprecated in favor ofPanelPlugin.setOptions
. The former two are the imperative way to write an option configurator. On the contrary, the latter is the newly-introduced declarative way.The imperative way allows writing a fairly flexible UI, just like writing a normal HTML form, of the option configurator while bringing much hassle in maintaining the UI styles/components consistent with those provided by
@grafana/ui
.The declarative way solves the problem by allowing specifying each field structurally with its name, description, type, and default value. But at same the time, it prevents the inherent flexibility.
Upon initiating, the project is at the stage where Grafana was migrating from 6.x to 7.x. At first, the panel was started with the boilerplate project depending on Grafana 7.0 which was not released yet at that time (https://github.com/grafana/grafana-starter-panel/issues/18#issuecomment-621807016). To avoid incompatibility, the project was reverted to an older commit of the boilerplate by https://github.com/Gowee/traceroute-map-panel/commit/acd2df0e0ad0985bcc83ad4880f25a67fb1354a0, resulting in the fact that the old
PanelPlugin.{setEditor,setDefaults}
were kept.To handle the complex tagged-union-style GeoIPProvider option https://github.com/Gowee/traceroute-map-panel/blob/8aa886c1cf9cffd38a6caefc4065a637d11bd423/src/types.ts#L21, the current implementation uses a select with dynamic text inputs https://github.com/Gowee/traceroute-map-panel/commit/85e79f935d8e864053a5d2a202f9d97d5a0f636c which appears to be infeasible with the new declarative
PanelPlugin.setOptions
.As is reported in issue #4,
PanelPlugin.setEditor
andPanelPlugin.setDefaults
turn to be unavailable even though it is just marked as deprecated (instead of removed). So it is inevitable to migrate toPanelPlugin.setOptions
.After the migration, the
custom-api
andcustom-function
might be removed due to the limitation of fields. Nevertheless, how to allow specifying a token (e.g. foripinfo
)?