PluginExtensions: Added support for sharing functions (#98888)

* feat: add generic plugin extension functions

* updated betterer.

* Fixed type issues after sync with main.

* Remved extensions from datasource and panel.

* Added validation for extension function registry.

* Added tests and validation logic for function extensions registry.

* removed prop already existing on base.

* fixed lint error.

---------

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
This commit is contained in:
Dominik Süß
2025-02-13 10:18:55 +01:00
committed by GitHub
parent fbf96916aa
commit 8a8e47fcea
40 changed files with 1182 additions and 69 deletions

View File

@ -56,6 +56,7 @@ func Test_ReadPluginJSON(t *testing.T) {
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -108,8 +109,10 @@ func Test_ReadPluginJSON(t *testing.T) {
Name: "Pie Chart (old)",
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -143,8 +146,10 @@ func Test_ReadPluginJSON(t *testing.T) {
Type: TypeDataSource,
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -188,6 +193,9 @@ func Test_ReadPluginJSON(t *testing.T) {
"id": "myorg-extensions-app/component-1/v1"
}
],
"addedFunctions": [
{"targets": ["foo/bar"], "title":"some hook"}
],
"extensionPoints": [
{
"title": "Extension point 1",
@ -209,6 +217,7 @@ func Test_ReadPluginJSON(t *testing.T) {
{Title: "Added link 1", Description: "Added link 1 description", Targets: []string{"grafana/dashboard/panel/menu"}},
},
AddedComponents: []AddedComponent{
{Title: "Added component 1", Description: "Added component 1 description", Targets: []string{"grafana/user/profile/tab"}},
},
ExposedComponents: []ExposedComponent{
@ -217,6 +226,9 @@ func Test_ReadPluginJSON(t *testing.T) {
ExtensionPoints: []ExtensionPoint{
{Id: "myorg-extensions-app/extensions-point-1/v1", Title: "Extension point 1", Description: "Extension points 1 description"},
},
AddedFunctions: []AddedFunction{
{Targets: []string{"foo/bar"}, Title: "some hook"},
},
},
Dependencies: Dependencies{
@ -271,6 +283,7 @@ func Test_ReadPluginJSON(t *testing.T) {
AddedComponents: []AddedComponent{
{Title: "Added component 1", Description: "Added component 1 description", Targets: []string{"grafana/user/profile/tab"}},
},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -301,8 +314,10 @@ func Test_ReadPluginJSON(t *testing.T) {
Type: TypeApp,
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -332,8 +347,10 @@ func Test_ReadPluginJSON(t *testing.T) {
Type: TypeApp,
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},
@ -371,6 +388,7 @@ func Test_ReadPluginJSON(t *testing.T) {
Extensions: Extensions{
AddedLinks: []AddedLink{},
AddedComponents: []AddedComponent{},
AddedFunctions: []AddedFunction{},
ExposedComponents: []ExposedComponent{},
ExtensionPoints: []ExtensionPoint{},
},