diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js index 7cb545cd5a776..56b81e36f1e92 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_datavisualizer_view.js @@ -20,6 +20,7 @@ import { EditFlyout } from '../edit_flyout'; import { ExplanationFlyout } from '../explanation_flyout'; import { ImportView } from '../import_view'; import { + DEFAULT_LINES_TO_SAMPLE, getMaxBytes, readFile, createUrlOverrides, @@ -55,7 +56,9 @@ export class FileDataVisualizerView extends Component { this.overrides = {}; this.previousOverrides = {}; - this.originalSettings = {}; + this.originalSettings = { + linesToSample: DEFAULT_LINES_TO_SAMPLE, + }; this.maxFileUploadBytes = getMaxBytes(); } @@ -129,7 +132,7 @@ export class FileDataVisualizerView extends Component { const serverSettings = processResults(resp); const serverOverrides = resp.overrides; - this.previousOverrides = this.overrides; + this.previousOverrides = overrides; this.overrides = {}; if (serverSettings.format === 'xml') { @@ -185,9 +188,8 @@ export class FileDataVisualizerView extends Component { serverError: error, }); - // as long as the previous overrides are different to the current overrides, // reload the results with the previous overrides - if (overrides !== undefined && isEqual(this.previousOverrides, overrides) === false) { + if (isRetry === false) { this.setState({ loading: true, loaded: false, @@ -244,6 +246,11 @@ export class FileDataVisualizerView extends Component { }; onCancel = () => { + this.overrides = {}; + this.previousOverrides = {}; + this.originalSettings = { + linesToSample: DEFAULT_LINES_TO_SAMPLE, + }; this.changeMode(MODE.READ); this.onFilePickerChange([]); }; @@ -276,7 +283,7 @@ export class FileDataVisualizerView extends Component { return (
{mode === MODE.READ && ( - + <> {!loading && !loaded && } {loading && } @@ -286,10 +293,14 @@ export class FileDataVisualizerView extends Component { )} {fileCouldNotBeRead && loading === false && ( - - + <> + - + )} {loaded && ( @@ -298,8 +309,8 @@ export class FileDataVisualizerView extends Component { explanation={explanation} fileName={fileName} data={fileContents} - showEditFlyout={() => this.showEditFlyout()} - showExplanationFlyout={() => this.showExplanationFlyout()} + showEditFlyout={this.showEditFlyout} + showExplanationFlyout={this.showExplanationFlyout} disableButtons={isEditFlyoutVisible || isExplanationFlyoutVisible} /> )} @@ -317,19 +328,20 @@ export class FileDataVisualizerView extends Component { )} {bottomBarVisible && loaded && ( - + <> + + + )} - - - + )} {mode === MODE.IMPORT && ( - + <> {bottomBarVisible && ( - + <> + + + )} - - - + )}
); @@ -360,10 +373,10 @@ export class FileDataVisualizerView extends Component { function BottomPadding() { // padding for the BottomBar return ( - + <> - + ); } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx index 7333c96a0d8ea..d869676e48827 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/file_datavisualizer_view/file_error_callouts.tsx @@ -7,7 +7,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; -import { EuiCallOut, EuiSpacer } from '@elastic/eui'; +import { EuiCallOut, EuiSpacer, EuiButtonEmpty, EuiHorizontalRule } from '@elastic/eui'; import numeral from '@elastic/numeral'; import { ErrorResponse } from '../../../../../../common/types/errors'; @@ -77,34 +77,57 @@ export const FileTooLarge: FC = ({ fileSize, maxFileSize }) = interface FileCouldNotBeReadProps { error: ErrorResponse; loaded: boolean; + showEditFlyout(): void; } -export const FileCouldNotBeRead: FC = ({ error, loaded }) => { +export const FileCouldNotBeRead: FC = ({ + error, + loaded, + showEditFlyout, +}) => { const message = error?.body?.message || ''; return ( - - } - color="danger" - iconType="cross" - data-test-subj="mlFileUploadErrorCallout fileCouldNotBeRead" - > - {message} - - {loaded && ( - <> - + <> + - - )} - + } + color="danger" + iconType="cross" + data-test-subj="mlFileUploadErrorCallout fileCouldNotBeRead" + > + {loaded === false && ( + <> + +
+ + + + + + )} + {message} + + {loaded && ( + <> + + + + )} +
+ ); }; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/index.ts index 492a797f7a2f2..67d5b1176459b 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/index.ts +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/index.ts @@ -11,4 +11,5 @@ export { readFile, getMaxBytes, getMaxBytesFormatted, + DEFAULT_LINES_TO_SAMPLE, } from './utils'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts index 49ee5ec6b90b0..781f400180b10 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/utils/utils.ts @@ -18,7 +18,7 @@ import { import { getUiSettings } from '../../../../util/dependency_cache'; import { FILE_DATA_VISUALIZER_MAX_FILE_SIZE } from '../../../../../../common/constants/settings'; -const DEFAULT_LINES_TO_SAMPLE = 1000; +export const DEFAULT_LINES_TO_SAMPLE = 1000; const UPLOAD_SIZE_MB = 5; const overrideDefaults = {