Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Fixes kibana object list in new job from recognised index page #171935

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { KibanaObjectUi } from '../page';

export interface KibanaObjectItemProps {
objectType: string;
kibanaObjects: KibanaObjectUi[];
kibanaObjects: KibanaObjectUi[] | undefined;
isSaving: boolean;
}

export const KibanaObjects: FC<KibanaObjectItemProps> = memo(
export const KibanaObjectList: FC<KibanaObjectItemProps> = memo(
({ objectType, kibanaObjects, isSaving }) => {
const kibanaObjectLabels: Record<string, string> = {
dashboard: i18n.translate('xpack.ml.newJob.recognize.dashboardsLabel', {
Expand All @@ -41,6 +41,10 @@ export const KibanaObjects: FC<KibanaObjectItemProps> = memo(
}),
};

if (kibanaObjects === undefined) {
return null;
}

return (
<>
<EuiTitle size="s">
Expand All @@ -53,7 +57,7 @@ export const KibanaObjects: FC<KibanaObjectItemProps> = memo(
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem>
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem grow={false}>
<EuiFlexItem>
<EuiText size="s" color={exists ? 'subdued' : 'success'}>
{title}
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ import {
JobOverride,
JobResponse,
KibanaObject,
KibanaObjects,
KibanaObjectResponse,
ModuleJob,
} from '../../../../../common/types/modules';
import { CreateResultCallout } from './components/create_result_callout';
import { KibanaObjects } from './components/kibana_objects';
import { KibanaObjectList } from './components/kibana_objects';
import { ModuleJobs } from './components/module_jobs';
import { JobSettingsForm, JobSettingsFormValues } from './components/job_settings_form';
import { TimeRange } from '../common/components';
Expand All @@ -50,10 +51,6 @@ export interface ModuleJobUI extends ModuleJob {

export type KibanaObjectUi = KibanaObject & KibanaObjectResponse;

export interface KibanaObjects {
[objectType: string]: KibanaObjectUi[];
}

interface PageProps {
moduleId: string;
existingGroupIds: string[];
Expand Down Expand Up @@ -111,6 +108,7 @@ export const Page: FC<PageProps> = ({ moduleId, existingGroupIds }) => {
try {
const response = await getDataRecognizerModule({ moduleId });
setJobs(response.jobs);
setKibanaObjects(response.kibana);

setSaveState(SAVE_STATE.NOT_SAVED);

Expand Down Expand Up @@ -365,7 +363,7 @@ export const Page: FC<PageProps> = ({ moduleId, existingGroupIds }) => {
<EuiPanel grow={false} hasShadow={false} hasBorder>
{Object.keys(kibanaObjects).map((objectType, i) => (
<Fragment key={objectType}>
<KibanaObjects
<KibanaObjectList
objectType={objectType}
kibanaObjects={kibanaObjects[objectType]}
isSaving={saveState === SAVE_STATE.SAVING}
Expand Down