mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[ML] Making creation of data view during file upload optional (#210208)
Adds an option override to tell the file uploader not to create a data view once ingest has finished. This is currently not used but should be used in the near future when creating lookup indices from the es|ql query bar. The PR also contains some typing clean up to remove duplication. **Before**  **After** 
This commit is contained in:
parent
d34ee93dcf
commit
9fa8ec42a6
10 changed files with 50 additions and 23 deletions
|
@ -18,4 +18,5 @@ export interface OpenFileUploadLiteContext {
|
|||
onUploadComplete?: (results: FileUploadResults | null) => void;
|
||||
indexSettings?: IndicesIndexSettings;
|
||||
autoAddInference?: string;
|
||||
autoCreateDataView?: boolean;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ export class FileManager {
|
|||
indexCreated: STATUS.NOT_STARTED,
|
||||
pipelineCreated: STATUS.NOT_STARTED,
|
||||
modelDeployed: STATUS.NA,
|
||||
dataViewCreated: STATUS.NA,
|
||||
dataViewCreated: STATUS.NOT_STARTED,
|
||||
pipelinesDeleted: STATUS.NOT_STARTED,
|
||||
fileImport: STATUS.NOT_STARTED,
|
||||
filesStatus: [],
|
||||
|
@ -91,6 +91,7 @@ export class FileManager {
|
|||
private http: HttpSetup,
|
||||
private dataViewsContract: DataViewsServicePublic,
|
||||
private autoAddInferenceEndpointName: string | null = null,
|
||||
private autoCreateDataView: boolean = true,
|
||||
private removePipelinesAfterImport: boolean = true,
|
||||
indexSettingsOverride: IndicesIndexSettings | undefined = undefined
|
||||
) {
|
||||
|
@ -225,10 +226,7 @@ export class FileManager {
|
|||
return files.map((file) => file.getPipeline());
|
||||
}
|
||||
|
||||
public async import(
|
||||
indexName: string,
|
||||
createDataView: boolean = true
|
||||
): Promise<FileUploadResults | null> {
|
||||
public async import(indexName: string): Promise<FileUploadResults | null> {
|
||||
if (this.mappings === null || this.pipelines === null || this.commonFileFormat === null) {
|
||||
this.setStatus({
|
||||
overallImportStatus: STATUS.FAILED,
|
||||
|
@ -239,6 +237,7 @@ export class FileManager {
|
|||
|
||||
this.setStatus({
|
||||
overallImportStatus: STATUS.STARTED,
|
||||
dataViewCreated: this.autoCreateDataView ? STATUS.NOT_STARTED : STATUS.NA,
|
||||
});
|
||||
|
||||
this.importer = await this.fileUpload.importerFactory(this.commonFileFormat, {});
|
||||
|
@ -372,7 +371,7 @@ export class FileManager {
|
|||
|
||||
const dataView = '';
|
||||
let dataViewResp;
|
||||
if (createDataView) {
|
||||
if (this.autoCreateDataView) {
|
||||
this.setStatus({
|
||||
dataViewCreated: STATUS.STARTED,
|
||||
});
|
||||
|
|
|
@ -20,6 +20,7 @@ export interface Props {
|
|||
getAdditionalLinks?: GetAdditionalLinks;
|
||||
setUploadResults?: (results: FileUploadResults) => void;
|
||||
autoAddInference?: string;
|
||||
autoCreateDataView?: boolean;
|
||||
indexSettings?: IndicesIndexSettings;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
@ -29,6 +30,7 @@ export const FileDataVisualizerLite: FC<Props> = ({
|
|||
resultLinks,
|
||||
setUploadResults,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
onClose,
|
||||
}) => {
|
||||
|
@ -60,6 +62,7 @@ export const FileDataVisualizerLite: FC<Props> = ({
|
|||
capabilities={coreStart.application.capabilities}
|
||||
setUploadResults={setUploadResults}
|
||||
autoAddInference={autoAddInference}
|
||||
autoCreateDataView={autoCreateDataView}
|
||||
indexSettings={indexSettings}
|
||||
onClose={onClose}
|
||||
/>
|
||||
|
|
|
@ -44,6 +44,7 @@ export function createOpenFileUploadLiteAction(
|
|||
async execute({
|
||||
onUploadComplete,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
}: OpenFileUploadLiteContext) {
|
||||
try {
|
||||
|
@ -52,6 +53,7 @@ export function createOpenFileUploadLiteAction(
|
|||
createFlyout(coreStart, share, data, {
|
||||
onUploadComplete,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
|
@ -48,6 +48,7 @@ interface Props {
|
|||
getAdditionalLinks?: GetAdditionalLinks;
|
||||
setUploadResults?: (results: FileUploadResults) => void;
|
||||
autoAddInference?: string;
|
||||
autoCreateDataView?: boolean;
|
||||
indexSettings?: IndicesIndexSettings;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
@ -58,6 +59,7 @@ export const FileUploadLiteView: FC<Props> = ({
|
|||
dataStart,
|
||||
setUploadResults,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
onClose,
|
||||
}) => {
|
||||
|
@ -71,10 +73,11 @@ export const FileUploadLiteView: FC<Props> = ({
|
|||
http,
|
||||
dataStart.dataViews,
|
||||
autoAddInference ?? null,
|
||||
autoCreateDataView,
|
||||
true,
|
||||
indexSettings
|
||||
),
|
||||
[autoAddInference, dataStart.dataViews, fileUpload, http, indexSettings]
|
||||
[autoAddInference, autoCreateDataView, dataStart.dataViews, fileUpload, http, indexSettings]
|
||||
);
|
||||
const deleteFile = useCallback((i: number) => fm.removeFile(i), [fm]);
|
||||
|
||||
|
|
|
@ -18,15 +18,24 @@ export const FileDataVisualizerLiteWrapper: FC<{
|
|||
resultLinks?: ResultLinks;
|
||||
setUploadResults?: (results: FileUploadResults) => void;
|
||||
autoAddInference?: string;
|
||||
autoCreateDataView?: boolean;
|
||||
indexSettings?: IndicesIndexSettings;
|
||||
onClose?: () => void;
|
||||
}> = ({ resultLinks, setUploadResults, autoAddInference, indexSettings, onClose }) => {
|
||||
}> = ({
|
||||
resultLinks,
|
||||
setUploadResults,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
onClose,
|
||||
}) => {
|
||||
return (
|
||||
<React.Suspense fallback={<div />}>
|
||||
<FileDataVisualizerLiteComponent
|
||||
resultLinks={resultLinks}
|
||||
setUploadResults={setUploadResults}
|
||||
autoAddInference={autoAddInference}
|
||||
autoCreateDataView={autoCreateDataView}
|
||||
indexSettings={indexSettings}
|
||||
onClose={onClose}
|
||||
/>
|
||||
|
@ -38,6 +47,7 @@ export function getFileDataVisualizerLiteWrapper(
|
|||
resultLinks?: ResultLinks,
|
||||
setUploadResults?: (results: FileUploadResults) => void,
|
||||
autoAddInference?: string,
|
||||
autoCreateDataView?: boolean,
|
||||
indexSettings?: IndicesIndexSettings,
|
||||
onClose?: () => void
|
||||
) {
|
||||
|
@ -46,6 +56,7 @@ export function getFileDataVisualizerLiteWrapper(
|
|||
resultLinks={resultLinks}
|
||||
setUploadResults={setUploadResults}
|
||||
autoAddInference={autoAddInference}
|
||||
autoCreateDataView={autoCreateDataView}
|
||||
indexSettings={indexSettings}
|
||||
onClose={onClose}
|
||||
/>
|
||||
|
|
|
@ -38,7 +38,7 @@ export function createFlyout(
|
|||
});
|
||||
|
||||
let results: FileUploadResults | null = null;
|
||||
const { onUploadComplete, autoAddInference, indexSettings } = props;
|
||||
const { onUploadComplete, autoAddInference, autoCreateDataView, indexSettings } = props;
|
||||
|
||||
const onFlyoutClose = () => {
|
||||
flyoutSession.close();
|
||||
|
@ -54,7 +54,7 @@ export function createFlyout(
|
|||
coreStart={coreStart}
|
||||
share={share}
|
||||
data={data}
|
||||
props={{ autoAddInference, indexSettings }}
|
||||
props={{ autoAddInference, autoCreateDataView, indexSettings }}
|
||||
onFlyoutClose={onFlyoutClose}
|
||||
setUploadResults={(res) => {
|
||||
if (res) {
|
||||
|
|
|
@ -16,6 +16,7 @@ interface Props {
|
|||
onClose?: () => void;
|
||||
setUploadResults?: (results: FileUploadResults) => void;
|
||||
autoAddInference?: string;
|
||||
autoCreateDataView?: boolean;
|
||||
indexSettings?: IndicesIndexSettings;
|
||||
}
|
||||
|
||||
|
@ -23,12 +24,14 @@ export const FileUploadLiteFlyoutContents: FC<Props> = ({
|
|||
onClose,
|
||||
setUploadResults,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
}) => {
|
||||
const Wrapper = getFileDataVisualizerLiteWrapper(
|
||||
undefined,
|
||||
setUploadResults,
|
||||
autoAddInference,
|
||||
autoCreateDataView,
|
||||
indexSettings,
|
||||
onClose
|
||||
);
|
||||
|
|
|
@ -27,7 +27,7 @@ export const FlyoutContents: FC<Props> = ({
|
|||
coreStart,
|
||||
share,
|
||||
data,
|
||||
props: { autoAddInference, indexSettings },
|
||||
props: { autoAddInference, autoCreateDataView, indexSettings },
|
||||
onFlyoutClose,
|
||||
setUploadResults,
|
||||
}) => {
|
||||
|
@ -41,6 +41,7 @@ export const FlyoutContents: FC<Props> = ({
|
|||
>
|
||||
<FileUploadLiteFlyoutContents
|
||||
autoAddInference={autoAddInference}
|
||||
autoCreateDataView={autoCreateDataView}
|
||||
indexSettings={indexSettings}
|
||||
onClose={() => {
|
||||
onFlyoutClose();
|
||||
|
|
|
@ -80,13 +80,21 @@ export const OverallUploadStatus: FC<Props> = ({ filesStatus, uploadStatus }) =>
|
|||
),
|
||||
status: generateStatus([uploadStatus.fileImport]),
|
||||
},
|
||||
...(uploadStatus.dataViewCreated === STATUS.NA
|
||||
? []
|
||||
: [
|
||||
{
|
||||
title: i18n.translate(
|
||||
'xpack.dataVisualizer.file.overallUploadStatus.creatingDataView',
|
||||
{
|
||||
title: i18n.translate('xpack.dataVisualizer.file.overallUploadStatus.creatingDataView', {
|
||||
defaultMessage: 'Creating data view',
|
||||
}),
|
||||
}
|
||||
),
|
||||
children: <></>,
|
||||
status: generateStatus([uploadStatus.dataViewCreated]),
|
||||
},
|
||||
]),
|
||||
|
||||
{
|
||||
title: i18n.translate('xpack.dataVisualizer.file.overallUploadStatus.uploadComplete', {
|
||||
defaultMessage: 'Upload complete',
|
||||
|
@ -96,9 +104,5 @@ export const OverallUploadStatus: FC<Props> = ({ filesStatus, uploadStatus }) =>
|
|||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<EuiSteps steps={steps} titleSize="xxs" css={css} />
|
||||
</>
|
||||
);
|
||||
return <EuiSteps steps={steps} titleSize="xxs" css={css} />;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue