[MM-21123] Add Labels to upstream Marketplace response (#13425)

* Add Labels to upstream Marketplace response

* Add LOCAL label to local plugins
Этот коммит содержится в:
Ben Schumacher
2020-01-14 07:16:36 +01:00
коммит произвёл GitHub
родитель 8e2c59ca00
Коммит 1f3f8fbf57
3 изменённых файлов: 43 добавлений и 12 удалений

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

@@ -547,6 +547,12 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
HomepageURL: "https://example.com/mattermost/mattermost-plugin-nps", HomepageURL: "https://example.com/mattermost/mattermost-plugin-nps",
IconData: "https://example.com/icon.svg", IconData: "https://example.com/icon.svg",
DownloadURL: "https://example.com/mattermost/mattermost-plugin-nps/releases/download/v1.0.3/com.mattermost.nps-1.0.3.tar.gz", DownloadURL: "https://example.com/mattermost/mattermost-plugin-nps/releases/download/v1.0.3/com.mattermost.nps-1.0.3.tar.gz",
Labels: []model.MarketplaceLabel{
{
Name: "someName",
Description: "some Description",
},
},
Manifest: &model.Manifest{ Manifest: &model.Manifest{
Id: "com.mattermost.nps", Id: "com.mattermost.nps",
Name: "User Satisfaction Surveys", Name: "User Satisfaction Surveys",
@@ -594,7 +600,11 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
HomepageURL: "", HomepageURL: "",
IconData: "", IconData: "",
DownloadURL: "", DownloadURL: "",
Manifest: manifest, Labels: []model.MarketplaceLabel{{
Name: "Local",
Description: "This plugin is not listed in the marketplace but was installed manually",
}},
Manifest: manifest,
}, },
InstalledVersion: manifest.Version, InstalledVersion: manifest.Version,
}) })
@@ -725,7 +735,11 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
HomepageURL: "", HomepageURL: "",
IconData: "", IconData: "",
DownloadURL: "", DownloadURL: "",
Manifest: manifest, Labels: []model.MarketplaceLabel{{
Name: "Local",
Description: "This plugin is not listed in the marketplace but was installed manually",
}},
Manifest: manifest,
}, },
InstalledVersion: manifest.Version, InstalledVersion: manifest.Version,
} }
@@ -738,7 +752,11 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
HomepageURL: "", HomepageURL: "",
IconData: "", IconData: "",
DownloadURL: "", DownloadURL: "",
Manifest: manifest, Labels: []model.MarketplaceLabel{{
Name: "Local",
Description: "This plugin is not listed in the marketplace but was installed manually",
}},
Manifest: manifest,
}, },
InstalledVersion: manifest.Version, InstalledVersion: manifest.Version,
} }

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

@@ -502,6 +502,11 @@ func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*m
result = append(result, &model.MarketplacePlugin{ result = append(result, &model.MarketplacePlugin{
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{ BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
// Labels should not (yet) be localized as the labels sent by the Marketplace are not (yet) localizable.
Labels: []model.MarketplaceLabel{{
Name: "Local",
Description: "This plugin is not listed in the marketplace but was installed manually",
}},
Manifest: plugin.Manifest, Manifest: plugin.Manifest,
}, },
InstalledVersion: plugin.Manifest.Version, InstalledVersion: plugin.Manifest.Version,

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

@@ -14,18 +14,26 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// BaseMarketplacePlugin is a Mattermost plugin received from the marketplace server. // BaseMarketplacePlugin is a Mattermost plugin received from the Marketplace server.
type BaseMarketplacePlugin struct { type BaseMarketplacePlugin struct {
HomepageURL string `json:"homepage_url"` HomepageURL string `json:"homepage_url"`
IconData string `json:"icon_data"` IconData string `json:"icon_data"`
DownloadURL string `json:"download_url"` DownloadURL string `json:"download_url"`
ReleaseNotesURL string `json:"release_notes_url"` ReleaseNotesURL string `json:"release_notes_url"`
// Signature represents a signature of a plugin saved in base64 encoding. Labels []MarketplaceLabel `json:"labels"`
Signature string `json:"signature"` Signature string `json:"signature"` // Signature represents a signature of a plugin saved in base64 encoding.
Manifest *Manifest `json:"manifest"` Manifest *Manifest `json:"manifest"`
} }
// MarketplacePlugin is a state aware marketplace plugin. // MarketplaceLabel represents a label shown in the Marketplace UI.
type MarketplaceLabel struct {
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"`
Color string `json:"color"`
}
// MarketplacePlugin is a state aware Marketplace plugin.
type MarketplacePlugin struct { type MarketplacePlugin struct {
*BaseMarketplacePlugin *BaseMarketplacePlugin
InstalledVersion string `json:"installed_version"` InstalledVersion string `json:"installed_version"`