Plugins: Fixed issue for plugin extensions in link validator (#64739)

fixed issue in validateLink.
This commit is contained in:
Marcus Andersson 2023-03-14 16:44:12 +01:00 committed by GitHub
parent 1e7c27e636
commit 8127ec5bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -30,6 +30,17 @@ describe('extension link validator', () => {
});
});
it('should return link configuration if path is not specified', () => {
const configureWithValidation = validator(() => {
return {
title: 'Go to page two',
};
});
const configured = configureWithValidation(extension, context);
expect(configured).toEqual({ title: 'Go to page two' });
});
it('should return undefined if path is invalid', () => {
const configureWithValidation = validator(() => {
return {

View File

@ -1,3 +1,5 @@
import { isString } from 'lodash';
import type { AppPluginExtensionLink } from '@grafana/data';
import type { ConfigureFunc } from './types';
@ -15,6 +17,10 @@ export function createLinkValidator(options: Options) {
return function validateLink(link, context) {
const configured = configure(link, context);
if (!isString(configured?.path)) {
return configured;
}
if (!isValidLinkPath(pluginId, configured?.path)) {
logger(
`[Plugins] Disabled extension '${title}' for '${pluginId}' beause configure didn't return a path with the correct prefix: '${`/a/${pluginId}/`}'`