Skip to content

Commit

Permalink
[ML] DF Analytics: Ensure creation flyout can be opened when no jobs …
Browse files Browse the repository at this point in the history
…exist (#50417)

* Ensure create flyout can be open when no jobs exist

* remove redundant isModalVisible check
  • Loading branch information
alvarezmelissa87 authored Nov 14, 2019
1 parent 30a70b3 commit 2516f94
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
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 @@ -239,6 +240,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,28 @@
/*
* 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, { 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 (
<CreateAnalyticsFlyout {...props}>
{isAdvancedEditorEnabled === false && <CreateAnalyticsForm {...props} />}
{isAdvancedEditorEnabled === true && <CreateAnalyticsAdvancedEditor {...props} />}
</CreateAnalyticsFlyout>
);
};
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';

0 comments on commit 2516f94

Please sign in to comment.