mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Renamed parts of the UI extension APIs (#63070)
* Renamed target -> id and href -> path after feedback. * fixed type issues in test page. * chore(pluginschemajson): update extensions props target -> id * this is the final. * fixed typings...again... --------- Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ describe('Plugin registry', () => {
|
||||
const registry = createPluginExtensionsRegistry({
|
||||
'belugacdn-app': createConfig([
|
||||
{
|
||||
target: 'plugins/belugacdn-app/menu',
|
||||
placement: 'plugins/belugacdn-app/menu',
|
||||
title: 'The title',
|
||||
type: PluginExtensionTypes.link,
|
||||
description: 'Incidents are occurring!',
|
||||
@@ -16,7 +16,7 @@ describe('Plugin registry', () => {
|
||||
]),
|
||||
'strava-app': createConfig([
|
||||
{
|
||||
target: 'plugins/strava-app/menu',
|
||||
placement: 'plugins/strava-app/menu',
|
||||
title: 'The title',
|
||||
type: PluginExtensionTypes.link,
|
||||
description: 'Incidents are occurring!',
|
||||
@@ -25,14 +25,14 @@ describe('Plugin registry', () => {
|
||||
]),
|
||||
'duplicate-links-app': createConfig([
|
||||
{
|
||||
target: 'plugins/duplicate-links-app/menu',
|
||||
placement: 'plugins/duplicate-links-app/menu',
|
||||
title: 'The title',
|
||||
type: PluginExtensionTypes.link,
|
||||
description: 'Incidents are occurring!',
|
||||
path: '/incidents/declare',
|
||||
},
|
||||
{
|
||||
target: 'plugins/duplicate-links-app/menu',
|
||||
placement: 'plugins/duplicate-links-app/menu',
|
||||
title: 'The title',
|
||||
type: PluginExtensionTypes.link,
|
||||
description: 'Incidents are occurring!',
|
||||
@@ -49,7 +49,7 @@ describe('Plugin registry', () => {
|
||||
title: 'The title',
|
||||
type: 'link',
|
||||
description: 'Incidents are occurring!',
|
||||
href: '/a/belugacdn-app/incidents/declare',
|
||||
path: '/a/belugacdn-app/incidents/declare',
|
||||
key: 539074708,
|
||||
});
|
||||
});
|
||||
@@ -68,7 +68,7 @@ describe('Plugin registry', () => {
|
||||
title: 'The title',
|
||||
type: 'link',
|
||||
description: 'Incidents are occurring!',
|
||||
href: '/a/belugacdn-app/incidents/declare',
|
||||
path: '/a/belugacdn-app/incidents/declare',
|
||||
key: 539074708,
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('Plugin registry', () => {
|
||||
title: 'The title',
|
||||
type: 'link',
|
||||
description: 'Incidents are occurring!',
|
||||
href: '/a/strava-app/incidents/declare',
|
||||
path: '/a/strava-app/incidents/declare',
|
||||
key: -1637066384,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,15 +17,15 @@ export function createPluginExtensionsRegistry(apps: Record<string, AppPluginCon
|
||||
}
|
||||
|
||||
for (const extension of extensions) {
|
||||
const target = extension.target;
|
||||
const placement = extension.placement;
|
||||
const item = createRegistryItem(pluginId, extension);
|
||||
|
||||
if (!Array.isArray(registry[target])) {
|
||||
registry[target] = [item];
|
||||
if (!Array.isArray(registry[placement])) {
|
||||
registry[placement] = [item];
|
||||
continue;
|
||||
}
|
||||
|
||||
registry[target].push(item);
|
||||
registry[placement].push(item);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -38,14 +38,14 @@ export function createPluginExtensionsRegistry(apps: Record<string, AppPluginCon
|
||||
}
|
||||
|
||||
function createRegistryItem(pluginId: string, extension: PluginsExtensionLinkConfig): PluginsExtensionLink {
|
||||
const href = `/a/${pluginId}${extension.path}`;
|
||||
const path = `/a/${pluginId}${extension.path}`;
|
||||
|
||||
return Object.freeze({
|
||||
type: PluginExtensionTypes.link,
|
||||
title: extension.title,
|
||||
description: extension.description,
|
||||
href: href,
|
||||
key: hashKey(`${extension.title}${href}`),
|
||||
path: path,
|
||||
key: hashKey(`${extension.title}${path}`),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user