recommit: ordered plugin settings (#7919) (#7926)

Этот коммит содержится в:
Chris
2017-11-30 18:20:29 -06:00
коммит произвёл GitHub
родитель 422292eea0
Коммит d879a7621f
2 изменённых файлов: 48 добавлений и 39 удалений

Просмотреть файл

@@ -31,6 +31,9 @@ type PluginOption struct {
} }
type PluginSetting struct { type PluginSetting struct {
// The key that the setting will be assigned to in the configuration file.
Key string `json:"key" yaml:"key"`
// The display name for the setting. // The display name for the setting.
DisplayName string `json:"display_name" yaml:"display_name"` DisplayName string `json:"display_name" yaml:"display_name"`
@@ -76,8 +79,8 @@ type PluginSettingsSchema struct {
// Optional text to display below the settings. // Optional text to display below the settings.
Footer string `json:"footer" yaml:"footer"` Footer string `json:"footer" yaml:"footer"`
// A mapping of setting keys to schema definitions. // A list of setting definitions.
Settings map[string]*PluginSetting `json:"settings" yaml:"settings"` Settings []*PluginSetting `json:"settings" yaml:"settings"`
} }
// The plugin manifest defines the metadata required to load and present your plugin. The manifest // The plugin manifest defines the metadata required to load and present your plugin. The manifest
@@ -93,7 +96,7 @@ type PluginSettingsSchema struct {
// executable: myplugin // executable: myplugin
// settings_schema: // settings_schema:
// settings: // settings:
// enable_extra_thing: // - key: enable_extra_thing
// type: bool // type: bool
// display_name: Enable Extra Thing // display_name: Enable Extra Thing
// help_text: When true, an extra thing will be enabled! // help_text: When true, an extra thing will be enabled!
@@ -126,6 +129,8 @@ type Manifest struct {
type ManifestBackend struct { type ManifestBackend struct {
// The path to your executable binary. This should be relative to the root of your bundle and the // The path to your executable binary. This should be relative to the root of your bundle and the
// location of the manifest file. // location of the manifest file.
//
// On Windows, this file must have a ".exe" extension.
Executable string `json:"executable" yaml:"executable"` Executable string `json:"executable" yaml:"executable"`
} }

Просмотреть файл

@@ -70,8 +70,9 @@ func TestManifestUnmarshal(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{ SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: map[string]*PluginSetting{ Settings: []*PluginSetting{
"thesetting": &PluginSetting{ &PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN, Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext", HelpText: "thehelptext",
@@ -100,7 +101,7 @@ settings_schema:
header: theheadertext header: theheadertext
footer: thefootertext footer: thefootertext
settings: settings:
thesetting: - key: thesetting
display_name: thedisplayname display_name: thedisplayname
type: dropdown type: dropdown
help_text: thehelptext help_text: thehelptext
@@ -125,8 +126,9 @@ settings_schema:
"settings_schema": { "settings_schema": {
"header": "theheadertext", "header": "theheadertext",
"footer": "thefootertext", "footer": "thefootertext",
"settings": { "settings": [
"thesetting": { {
"key": "thesetting",
"display_name": "thedisplayname", "display_name": "thedisplayname",
"type": "dropdown", "type": "dropdown",
"help_text": "thehelptext", "help_text": "thehelptext",
@@ -140,7 +142,7 @@ settings_schema:
], ],
"default": "thedefault" "default": "thedefault"
} }
} ]
} }
}`), &jsonResult)) }`), &jsonResult))
assert.Equal(t, expected, jsonResult) assert.Equal(t, expected, jsonResult)
@@ -175,8 +177,9 @@ func TestManifestJson(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{ SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: map[string]*PluginSetting{ Settings: []*PluginSetting{
"thesetting": &PluginSetting{ &PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN, Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext", HelpText: "thehelptext",
@@ -239,8 +242,9 @@ func TestManifestClientManifest(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{ SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext", Header: "theheadertext",
Footer: "thefootertext", Footer: "thefootertext",
Settings: map[string]*PluginSetting{ Settings: []*PluginSetting{
"thesetting": &PluginSetting{ &PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname", DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN, Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext", HelpText: "thehelptext",