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] DF Analytics: Ensure creation flyout can be opened when no jobs exist #50417

Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -43,6 +43,7 @@ import { AnalyticStatsBarStats, StatsBar } from '../../../../../components/stats
import { RefreshAnalyticsListButton } from '../refresh_analytics_list_button';
import { CreateAnalyticsButton } from '../create_analytics_button';
import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';
import { CreateAnalyticsFlyoutWrapper } from '../create_analytics_flyout_wrapper';

function getItemIdToExpandedRowMap(
itemIds: DataFrameAnalyticsId[],
Expand Down Expand Up @@ -242,6 +243,9 @@ export const DataFrameAnalyticsList: FC<Props> = ({
}
data-test-subj="mlNoDataFrameAnalyticsFound"
/>
{!isManagementTable && createAnalyticsForm && (
<CreateAnalyticsFlyoutWrapper {...createAnalyticsForm} />
)}
</Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import { createPermissionFailureMessage } from '../../../../../privilege/check_p

import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';

import { CreateAnalyticsAdvancedEditor } from '../create_analytics_advanced_editor';
import { CreateAnalyticsForm } from '../create_analytics_form';
import { CreateAnalyticsFlyout } from '../create_analytics_flyout';
import { CreateAnalyticsFlyoutWrapper } from '../create_analytics_flyout_wrapper';

export const CreateAnalyticsButton: FC<CreateAnalyticsFormProps> = props => {
const { disabled, isAdvancedEditorEnabled, isModalVisible } = props.state;
const { disabled } = props.state;
const { openModal } = props.actions;

const button = (
Expand Down Expand Up @@ -51,12 +49,7 @@ export const CreateAnalyticsButton: FC<CreateAnalyticsFormProps> = props => {
return (
<Fragment>
{button}
{isModalVisible && (
<CreateAnalyticsFlyout {...props}>
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
{isAdvancedEditorEnabled === true && <CreateAnalyticsAdvancedEditor {...props} />}
</CreateAnalyticsFlyout>
)}
<CreateAnalyticsFlyoutWrapper {...props} />
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Fragment, FC } from 'react';

import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';

import { CreateAnalyticsAdvancedEditor } from '../create_analytics_advanced_editor';
import { CreateAnalyticsForm } from '../create_analytics_form';
import { CreateAnalyticsFlyout } from '../create_analytics_flyout';

export const CreateAnalyticsFlyoutWrapper: FC<CreateAnalyticsFormProps> = props => {
const { isAdvancedEditorEnabled, isModalVisible } = props.state;

if (isModalVisible === false) {
return null;
}

return (
<Fragment>
{isModalVisible && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is redundant, you already return null 🙂 for false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragment can be omitted as well

<CreateAnalyticsFlyout {...props}>
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
{isAdvancedEditorEnabled ? <CreateAnalyticsAdvancedEditor {...props} /> : <CreateAnalyticsForm {...props} />}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this piece, I think it's fine to be explicit about what value is expected.

{isAdvancedEditorEnabled === true && <CreateAnalyticsAdvancedEditor {...props} />}
</CreateAnalyticsFlyout>
)}
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { CreateAnalyticsFlyoutWrapper } from './create_analytics_flyout_wrapper';