mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 12:02:30 +08:00
Actionsets: Add ability for plugins to add actions for core actionsets (i.e. folders:edit
) (#88776)
* initial commit * Action sets stored remove the dependancy for actionsets got the actionsets registered storing the permissions * fix golanglinting * remove unused struct field * wip * actionset registry for a plugin from the actionsetservice * update to make declareactionset the primary way of plugin registration and modification * declare actually extends actionsets * tests fixed * tests skipped * skip tests * skip tests * skip tests * skip tests * change to warning instead * remove step from pipeline to see if it fails due to plugin not registering * reintroduce step but remove features dependancy * add back the tests that were failing * remove comments and another skip test * fix a comment and remove unneeded changes * fix and clean up, put the behaviour behind a feature toggle * clean up * fixing tests * hard-code allowed action sets for plugins * Apply suggestions from code review Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> * small cleanup --------- Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com> Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
@ -94,6 +94,33 @@ func (r *RegisterPluginRoles) Register(ctx context.Context, p *plugins.Plugin) (
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// RegisterActionSets implements an InitializeFunc for registering plugin action sets.
|
||||
type RegisterActionSets struct {
|
||||
log log.Logger
|
||||
actionSetRegistry plugins.ActionSetRegistry
|
||||
}
|
||||
|
||||
// RegisterActionSetsStep returns a new InitializeFunc for registering plugin action sets.
|
||||
func RegisterActionSetsStep(actionRegistry plugins.ActionSetRegistry) initialization.InitializeFunc {
|
||||
return newRegisterActionSets(actionRegistry).Register
|
||||
}
|
||||
|
||||
func newRegisterActionSets(registry plugins.ActionSetRegistry) *RegisterActionSets {
|
||||
return &RegisterActionSets{
|
||||
log: log.New("plugins.actionsets.registration"),
|
||||
actionSetRegistry: registry,
|
||||
}
|
||||
}
|
||||
|
||||
// Register registers the plugin action sets.
|
||||
func (r *RegisterActionSets) Register(ctx context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
if err := r.actionSetRegistry.RegisterActionSets(ctx, p.ID, p.ActionSets); err != nil {
|
||||
r.log.Warn("Plugin action set registration failed", "pluginId", p.ID, "error", err)
|
||||
return nil, err
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// ReportBuildMetrics reports build information for all plugins, except core and bundled plugins.
|
||||
func ReportBuildMetrics(_ context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
if !p.IsCorePlugin() && !p.IsBundledPlugin() {
|
||||
|
Reference in New Issue
Block a user