Plugins: Support for link extensions (#61663)

* added extensions to plugin.json and exposing it via frontend settings.

* added extensions to the plugin.json schema.

* changing the extensions in frontend settings to a map instead of an array.

* wip

* feat(pluginregistry): begin wiring up registry

* feat(pluginextensions): prevent duplicate links and clean up

* added test case for link extensions.

* added tests and implemented the getPluginLink function.

* wip

* feat(pluginextensions): expose plugin extension registry

* fix(pluginextensions): appease the typescript gods post rename

* renamed file and will throw error if trying to call setExtensionsRegistry if trying to call it twice.

* added reafactorings.

* fixed failing test.

* minor refactorings to make sure we only include extensions if the app is enabled.

* fixed some nits.

* Update public/app/features/plugins/extensions/registry.test.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update packages/grafana-runtime/src/services/pluginExtensions/registry.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update packages/grafana-runtime/src/services/pluginExtensions/registry.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update public/app/features/plugins/extensions/registry.test.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Moved types for extensions from data to runtime.

* added a small example on how you could consume link extensions.

* renamed after feedback from levi.

* updated the plugindef.cue.

* using the generated plugin def.

* added tests for apps and extensions.

* fixed linting issues.

* wip

* wip

* wip

* wip

* test(extensions): fix up failing tests

* feat(extensions): freeze registry extension arrays, include type in registry items

* added restrictions in the pugindef cue schema.

* wip

* added required fields.

* added key to uniquely identify each item.

* test(pluginextensions): align tests with implementation

* chore(schema): refresh reference.md

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
Marcus Andersson
2023-02-07 17:20:05 +01:00
committed by GitHub
co-authored by Levente Balogh Jack Westbrook
parent 8a94688114
commit 1cfd3f81fb
24 changed files with 812 additions and 98 deletions
+22 -5
View File
@@ -1,9 +1,9 @@
package plugindef
import (
"strings"
"regexp"
"strings"
"github.com/grafana/thema"
)
@@ -122,6 +122,23 @@ seqs: [
...
}
#ExtensionsLink: {
// Target where the link will be rendered
target: =~"^(plugins|grafana)\/[a-z-/0-9]*$"
// Type of extension
type: "link"
// Title that will be displayed for the rendered link
title: string & strings.MinRunes(3) & strings.MaxRunes(22)
// Description for the rendered link
description: string & strings.MaxRunes(200)
// Path relative to the extending plugin e.g. /incidents/declare
path: =~"^\/.*"
...
}
// Extensions made by the current plugin.
extensions?: [...#ExtensionsLink]
// For data source plugins, if the plugin supports logs.
logs?: bool
@@ -175,9 +192,9 @@ seqs: [
// each of which has an action and an optional scope.
// Example: the role 'Schedules Reader' bundles permissions to view all schedules of the plugin.
#Role: {
name: string,
name: =~"^([A-Z][0-9A-Za-z ]+)$"
description: string,
name: string
name: =~"^([A-Z][0-9A-Za-z ]+)$"
description: string
permissions: [...#Permission]
}