ui

package
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PermissionSelector

func PermissionSelector(data PermissionSelectorData) g.Node

PermissionSelector renders a permission multi-select component.

func RoleForm

func RoleForm(data RoleFormData) g.Node

RoleForm renders a form for creating/editing a role.

func RoleListTable

func RoleListTable(data RoleListTableData) g.Node

RoleListTable renders a table of roles with actions.

func RoleManagementInterface

func RoleManagementInterface(data RoleManagementInterfaceData) g.Node

RoleManagementInterface renders the complete role management UI.

Types

type BridgeFunction added in v0.0.15

type BridgeFunction struct {
	// Name is the function name (will be prefixed with extensionID, e.g., "cms.getEntries")
	Name string

	// Handler is the function that handles the bridge call
	// Signature: func(ctx bridge.Context, input T) (output U, error)
	// The handler receives typed input and returns typed output with error handling
	Handler any

	// Description for documentation/debugging
	Description string

	// Options for bridge registration (auth requirements, rate limiting, etc.)
	// Use bridge.RequireAuth(), bridge.RequireRoles("admin"), etc.
	Options []any // Will be bridge.Option from forgeui/bridge
}

BridgeFunction represents a bridge function that extensions can register Bridge functions are callable from the frontend using $bridge.call('extensionID.functionName', params).

type DashboardExtension

type DashboardExtension interface {
	// ExtensionID returns a unique identifier for this extension
	ExtensionID() string

	// NavigationItems returns navigation items to register
	NavigationItems() []NavigationItem

	// Routes returns routes to register under /dashboard/app/:appId/
	Routes() []Route

	// SettingsSections returns settings sections to add to the settings page
	// Deprecated: Use SettingsPages() instead for full-page settings
	// Returns a list of setting section renderers
	SettingsSections() []SettingsSection

	// SettingsPages returns full settings pages to add to the settings sidebar
	// These pages get their own routes and full-page layouts
	SettingsPages() []SettingsPage

	// DashboardWidgets returns widgets to show on the main dashboard
	// These appear as cards on the dashboard home page
	DashboardWidgets() []DashboardWidget

	// BridgeFunctions returns bridge functions to register
	// Functions are automatically namespaced with extension ID (e.g., "cms.getContentTypes")
	// Frontend can call these using: await $bridge.call('cms.getContentTypes', { appId: 'xxx' })
	BridgeFunctions() []BridgeFunction
}

DashboardExtension is the interface that plugins implement to extend the dashboard.

type DashboardWidget

type DashboardWidget struct {
	// ID is a unique identifier for this widget
	ID string
	// Title is the widget title
	Title string
	// Icon is an optional icon
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// Size determines the widget size (1 = 1 column, 2 = 2 columns, etc.)
	Size int
	// Renderer renders the widget content
	Renderer func(basePath string, currentApp *app.App) g.Node
}

DashboardWidget represents a widget on the dashboard home page.

type NavigationItem struct {
	// ID is a unique identifier for this nav item (e.g., "multisession")
	ID string
	// Label is the display text for the link
	Label string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Position determines where the nav item appears
	Position NavigationPosition
	// Order determines the display order within the position (lower = first)
	Order int
	// URLBuilder builds the URL for this nav item given the current app
	// Example: func(basePath string, app *app.App) string {
	//   return basePath + "/dashboard/app/" + app.ID.String() + "/multisession"
	// }
	URLBuilder func(basePath string, currentApp *app.App) string
	// ActiveChecker returns true if this nav item is currently active
	// Example: func(activePage string) bool { return activePage == "multisession" }
	ActiveChecker func(activePage string) bool
	// RequiresPlugin optionally specifies a plugin ID that must be enabled
	RequiresPlugin string
	// PermissionRequired optionally specifies a permission required to see this item
	PermissionRequired string
}

NavigationItem represents a navigation link registered by a plugin.

type NavigationPosition string

NavigationPosition defines where a navigation item should be placed.

const (
	// NavPositionMain places the item in the main navigation bar.
	NavPositionMain NavigationPosition = "main"
	// NavPositionSettings places the item in the settings section.
	NavPositionSettings NavigationPosition = "settings"
	// NavPositionUserDropdown places the item in the user dropdown menu.
	NavPositionUserDropdown NavigationPosition = "user_dropdown"
	// NavPositionFooter places the item in the footer.
	NavPositionFooter NavigationPosition = "footer"
)

