feat(cabana): read-only Plugins screen with installed plugins
- GET /plugins (backend.view_plugins, superusers always pass) lists the plugins from party.Installed, or party.Activated IDs for older builds, with the built framework version and whether the registry is configured - Settings -> System -> Plugins entry with the new SettingsEntry.path, added only for principals allowed to open it - PluginsView at /system/plugins with an Installed tab (reka-ui Tabs); settings panel, rail, breadcrumbs and page title know the route - OpenAPI and SPA types regenerated; contract, token-class and conformance inventories list the route; en/pl strings; docs
This commit is contained in:
@@ -32,6 +32,9 @@ type SettingsEntry struct {
|
||||
// Controller is the admin controller a link entry opens; empty for a
|
||||
// singleton settings form.
|
||||
Controller string `json:"controller"`
|
||||
// Path is the admin SPA route an entry of the admin's own opens (the
|
||||
// Plugins screen, /system/plugins); omitted for plugin entries.
|
||||
Path string `json:"path,omitempty"`
|
||||
}
|
||||
|
||||
// Metadata returns only entries the backend principal may open. Denied
|
||||
@@ -103,6 +106,13 @@ func (r *Registry) Metadata(ctx context.Context, principal *bouncer.Principal, t
|
||||
Controller: item.Controller,
|
||||
})
|
||||
}
|
||||
if r.listsPluginsScreen(principal) {
|
||||
settings = append(settings, pluginsSettingsEntry(
|
||||
translateKey(ctx, tr, "backend::lang.plugins.menu_label"),
|
||||
translateKey(ctx, tr, "backend::lang.plugins.menu_description"),
|
||||
translateKey(ctx, tr, "backend::lang.settings.category_system"),
|
||||
))
|
||||
}
|
||||
sort.SliceStable(settings, func(i, j int) bool {
|
||||
if settings[i].Order == settings[j].Order {
|
||||
return settings[i].Code < settings[j].Code
|
||||
@@ -112,6 +122,20 @@ func (r *Registry) Metadata(ctx context.Context, principal *bouncer.Principal, t
|
||||
return navigation, settings
|
||||
}
|
||||
|
||||
// listsPluginsScreen reports whether the settings list links the Plugins
|
||||
// screen for principal: the admin's own screens are compiled (they declare
|
||||
// PermissionViewPlugins), no plugin took the settings code "plugins", and
|
||||
// the principal may open the screen.
|
||||
func (r *Registry) listsPluginsScreen(principal *bouncer.Principal) bool {
|
||||
if _, declared := r.permissions[PermissionViewPlugins]; !declared {
|
||||
return false
|
||||
}
|
||||
if _, taken := r.settings[pluginsSettingsCode]; taken {
|
||||
return false
|
||||
}
|
||||
return Allows(principal, []string{PermissionViewPlugins})
|
||||
}
|
||||
|
||||
// openableTarget returns the controller a main item should link to. It is the
|
||||
// item's own controller unless the principal cannot open it or it is the
|
||||
// controller of a side item hidden for this request (in hidden), in which
|
||||
|
||||
Reference in New Issue
Block a user