Skip to content

Commit

Permalink
Enable regexes and functions in link patterns (jaegertracing#817)
Browse files Browse the repository at this point in the history
* Rearange nav controls

Signed-off-by: yoave23 <Yoav.eyal@logz.io>

* Remove logo and use text

Signed-off-by: yoave23 <Yoav.eyal@logz.io>

* Enable commented features and tests

Signed-off-by: yoave23 <Yoav.eyal@logz.io>
  • Loading branch information
yoave23 authored Sep 26, 2021
1 parent a3addbe commit cc9643c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
10 changes: 0 additions & 10 deletions packages/jaeger-ui/src/model/link-patterns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ describe('processTemplate()', () => {
);
});

/*
// kept on ice until #123 is implemented:
it('correctly returns the same object when passing an already processed template', () => {
const alreadyProcessed = {
parameters: ['b'],
Expand All @@ -58,8 +55,6 @@ describe('processTemplate()', () => {
expect(processedTemplate).toBe(alreadyProcessed);
});

*/

it('reports an error when passing an object that does not look like an already processed template', () => {
expect(() =>
processTemplate(
Expand Down Expand Up @@ -98,9 +93,6 @@ describe('createTestFunction()', () => {
expect(testFn('otherValue')).toBe(false);
});

/*
// kept on ice until #123 is implemented:
it('accepts a regular expression', () => {
const testFn = createTestFunction(/^my.*Value$/);
expect(testFn('myValue')).toBe(true);
Expand Down Expand Up @@ -131,8 +123,6 @@ describe('createTestFunction()', () => {
expect(mockCallback).toHaveBeenCalledWith('otherValue');
});

*/

it('accepts undefined', () => {
const testFn = createTestFunction();
expect(testFn('myValue')).toBe(true);
Expand Down
11 changes: 1 addition & 10 deletions packages/jaeger-ui/src/model/link-patterns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ type TLinksRV = { url: string; text: string }[];

export function processTemplate(template: any, encodeFn: (unencoded: any) => string): ProcessedTemplate {
if (typeof template !== 'string') {
/*
// kept on ice until #123 is implemented:
if (template && Array.isArray(template.parameters) && (typeof template.template === 'function')) {
if (template && Array.isArray(template.parameters) && typeof template.template === 'function') {
return template;
}

*/
throw new Error('Invalid template');
}
return {
Expand All @@ -63,17 +59,12 @@ export function createTestFunction(entry: any) {
if (Array.isArray(entry)) {
return (arg: any) => entry.indexOf(arg) > -1;
}
/*
// kept on ice until #123 is implemented:
if (entry instanceof RegExp) {
return (arg: any) => entry.test(arg);
}
if (typeof entry === 'function') {
return entry;
}
*/
if (entry == null) {
return () => true;
}
Expand Down

0 comments on commit cc9643c

Please sign in to comment.