Skip to content

Commit

Permalink
adding check for non time based index
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jul 5, 2021
1 parent e1a3d48 commit 04879a8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const ResultsLinks: FC<Props> = ({

Promise.all(
additionalLinks.map(async ({ canDisplay, getUrl }) => {
if ((await canDisplay()) === false) {
if ((await canDisplay({ indexPatternId })) === false) {
return null;
}
return getUrl({ globalState, indexPatternId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const ActionsPanel: FC<Props> = ({

Promise.all(
additionalLinks.map(async ({ canDisplay, getUrl }) => {
if ((await canDisplay()) === false) {
if ((await canDisplay({ indexPatternId })) === false) {
return null;
}
return getUrl({ globalState, indexPatternId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ interface GetUrlParams {
export const FileDataVisualizerPage: FC = () => {
useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false });
const {
services: { docLinks, dataVisualizer },
services: {
docLinks,
dataVisualizer,
data: {
indexPatterns: { get: getIndexPattern },
},
},
} = useMlKibana();
const mlUrlGenerator = useMlUrlGenerator();
getMlNodeCount();
Expand All @@ -52,8 +58,15 @@ export const FileDataVisualizerPage: FC = () => {
},
});
},
canDisplay: async () => {
return isFullLicense() && checkPermission('canCreateJob') && mlNodesAvailable();
canDisplay: async ({ indexPatternId }) => {
const { timeFieldName } = await getIndexPattern(indexPatternId);

return (
isFullLicense() &&
timeFieldName !== undefined &&
checkPermission('canCreateJob') &&
mlNodesAvailable()
);
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ interface GetUrlParams {
export const IndexDataVisualizerPage: FC = () => {
useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false });
const {
services: { docLinks, dataVisualizer },
services: {
docLinks,
dataVisualizer,
data: {
indexPatterns: { get: getIndexPattern },
},
},
} = useMlKibana();
const mlUrlGenerator = useMlUrlGenerator();
getMlNodeCount();
Expand Down Expand Up @@ -66,8 +72,14 @@ export const IndexDataVisualizerPage: FC = () => {
},
});
},
canDisplay: async () => {
return isFullLicense() && checkPermission('canCreateJob') && mlNodesAvailable();
canDisplay: async ({ indexPatternId }) => {
const { timeFieldName } = await getIndexPattern(indexPatternId);
return (
isFullLicense() &&
timeFieldName !== undefined &&
checkPermission('canCreateJob') &&
mlNodesAvailable()
);
},
dataTestSubj: 'dataVisualizerCreateAdvancedJobCard',
},
Expand Down

0 comments on commit 04879a8

Please sign in to comment.