Fix: Proper plugin logo loading depending on staging (#88247)

* making logos respect the staging

* making it work when served from subfolders

* fixing helper test
This commit is contained in:
Timur Olzhabayev 2024-05-27 10:26:30 +02:00 committed by GitHub
parent e7f05f4ff2
commit 4761326568
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View File

@ -51,7 +51,8 @@ func AddDefaultResponseHeaders(cfg *setting.Cfg) web.Handler {
!strings.HasPrefix(c.Req.URL.Path, "/avatar/") && !strings.HasPrefix(c.Req.URL.Path, "/avatar/") &&
!strings.HasPrefix(c.Req.URL.Path, "/api/datasources/proxy/") && !strings.HasPrefix(c.Req.URL.Path, "/api/datasources/proxy/") &&
!strings.HasPrefix(c.Req.URL.Path, "/api/reports/render/") && !strings.HasPrefix(c.Req.URL.Path, "/api/reports/render/") &&
!strings.HasPrefix(c.Req.URL.Path, "/render/d-solo/") && !resourceCachable { !strings.HasPrefix(c.Req.URL.Path, "/render/d-solo/") &&
!(strings.HasPrefix(c.Req.URL.Path, "/api/gnet/plugins") && strings.Contains(c.Req.URL.Path, "/logos/")) && !resourceCachable {
addNoCacheHeaders(c.Resp) addNoCacheHeaders(c.Resp)
} }

View File

@ -190,8 +190,8 @@ describe('Plugins/Helpers', () => {
id: 'alexanderzobnin-zabbix-app', id: 'alexanderzobnin-zabbix-app',
info: { info: {
logos: { logos: {
large: 'https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/large', large: '/api/gnet/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/large',
small: 'https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/small', small: '/api/gnet/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/small',
}, },
keywords: ['zabbix', 'monitoring', 'dashboard'], keywords: ['zabbix', 'monitoring', 'dashboard'],
}, },
@ -319,8 +319,8 @@ describe('Plugins/Helpers', () => {
id: 'alexanderzobnin-zabbix-app', id: 'alexanderzobnin-zabbix-app',
info: { info: {
logos: { logos: {
small: 'https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/small', small: '/api/gnet/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/small',
large: 'https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/large', large: '/api/gnet/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/logos/large',
}, },
keywords: ['zabbix', 'monitoring', 'dashboard'], keywords: ['zabbix', 'monitoring', 'dashboard'],
}, },

View File

@ -126,8 +126,8 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
id, id,
info: { info: {
logos: { logos: {
small: `https://grafana.com/api/plugins/${id}/versions/${version}/logos/small`, small: `${config.appSubUrl}/api/gnet/plugins/${id}/versions/${version}/logos/small`,
large: `https://grafana.com/api/plugins/${id}/versions/${version}/logos/large`, large: `${config.appSubUrl}/api/gnet/plugins/${id}/versions/${version}/logos/large`,
}, },
keywords, keywords,
}, },
@ -214,8 +214,8 @@ export function mapToCatalogPlugin(local?: LocalPlugin, remote?: RemotePlugin, e
if (remote) { if (remote) {
logos = { logos = {
small: `https://grafana.com/api/plugins/${id}/versions/${remote.version}/logos/small`, small: `${config.appSubUrl}/api/gnet/plugins/${id}/versions/${remote.version}/logos/small`,
large: `https://grafana.com/api/plugins/${id}/versions/${remote.version}/logos/large`, large: `${config.appSubUrl}/api/gnet/plugins/${id}/versions/${remote.version}/logos/large`,
}; };
} else if (local && local.info.logos) { } else if (local && local.info.logos) {
logos = local.info.logos; logos = local.info.logos;