mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Fixed issue for plugin extensions in link validator (#64739)
fixed issue in validateLink.
This commit is contained in:
parent
1e7c27e636
commit
8127ec5bfd
@ -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 {
|
||||
|
@ -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}/`}'`
|
||||
|
Loading…
Reference in New Issue
Block a user