v1alpha1

package
v0.13.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// PreferencesName is the name for the preferences file.
	PreferencesName = "preferences.json"
)

Variables

This section is empty.

Functions

func WritePreferences

func WritePreferences(ctx context.Context, config Config, preferences Preferences) error

WritePreferences writes preferences to the filesystem.

Types

type Condition

type Condition struct {
	LHS string        `json:"lhs"`
	RHS string        `json:"rhs"`
	Op  OperationType `json:"op"`
}

Condition is a condition. Conditions are used to determine if an element is enabled.

type Config

type Config interface {
	// DataDirectory is the data directory.
	DataDirectory() string
}

Config is configuration for preferences.

type Element

type Element struct {
	Name              string      `json:"name"`
	Value             string      `json:"value"`
	Type              string      `json:"type"`
	DisableConditions []Condition `json:"disableConditions,omitempty"`
	Config            interface{} `json:"config"`
}

Element is an element in a section.

func NewRadioElement

func NewRadioElement(name, value string, disableConditions []Condition, values map[string]string) Element

NewRadioElement creates a radio element.

func NewTextElement

func NewTextElement(name, value string, disableConditions []Condition, placeholder, label string) Element

NewTextElement creates a text element.

type OperationType

type OperationType string

OperationType is an operation type. It is used in Condition to determine if an element is enabled.

const (
	// OperationTypeString is an equal operation.
	OperationTypeString OperationType = "Equal"
)

type PreferencePanel

type PreferencePanel struct {
	Name     string              `json:"name"`
	Sections []PreferenceSection `json:"sections,omitempty"`
}

PreferencePanel is a preference panel.

type PreferenceSection

type PreferenceSection struct {
	Name     string    `json:"name"`
	Elements []Element `json:"elements,omitempty"`
}

PreferenceSection is a section in a preference panel.

type Preferences

type Preferences struct {
	Version    string            `json:"version"`
	Panels     []PreferencePanel `json:"panels,omitempty"`
	UpdateName string            `json:"updateName"`
}

Preferences are preferences.

func CreateOrOpenPreferences

func CreateOrOpenPreferences(ctx context.Context, config Config) (Preferences, error)

CreateOrOpenPreferences creates or opens an existing preferences file.

func (*Preferences) Update

func (p *Preferences) Update(values map[string]string)

Update updates preferences given a set of a values.

type RadioConfig

type RadioConfig struct {
	Values []RadioValue `json:"values"`
}

RadioConfig is configuration for a radio element.

type RadioValue

type RadioValue struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

RadioValue is an individual radio value.

type TextConfig

type TextConfig struct {
	Label       string `json:"label"`
	Placeholder string `json:"placeholder"`
}

TextConfig is configuration for a text element.

Jump to

Keyboard shortcuts

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