type OrgExtensionContext added in v0.0.5

type OrgExtensionContext struct {
	// OrgID is the organization identifier
	OrgID xid.ID
	// AppID is the application identifier
	AppID xid.ID
	// BasePath is the dashboard base path
	BasePath string
	// Request is the HTTP request for accessing additional context
	Request *http.Request
	// GetOrg is a helper function to lazy-load the organization object if needed
	// Most extensions should fetch their own org-scoped data instead
	GetOrg func() (any, error)
	// IsAdmin indicates if the current user has admin privileges in this org
	IsAdmin bool
}

OrgExtensionContext provides context information to extension renderers Extensions receive minimal information and fetch their own data as needed.

type OrganizationAction added in v0.0.5

type OrganizationAction struct {
	// ID is a unique identifier for this action
	ID string
	// Label is the button text
	Label string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// Style determines button styling: "primary", "secondary", "danger"
	Style string
	// RequireAdmin indicates if admin privileges are required to see this action
	RequireAdmin bool
	// Action is the onclick handler or htmx attribute
	// Examples:
	//   - "htmx.ajax('POST', '/api/scim/sync', {target: '#status'})"
	//   - "document.getElementById('modal').showModal()"
	Action string
}

OrganizationAction represents an action button in the organization header.

type OrganizationQuickLink struct {
	// ID is a unique identifier for this link
	ID string
	// Title is the card title
	Title string
	// Description is the card description
	Description string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// URLBuilder builds the URL for this link
	// Receives basePath, orgID, and appID to construct the full URL
	URLBuilder func(basePath string, orgID xid.ID, appID xid.ID) string
	// RequireAdmin indicates if admin privileges are required to see this link
	RequireAdmin bool
}

OrganizationQuickLink represents a quick access card on the organization detail page.

type OrganizationSettingsSection added in v0.0.5

type OrganizationSettingsSection struct {
	// ID is a unique identifier for this section
	ID string
	// Title is the section title
	Title string
	// Description is the section description
	Description string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// RequireAdmin indicates if admin privileges are required to see this section
	RequireAdmin bool
	// Renderer renders the section content
	Renderer func(ctx OrgExtensionContext) g.Node
}

OrganizationSettingsSection represents a settings section for organization configuration.

type OrganizationTab added in v0.0.5

type OrganizationTab struct {
	// ID is a unique identifier for this tab
	ID string
	// Label is the display text in the tab navigation
	Label string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Order determines display order in tab bar (lower = first)
	Order int
	// RequireAdmin indicates if admin privileges are required to view this tab
	RequireAdmin bool
	// Path is the URL path segment for this tab (e.g., "scim", "billing")
	// Will be accessible at: /dashboard/app/:appId/organizations/:orgId/tabs/:path
	Path string
	// Renderer renders the full tab content
	// The function receives context with org ID and can fetch its own data
	Renderer func(ctx OrgExtensionContext) g.Node
}

OrganizationTab represents a full-page tab for organization content.

type OrganizationUIExtension added in v0.0.5

type OrganizationUIExtension interface {
	// ExtensionID returns a unique identifier for this extension
	ExtensionID() string

	// OrganizationWidgets returns widget cards to display on the organization detail page
	// These appear as stats cards alongside the default org stats
	OrganizationWidgets() []OrganizationWidget

	// OrganizationTabs returns full-page tabs for organization content
	// Each tab gets its own route and can display complete pages
	OrganizationTabs() []OrganizationTab

	// OrganizationActions returns action buttons for the organization header
	// These appear as buttons in the organization detail page header
	OrganizationActions() []OrganizationAction

	// OrganizationQuickLinks returns quick access cards
	// These appear alongside default quick links (Members, Teams, Roles, Invitations)
	OrganizationQuickLinks() []OrganizationQuickLink

	// OrganizationSettingsSections returns settings sections for org settings pages
	// These can be used to add custom settings to organization configuration
	OrganizationSettingsSections() []OrganizationSettingsSection
}

OrganizationUIExtension is the interface that plugins implement to extend organization pages This allows plugins to add widgets, tabs, actions, and quick links to organization-scoped pages.

type OrganizationWidget added in v0.0.5

