settings

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextIDKey defines the key used in the context to store the ID
	ContextIDKey = "setting_id"
	// ContextButtonValueKey defines the key used in the context to store a button value
	ContextButtonValueKey = "button_value"
	// ContextOptionValueKey defines the key used in the context to store a selected option value
	ContextOptionValueKey = "selected_option"

	// DisabledString defines the string used to show that a setting is disabled
	DisabledString = "Disabled"
	// TrueString codify the boolean true into a string
	TrueString = "true"
	// FalseString codify the boolean false into a string
	FalseString = "false"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Setting

type Setting interface {
	Set(userID string, value interface{}) error
	Get(userID string) (interface{}, error)
	GetID() string
	GetDependency() string
	IsDisabled(foreignValue interface{}) bool
	GetTitle() string
	GetDescription() string
	GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error)
}

Setting defines the behavior of each element a the panel

func NewBoolSetting

func NewBoolSetting(id, title, description, dependsOn string, store SettingStore) Setting

NewBoolSetting creates a new setting input for boolean values

func NewEmptySetting

func NewEmptySetting(id, title, description string) Setting

NewEmptySetting creates a new panel value with no setting attached

func NewOptionSetting

func NewOptionSetting(id, title, description, dependsOn string, options []string, store SettingStore) Setting

NewOptionSetting creates a new setting input to select from a dropdown

func NewReadOnlySetting

func NewReadOnlySetting(id, title, description, dependsOn string, store SettingStore) Setting

NewReadOnlySetting creates a new panel value that only read from the setting

type SettingStore

type SettingStore interface {
	SetSetting(userID, settingID string, value interface{}) error
	GetSetting(userID, settingID string) (interface{}, error)
}

SettingStore defines the behavior needed to set and get settings

Jump to

Keyboard shortcuts

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