Skip to content

Commit ed54585

Browse files
[ML] DF Analytics: Ensure creation flyout can be opened when no jobs exist (#50417) (#50682)
* Ensure create flyout can be open when no jobs exist * remove redundant isModalVisible check
1 parent 985ff33 commit ed54585

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { AnalyticStatsBarStats, StatsBar } from '../../../../../components/stats
4343
import { RefreshAnalyticsListButton } from '../refresh_analytics_list_button';
4444
import { CreateAnalyticsButton } from '../create_analytics_button';
4545
import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';
46+
import { CreateAnalyticsFlyoutWrapper } from '../create_analytics_flyout_wrapper';
4647

4748
function getItemIdToExpandedRowMap(
4849
itemIds: DataFrameAnalyticsId[],
@@ -239,6 +240,9 @@ export const DataFrameAnalyticsList: FC<Props> = ({
239240
}
240241
data-test-subj="mlNoDataFrameAnalyticsFound"
241242
/>
243+
{!isManagementTable && createAnalyticsForm && (
244+
<CreateAnalyticsFlyoutWrapper {...createAnalyticsForm} />
245+
)}
242246
</Fragment>
243247
);
244248
}

x-pack/legacy/plugins/ml/public/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ import { createPermissionFailureMessage } from '../../../../../privilege/check_p
1414

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

17-
import { CreateAnalyticsAdvancedEditor } from '../create_analytics_advanced_editor';
18-
import { CreateAnalyticsForm } from '../create_analytics_form';
19-
import { CreateAnalyticsFlyout } from '../create_analytics_flyout';
17+
import { CreateAnalyticsFlyoutWrapper } from '../create_analytics_flyout_wrapper';
2018

2119
export const CreateAnalyticsButton: FC<CreateAnalyticsFormProps> = props => {
22-
const { disabled, isAdvancedEditorEnabled, isModalVisible } = props.state;
20+
const { disabled } = props.state;
2321
const { openModal } = props.actions;
2422

2523
const button = (
@@ -51,12 +49,7 @@ export const CreateAnalyticsButton: FC<CreateAnalyticsFormProps> = props => {
5149
return (
5250
<Fragment>
5351
{button}
54-
{isModalVisible && (
55-
<CreateAnalyticsFlyout {...props}>
56-
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
57-
{isAdvancedEditorEnabled === true && <CreateAnalyticsAdvancedEditor {...props} />}
58-
</CreateAnalyticsFlyout>
59-
)}
52+
<CreateAnalyticsFlyoutWrapper {...props} />
6053
</Fragment>
6154
);
6255
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React, { FC } from 'react';
8+
9+
import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';
10+
11+
import { CreateAnalyticsAdvancedEditor } from '../create_analytics_advanced_editor';
12+
import { CreateAnalyticsForm } from '../create_analytics_form';
13+
import { CreateAnalyticsFlyout } from '../create_analytics_flyout';
14+
15+
export const CreateAnalyticsFlyoutWrapper: FC<CreateAnalyticsFormProps> = props => {
16+
const { isAdvancedEditorEnabled, isModalVisible } = props.state;
17+
18+
if (isModalVisible === false) {
19+
return null;
20+
}
21+
22+
return (
23+
<CreateAnalyticsFlyout {...props}>
24+
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
25+
{isAdvancedEditorEnabled === true && <CreateAnalyticsAdvancedEditor {...props} />}
26+
</CreateAnalyticsFlyout>
27+
);
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export { CreateAnalyticsFlyoutWrapper } from './create_analytics_flyout_wrapper';

0 commit comments

Comments
 (0)