mirror of
https://github.com/safing/portbase
synced 2025-04-20 01:19:08 +00:00
Add config annotation to mark a setting as "plan requires"
This commit is contained in:
parent
2d0ce85661
commit
c992b8ea54
3 changed files with 10 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ misc
|
||||||
|
|
||||||
go.mod.*
|
go.mod.*
|
||||||
vendor
|
vendor
|
||||||
|
go.work
|
||||||
|
go.work.sum
|
||||||
|
|
|
@ -108,6 +108,11 @@ const (
|
||||||
// requirement. The type of RequiresAnnotation is []ValueRequirement
|
// requirement. The type of RequiresAnnotation is []ValueRequirement
|
||||||
// or ValueRequirement.
|
// or ValueRequirement.
|
||||||
RequiresAnnotation = "safing/portbase:config:requires"
|
RequiresAnnotation = "safing/portbase:config:requires"
|
||||||
|
|
||||||
|
// SettingRequiresFeaturePlan can be used to mark a setting as only available
|
||||||
|
// when the user has a certain feature ID activated by the subscription plan.
|
||||||
|
// The type is []string or string.
|
||||||
|
SettingRequiresFeaturePlan = "safing/portmaster:ui:config:requires-feature"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QuickSettingsAction defines the action of a quick setting.
|
// QuickSettingsAction defines the action of a quick setting.
|
||||||
|
|
|
@ -52,6 +52,7 @@ func replaceConfig(newValues map[string]interface{}) []*ValidationError {
|
||||||
|
|
||||||
option.Lock()
|
option.Lock()
|
||||||
option.activeValue = nil
|
option.activeValue = nil
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
valueCache, err := validateValue(option, newValue)
|
valueCache, err := validateValue(option, newValue)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -103,11 +104,11 @@ func replaceDefaultConfig(newValues map[string]interface{}) []*ValidationError {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfigOption sets a single value in the (prioritized) user defined config.
|
// SetConfigOption sets a single value in the (prioritized) user defined config.
|
||||||
func SetConfigOption(key string, value interface{}) error {
|
func SetConfigOption(key string, value any) error {
|
||||||
return setConfigOption(key, value, true)
|
return setConfigOption(key, value, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setConfigOption(key string, value interface{}, push bool) (err error) {
|
func setConfigOption(key string, value any, push bool) (err error) {
|
||||||
option, err := GetOption(key)
|
option, err := GetOption(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue