Files
sm-feedback-plugin/admin.go
Jakub Zych af5d77c997 feat: G15Office job, widget settings and submissions admin, embed.js and the settings importer
- SyncG15Office files each submission as a G15Office task with its screenshot through a fetchguard client limited to the configured host; a River job with 3 attempts, PHP's messages on failure, nothing sent when unconfigured
- the replay of PHP's recorded G15Office exchange (classes/testdata) asserts the task JSON, headers and the screenshot part
- settings screen (cabana field types only), read-only submissions list, manage_settings permission and navigation
- embed.js served byte for byte at /plugins/golem15/feedback/assets/js/embed.js
- feedback:import-settings copies the WinterCMS settings row once
2026-10-04 00:22:08 +02:00

83 lines
2.8 KiB
Go

package feedback
import (
"embed"
"io/fs"
"git.golem15.com/golem15/sm-feedback-plugin/controllers"
"git.golem15.com/golem15/sm-feedback-plugin/models"
"git.golem15.com/golem15/summercms/modules/pact"
)
//go:embed controllers/submissions/config_list.yaml models/submission/columns.yaml models/settings/fields.yaml
var adminFS embed.FS
var (
_ pact.AdminAssets = (*Plugin)(nil)
_ pact.HasAdminControllers = (*Plugin)(nil)
_ pact.HasPermissions = (*Plugin)(nil)
_ pact.HasNavigation = (*Plugin)(nil)
_ pact.HasSettings = (*Plugin)(nil)
)
// AdminFS is the admin YAML: the settings form and the submissions list.
func (p *Plugin) AdminFS() fs.FS { return adminFS }
// AdminControllers is the submissions list.
func (p *Plugin) AdminControllers() []pact.AdminController {
return controllers.AdminControllers()
}
// Permissions is registerPermissions: golem15.feedback.manage_settings for
// the developer role.
func (*Plugin) Permissions() []pact.Permission {
return []pact.Permission{{
Code: controllers.PermissionManageSettings,
Tab: "golem15.feedback::lang.plugin.tab",
Label: "golem15.feedback::lang.settings.manage_settings",
Roles: []string{"developer"},
}}
}
// Navigation is the Feedback menu with its submissions entry.
func (*Plugin) Navigation() []pact.NavigationItem {
return []pact.NavigationItem{{
Code: "feedback",
Label: "golem15.feedback::lang.plugin.menu_label",
Icon: "message-square",
Permissions: []string{"golem15.feedback.*"},
Order: 600,
Controller: "golem15.feedback.submissions",
SideMenu: []pact.NavigationItem{{
Code: "submissions",
Label: "golem15.feedback::lang.submissions.menu_label",
Icon: "inbox",
Permissions: []string{controllers.PermissionManageSettings},
Controller: "golem15.feedback.submissions",
}},
}}
}
// SettingsCode is the settings screen's code. WinterCMS keys the screen
// by plugin and code ("settings"); cabana keys it by code alone across all
// plugins, so the plugin's own name keeps it apart from other plugins'.
const SettingsCode = "feedback"
// Settings is registerSettings: the widget settings singleton
// (golem15_feedback_settings) on cabana's settings screen.
func (*Plugin) Settings() []pact.SettingsItem {
return []pact.SettingsItem{{
Code: SettingsCode,
Label: "golem15.feedback::lang.settings.menu_label",
Description: "golem15.feedback::lang.settings.settings_description",
Category: "golem15.feedback::lang.plugin.tab",
Icon: "message-square",
Model: `Golem15\Feedback\Models\Settings`,
Order: 500,
Keywords: []string{"feedback", "widget", "g15office"},
Permissions: []string{controllers.PermissionManageSettings},
Form: "models/settings/fields.yaml",
NewModel: func() any { return &models.Settings{} },
}}
}