forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add backend support for plugin settings * Add plugin settings config * Add UI support for plugin settings
- Loading branch information
1 parent
06d8353
commit 2b87181
Showing
24 changed files
with
444 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,4 +207,5 @@ fragment ConfigData on ConfigResult { | |
...ConfigDefaultSettingsData | ||
} | ||
ui | ||
plugins | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,13 @@ query Plugins { | |
description | ||
hooks | ||
} | ||
|
||
settings { | ||
name | ||
display_name | ||
description | ||
type | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/stashapp/stash/internal/manager/config" | ||
) | ||
|
||
func (r *configResultResolver) Plugins(ctx context.Context, obj *ConfigResult, include []string) (map[string]interface{}, error) { | ||
if len(include) == 0 { | ||
ret := config.GetInstance().GetAllPluginConfiguration() | ||
return ret, nil | ||
} | ||
|
||
ret := make(map[string]interface{}) | ||
|
||
for _, plugin := range include { | ||
c := config.GetInstance().GetPluginConfiguration(plugin) | ||
if len(c) > 0 { | ||
ret[plugin] = c | ||
} | ||
} | ||
|
||
return ret, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package plugin | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"strconv" | ||
) | ||
|
||
type PluginSettingTypeEnum string | ||
|
||
const ( | ||
PluginSettingTypeEnumString PluginSettingTypeEnum = "STRING" | ||
PluginSettingTypeEnumNumber PluginSettingTypeEnum = "NUMBER" | ||
PluginSettingTypeEnumBoolean PluginSettingTypeEnum = "BOOLEAN" | ||
) | ||
|
||
var AllPluginSettingTypeEnum = []PluginSettingTypeEnum{ | ||
PluginSettingTypeEnumString, | ||
PluginSettingTypeEnumNumber, | ||
PluginSettingTypeEnumBoolean, | ||
} | ||
|
||
func (e PluginSettingTypeEnum) IsValid() bool { | ||
switch e { | ||
case PluginSettingTypeEnumString, PluginSettingTypeEnumNumber, PluginSettingTypeEnumBoolean: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func (e PluginSettingTypeEnum) String() string { | ||
return string(e) | ||
} | ||
|
||
func (e *PluginSettingTypeEnum) UnmarshalGQL(v interface{}) error { | ||
str, ok := v.(string) | ||
if !ok { | ||
return fmt.Errorf("enums must be strings") | ||
} | ||
|
||
*e = PluginSettingTypeEnum(str) | ||
if !e.IsValid() { | ||
return fmt.Errorf("%s is not a valid PluginSettingTypeEnum", str) | ||
} | ||
return nil | ||
} | ||
|
||
func (e PluginSettingTypeEnum) MarshalGQL(w io.Writer) { | ||
fmt.Fprint(w, strconv.Quote(e.String())) | ||
} |
Oops, something went wrong.