MM-54505: re-enable remote marketplace functionality (#24561)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64fabbeed3
Коммит
9a3b503169
@@ -462,8 +462,6 @@ func TestDisableOnRemove(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMarketplacePlugins(t *testing.T) {
|
func TestGetMarketplacePlugins(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
@@ -685,8 +683,6 @@ func TestGetMarketplacePlugins(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
samplePlugins := []*model.MarketplacePlugin{
|
samplePlugins := []*model.MarketplacePlugin{
|
||||||
{
|
{
|
||||||
@@ -831,8 +827,6 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSearchGetMarketplacePlugins(t *testing.T) {
|
func TestSearchGetMarketplacePlugins(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
samplePlugins := []*model.MarketplacePlugin{
|
samplePlugins := []*model.MarketplacePlugin{
|
||||||
{
|
{
|
||||||
@@ -959,8 +953,6 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetLocalPluginInMarketplace(t *testing.T) {
|
func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
@@ -1123,8 +1115,6 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRemotePluginInMarketplace(t *testing.T) {
|
func TestGetRemotePluginInMarketplace(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
@@ -1181,69 +1171,7 @@ func TestGetRemotePluginInMarketplace(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoteMarketplaceDisabledByStreamlinedMarketplaceFlag(t *testing.T) {
|
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "true")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t)
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
marketplacePlugins := []*model.MarketplacePlugin{
|
|
||||||
{
|
|
||||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
|
||||||
HomepageURL: "https://example.com/mattermost/mattermost-plugin-nps",
|
|
||||||
IconData: "https://example.com/icon.svg",
|
|
||||||
DownloadURL: "www.github.com/example",
|
|
||||||
Manifest: &model.Manifest{
|
|
||||||
Id: "marketplace.test",
|
|
||||||
Name: "marketplacetest",
|
|
||||||
Description: "a marketplace plugin",
|
|
||||||
Version: "0.1.2",
|
|
||||||
MinServerVersion: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
InstalledVersion: "",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
|
||||||
res.WriteHeader(http.StatusOK)
|
|
||||||
json, err := json.Marshal([]*model.MarketplacePlugin{marketplacePlugins[0]})
|
|
||||||
require.NoError(t, err)
|
|
||||||
res.Write(json)
|
|
||||||
}))
|
|
||||||
defer testServer.Close()
|
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
|
||||||
*cfg.PluginSettings.Enable = true
|
|
||||||
*cfg.PluginSettings.EnableMarketplace = true
|
|
||||||
*cfg.PluginSettings.EnableRemoteMarketplace = true
|
|
||||||
*cfg.PluginSettings.EnableUploads = true
|
|
||||||
*cfg.PluginSettings.MarketplaceURL = testServer.URL
|
|
||||||
})
|
|
||||||
|
|
||||||
prepackagePlugin := &plugin.PrepackagedPlugin{
|
|
||||||
Manifest: &model.Manifest{
|
|
||||||
Version: "0.0.1",
|
|
||||||
Id: "prepackaged.test",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
env := th.App.GetPluginsEnvironment()
|
|
||||||
env.SetPrepackagedPlugins([]*plugin.PrepackagedPlugin{prepackagePlugin}, nil)
|
|
||||||
|
|
||||||
// No marketplace plugins returned
|
|
||||||
plugins, _, err := th.SystemAdminClient.GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{})
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Only returns the prepackaged plugins
|
|
||||||
require.Len(t, plugins, 1)
|
|
||||||
require.Equal(t, prepackagePlugin.Manifest, plugins[0].Manifest)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
@@ -1376,8 +1304,6 @@ func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInstallMarketplacePlugin(t *testing.T) {
|
func TestInstallMarketplacePlugin(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
@@ -1729,8 +1655,6 @@ func TestInstallMarketplacePlugin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInstallMarketplacePluginPrepackagedDisabled(t *testing.T) {
|
func TestInstallMarketplacePluginPrepackagedDisabled(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
|
|
||||||
path, _ := fileutils.FindDir("tests")
|
path, _ := fileutils.FindDir("tests")
|
||||||
|
|
||||||
|
|||||||
@@ -855,8 +855,6 @@ func TestPushNotificationAck(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCompleteOnboarding(t *testing.T) {
|
func TestCompleteOnboarding(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
|
||||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ func (a *App) GetPlugins() (*model.PluginsResponse, *model.AppError) {
|
|||||||
func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
func (a *App) GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError) {
|
||||||
plugins := map[string]*model.MarketplacePlugin{}
|
plugins := map[string]*model.MarketplacePlugin{}
|
||||||
|
|
||||||
if *a.Config().PluginSettings.EnableRemoteMarketplace && !a.Config().FeatureFlags.StreamlinedMarketplace && !filter.LocalOnly {
|
if *a.Config().PluginSettings.EnableRemoteMarketplace && !filter.LocalOnly {
|
||||||
p, appErr := a.getRemotePlugins()
|
p, appErr := a.getRemotePlugins()
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ func (ch *Channels) InstallMarketplacePlugin(request *model.InstallMarketplacePl
|
|||||||
signatureFile = bytes.NewReader(prepackagedPlugin.Signature)
|
signatureFile = bytes.NewReader(prepackagedPlugin.Signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *ch.cfgSvc.Config().PluginSettings.EnableRemoteMarketplace && !ch.cfgSvc.Config().FeatureFlags.StreamlinedMarketplace {
|
if *ch.cfgSvc.Config().PluginSettings.EnableRemoteMarketplace {
|
||||||
var plugin *model.BaseMarketplacePlugin
|
var plugin *model.BaseMarketplacePlugin
|
||||||
plugin, appErr = ch.getRemoteMarketplacePlugin(request.Id, request.Version)
|
plugin, appErr = ch.getRemoteMarketplacePlugin(request.Id, request.Version)
|
||||||
// The plugin might only be prepackaged and not on the Marketplace.
|
// The plugin might only be prepackaged and not on the Marketplace.
|
||||||
|
|||||||
@@ -76,16 +76,8 @@ exports[`components/marketplace/ doesn't show web marketplace banner in FeatureF
|
|||||||
<div
|
<div
|
||||||
className="GenericModal__body"
|
className="GenericModal__body"
|
||||||
>
|
>
|
||||||
<MarketplaceList
|
<LoadingScreen
|
||||||
filter=""
|
className="loading"
|
||||||
listRef={
|
|
||||||
Object {
|
|
||||||
"current": null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listing={Array []}
|
|
||||||
noResultsMessage="No plugins found"
|
|
||||||
page={0}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
@@ -169,49 +161,8 @@ exports[`components/marketplace/ hides search, shows web marketplace banner in F
|
|||||||
<div
|
<div
|
||||||
className="GenericModal__body"
|
className="GenericModal__body"
|
||||||
>
|
>
|
||||||
<MarketplaceList
|
<LoadingScreen
|
||||||
filter=""
|
className="loading"
|
||||||
listRef={
|
|
||||||
Object {
|
|
||||||
"current": null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listing={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"author_type": "mattermost",
|
|
||||||
"download_url": "https://github.com/mattermost/mattermost-plugin-nps/releases/download/v1.0.3/com.mattermost.nps-1.0.3.tar.gz",
|
|
||||||
"enterprise": false,
|
|
||||||
"homepage_url": "https://github.com/mattermost/mattermost-plugin-nps",
|
|
||||||
"installed_version": "",
|
|
||||||
"manifest": Object {
|
|
||||||
"description": "This plugin sends quarterly user satisfaction surveys to gather feedback and help improve Mattermost",
|
|
||||||
"id": "com.mattermost.nps",
|
|
||||||
"min_server_version": "5.14.0",
|
|
||||||
"name": "User Satisfaction Surveys",
|
|
||||||
"version": "1.0.3",
|
|
||||||
},
|
|
||||||
"release_stage": "production",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"author_type": "mattermost",
|
|
||||||
"download_url": "https://github.com/mattermost/mattermost-test/releases/download/v1.0.3/com.mattermost.nps-1.0.3.tar.gz",
|
|
||||||
"enterprise": false,
|
|
||||||
"homepage_url": "https://github.com/mattermost/mattermost-test",
|
|
||||||
"installed_version": "1.0.3",
|
|
||||||
"manifest": Object {
|
|
||||||
"description": "This plugin is to test",
|
|
||||||
"id": "com.mattermost.test",
|
|
||||||
"min_server_version": "5.14.0",
|
|
||||||
"name": "Test",
|
|
||||||
"version": "1.0.3",
|
|
||||||
},
|
|
||||||
"release_stage": "production",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
noResultsMessage="No plugins found"
|
|
||||||
page={0}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
|||||||
@@ -251,13 +251,17 @@ const MarketplaceModal = ({
|
|||||||
>
|
>
|
||||||
{isStreamlinedMarketplaceEnabled ? (
|
{isStreamlinedMarketplaceEnabled ? (
|
||||||
<>
|
<>
|
||||||
<MarketplaceList
|
{loading ? (
|
||||||
listRef={listRef}
|
<LoadingScreen className='loading'/>
|
||||||
listing={listing}
|
) : (
|
||||||
page={page}
|
<MarketplaceList
|
||||||
filter={filter}
|
listRef={listRef}
|
||||||
noResultsMessage={formatMessage({id: 'marketplace_modal.no_plugins', defaultMessage: 'No plugins found'})}
|
listing={listing}
|
||||||
/>
|
page={page}
|
||||||
|
filter={filter}
|
||||||
|
noResultsMessage={formatMessage({id: 'marketplace_modal.no_plugins', defaultMessage: 'No plugins found'})}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user