Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ export const FLYOUT_CONTINUE_BUTTON = i18n.translate(
{ defaultMessage: 'Continue' }
);

export const DOCUMENT_CREATION_ERRORS = {
NO_FILE: i18n.translate('xpack.enterpriseSearch.appSearch.documentCreation.noFileFound', {
defaultMessage: 'No file found.',
}),
NO_VALID_FILE: i18n.translate('xpack.enterpriseSearch.appSearch.documentCreation.noValidFile', {
defaultMessage: 'Problem parsing file.',
}),
NOT_VALID: i18n.translate('xpack.enterpriseSearch.appSearch.documentCreation.notValidJson', {
defaultMessage: 'Document contents must be a valid JSON array or object.',
}),
};
export const DOCUMENT_CREATION_WARNINGS = {
LARGE_FILE: i18n.translate('xpack.enterpriseSearch.appSearch.documentCreation.largeFile', {
defaultMessage:
"You're uploading an extremely large file. This could potentially lock your browser, or take a very long time to process. If possible, try splitting your data up into multiple smaller files.",
}),
};

// This is indented the way it is to work with ApiCodeExample.
// Use dedent() when calling this alone
export const DOCUMENTS_API_JSON_EXAMPLE = `[
Expand Down
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 { Summary } from './summary';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 from 'react';

export const Summary: React.FC = () => {
return <>TODO</>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
PasteJsonText,
UploadJsonFile,
} from './creation_mode_components';
import { Summary } from './creation_response_components';
import { DocumentCreationStep } from './types';

import { DocumentCreationFlyout, FlyoutContent } from './document_creation_flyout';
Expand Down Expand Up @@ -82,28 +83,11 @@ describe('DocumentCreationFlyout', () => {
});
});

describe('creation steps', () => {
it('renders an error page', () => {
setMockValues({ ...values, creationStep: DocumentCreationStep.ShowError });
const wrapper = shallow(<FlyoutContent />);

expect(wrapper.text()).toBe('DocumentCreationError'); // TODO: actual component
});

it('renders an error summary', () => {
setMockValues({ ...values, creationStep: DocumentCreationStep.ShowErrorSummary });
const wrapper = shallow(<FlyoutContent />);

expect(wrapper.text()).toBe('DocumentCreationSummary'); // TODO: actual component
});

it('renders a success summary', () => {
setMockValues({ ...values, creationStep: DocumentCreationStep.ShowSuccessSummary });
const wrapper = shallow(<FlyoutContent />);
it('renders a summary', () => {
setMockValues({ ...values, creationStep: DocumentCreationStep.ShowSummary });
const wrapper = shallow(<FlyoutContent />);

// TODO: Figure out if the error and success summary should remain the same vs different components
expect(wrapper.text()).toBe('DocumentCreationSummary'); // TODO: actual component
});
expect(wrapper.find(Summary)).toHaveLength(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
PasteJsonText,
Comment thread
cee-chen marked this conversation as resolved.
UploadJsonFile,
} from './creation_mode_components';
import { Summary } from './creation_response_components';

export const DocumentCreationFlyout: React.FC = () => {
const { closeDocumentCreation } = useActions(DocumentCreationLogic);
Expand Down Expand Up @@ -48,11 +49,7 @@ export const FlyoutContent: React.FC = () => {
case 'file':
return <UploadJsonFile />;
}
case DocumentCreationStep.ShowError:
return <>DocumentCreationError</>;
case DocumentCreationStep.ShowErrorSummary:
return <>DocumentCreationSummary</>;
case DocumentCreationStep.ShowSuccessSummary:
return <>DocumentCreationSummary</>;
case DocumentCreationStep.ShowSummary:
return <Summary />;
}
};
Loading