type OrganizationWidget struct {
	// ID is a unique identifier for this widget
	ID string
	// Title is the widget title
	Title string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// Size determines the widget size in grid columns (1-3)
	// 1 = takes 1/3 of row, 2 = takes 2/3 of row, 3 = full width
	Size int
	// RequireAdmin indicates if admin privileges are required to view this widget
	RequireAdmin bool
	// Renderer renders the widget content
	// The function receives context with org ID and can fetch its own data
	Renderer func(ctx OrgExtensionContext) g.Node
}

OrganizationWidget represents a stats card/widget on the organization detail page.

type PermissionSelectorData

type PermissionSelectorData struct {
	Permissions     []*schema.Permission
	SelectedPermIDs map[xid.ID]bool
}

PermissionSelectorData contains data for the permission selector.

type RoleFormData

type RoleFormData struct {
	Role            *schema.Role
	Permissions     []*schema.Permission
	SelectedPermIDs map[xid.ID]bool
	IsTemplate      bool
	CanSetOwnerRole bool
	Errors          map[string]string
	ActionURL       string
	CancelURL       string
}

RoleFormData contains data for rendering the role form.

type RoleListTableData

type RoleListTableData struct {
	Roles       []*schema.Role
	IsTemplate  bool
	BasePath    string
	OnEdit      func(roleID xid.ID) string
	OnDelete    func(roleID xid.ID) string
	OnClone     func(roleID xid.ID) string
	ShowActions bool
}

RoleListTableData contains data for the role list table.

type RoleManagementInterfaceData

type RoleManagementInterfaceData struct {
	Title         string
	Description   string
	Roles         []*schema.Role
	IsTemplate    bool
	BasePath      string
	CreateRoleURL string
	AppID         xid.ID
	OrgID         *xid.ID
	ShowActions   bool
}

RoleManagementInterfaceData contains data for the full role management interface.

type Route

type Route struct {
	// Method is the HTTP method (GET, POST, etc.)
	Method string
	// Path is the route path (relative to /app/:appId/)
	// Example: "/multisession" becomes "/app/:appId/multisession"
	Path string
	// Handler is the ForgeUI page handler function
	// Signature: func(ctx *router.PageContext) (g.Node, error)
	// The layout is applied automatically by ForgeUI based on route configuration
	Handler func(ctx *router.PageContext) (g.Node, error)
	// Name is the route name for identification
	Name string
	// Summary is a short description for OpenAPI
	Summary string
	// Description is a detailed description for OpenAPI
	Description string
	// Tags are OpenAPI tags
	Tags []string
	// RequireAuth indicates if the route requires authentication
	RequireAuth bool
	// RequireAdmin indicates if the route requires admin privileges
	RequireAdmin bool
}

Route represents a route registered by a plugin extension.

type SettingsPage

type SettingsPage struct {
	// ID is a unique identifier for this page (e.g., "role-templates", "api-keys")
	ID string
	// Label is the display text in the sidebar
	Label string
	// Description is a brief description of what this page does
	Description string
	// Icon is an optional icon component (lucide icon recommended)
	Icon g.Node
	// Category groups pages in the sidebar ("general", "security", "communication", "integrations", "advanced")
	Category string
	// Order determines the display order within the category (lower = first)
	Order int
	// Path is the URL path relative to /settings/ (e.g., "roles", "api-keys")
	Path string
	// RequirePlugin optionally specifies a plugin ID that must be enabled
	RequirePlugin string
	// RequireAdmin indicates if admin privileges are required
	RequireAdmin bool
}

SettingsPage represents a full settings page in the sidebar navigation.

type SettingsSection

type SettingsSection struct {
	// ID is a unique identifier for this section
	ID string
	// Title is the section title
	Title string
	// Description is the section description
	Description string
	// Icon is an optional icon
	Icon g.Node
	// Order determines display order (lower = first)
	Order int
	// Renderer renders the section content
	Renderer func(basePath string, currentApp *app.App) g.Node
}

SettingsSection represents a section in the settings page Deprecated: Use SettingsPage instead for full-page settings.

Directories

Path Synopsis
Package schema provides a dynamic UI schema system for building settings forms with validation, forgeui component rendering, and plugin extensibility.
Package schema provides a dynamic UI schema system for building settings forms with validation, forgeui component rendering, and plugin extensibility.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL