- `;
-};
-
-// TODO: merge this function and popoverMenu() into one
-export const popoverMenuDiscover = (savedObjectAvailable) => {
- const buttonClass = savedObjectAvailable
- ? 'euiContextMenuItem'
- : 'euiContextMenuItem euiContextMenuItem-isDisabled';
- const button = savedObjectAvailable ? 'button' : 'button disabled';
- const popoverHeight = savedObjectAvailable ? '354px' : '322px';
- const message = savedObjectAvailable
- ? i18n.translate('opensearch.reports.menu.csv.waitPrompt', {
- defaultMessage:
- 'Files can take a minute or two to generate depending on the size of your source data.',
- })
- : i18n.translate('opensearch.reports.menu.csv.savePrompt', {
- defaultMessage: 'Save this search to enable CSV reports.',
- });
- const arrowRight = '60px';
- const popoverRight = '77px';
-
- return `
-
-
-
-
-
-
-
- `;
-};
-
-export const permissionsMissingOnGeneration = () => {
- return `
-
-
${i18n.translate(
- 'opensearch.reports.menu.newNotificationAppears',
- { defaultMessage: 'A new notification appears' }
- )}
-
-
-
-
-
-
-
-
-
-
-
${i18n.translate('opensearch.reports.menu.insufficientPermissions', {
- defaultMessage:
- 'Insufficient permissions. Reach out to your OpenSearch Dashboards administrator.',
- })}
-
-
- `;
-};
-
-export const reportGenerationSuccess = () => {
- return `
-
-
A new notification appears
-
-
-
-
-
-
-
-
-
-
-
- `;
-};
-
-export const reportGenerationFailure = (
- title = i18n.translate('opensearch.reports.menu.downloadError', {
- defaultMessage: 'Download error',
- }),
- text = i18n.translate('opensearch.reports.menu.errorGeneratingThisReport', {
- defaultMessage: 'There was an error generating this report.',
- })
-) => {
- return `
-
-
A new notification appears
-
-
-
-
-
-
-
-
-
-
-
- `;
-};
-
-export const reportGenerationInProgressModal = () => {
- return `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
${i18n.translate(
- 'opensearch.reports.menu.progress.preparingYourFile',
- { defaultMessage: 'Preparing your file for download.' }
- )}
-
${i18n.translate(
- 'opensearch.reports.menu.progress.youCanClose',
- {
- defaultMessage:
- 'Please keep this dialog open while report is being generated.',
- }
- )}
-
-
-
-
-
-
-
-
-
-
- `;
-};
diff --git a/dashboards-reports/public/components/main/__tests__/__snapshots__/main.test.tsx.snap b/dashboards-reports/public/components/main/__tests__/__snapshots__/main.test.tsx.snap
deleted file mode 100644
index 7f552895..00000000
--- a/dashboards-reports/public/components/main/__tests__/__snapshots__/main.test.tsx.snap
+++ /dev/null
@@ -1,3908 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`
panel render component 1`] = `
-
-
-
-
-
- Reports
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No reports to display
-
-
-
-
-
-
- Create a report definition, or share/download a report from a dashboard, saved search or visualization.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report definitions
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No report definitions to display
-
-
-
-
-
-
- Create a new report definition to get started
-
-
-
-
-
-
-
-
-
-
- Create report definition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render component after create success 1`] = `
-
-
-
-
-
- Reports
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No reports to display
-
-
-
-
-
-
- Create a report definition, or share/download a report from a dashboard, saved search or visualization.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report definitions
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No report definitions to display
-
-
-
-
-
-
- Create a new report definition to get started
-
-
-
-
-
-
-
-
-
-
- Create report definition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A new notification appears
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render component after delete success 1`] = `
-
-
-
-
-
- Reports
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No reports to display
-
-
-
-
-
-
- Create a report definition, or share/download a report from a dashboard, saved search or visualization.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report definitions
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No report definitions to display
-
-
-
-
-
-
- Create a new report definition to get started
-
-
-
-
-
-
-
-
-
-
- Create report definition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A new notification appears
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render component after edit success 1`] = `
-
-
-
-
-
- Reports
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No reports to display
-
-
-
-
-
-
- Create a report definition, or share/download a report from a dashboard, saved search or visualization.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report definitions
-
-
- (
- 0
- )
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No report definitions to display
-
-
-
-
-
-
- Create a new report definition to get started
-
-
-
-
-
-
-
-
-
-
- Create report definition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A new notification appears
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/main/__tests__/__snapshots__/report_definitions_table.test.tsx.snap b/dashboards-reports/public/components/main/__tests__/__snapshots__/report_definitions_table.test.tsx.snap
deleted file mode 100644
index a2a56bfd..00000000
--- a/dashboards-reports/public/components/main/__tests__/__snapshots__/report_definitions_table.test.tsx.snap
+++ /dev/null
@@ -1,954 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`
panel render component 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- test report name
-
-
-
-
-
-
-
- Dashboard
-
-
-
-
-
-
-
- Download
-
-
-
-
-
-
-
-
-
-
-
-
-
- Invalid Date @ Invalid Date
-
-
-
-
-
-
-
- Created
-
-
-
-
-
-
-
-
-
- test report name 2
-
-
-
-
-
-
-
- Dashboard
-
-
-
-
-
-
-
- Download
-
-
-
-
-
-
-
-
-
-
-
-
-
- Invalid Date @ Invalid Date
-
-
-
-
-
-
-
- Created
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Rows per page
- :
- 10
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render empty table 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No report definitions to display
-
-
-
-
-
-
- Create a new report definition to get started
-
-
-
-
-
-
-
-
-
-
- Create report definition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/main/__tests__/__snapshots__/reports_table.test.tsx.snap b/dashboards-reports/public/components/main/__tests__/__snapshots__/reports_table.test.tsx.snap
deleted file mode 100644
index d2593c6e..00000000
--- a/dashboards-reports/public/components/main/__tests__/__snapshots__/reports_table.test.tsx.snap
+++ /dev/null
@@ -1,1025 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`
panel render component 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- test report table item
-
-
-
-
-
-
-
-
-
-
-
- Test type
-
-
-
-
-
-
-
- Invalid Date @ Invalid Date
-
-
-
-
-
-
-
- Created
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Rows per page
- :
- 10
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render empty component 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- State
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No reports to display
-
-
-
-
-
-
- Create a report definition, or share/download a report from a dashboard, saved search or visualization.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/main/__tests__/__utils__/main_utils_test_utils.tsx b/dashboards-reports/public/components/main/__tests__/__utils__/main_utils_test_utils.tsx
deleted file mode 100644
index 28e8e36b..00000000
--- a/dashboards-reports/public/components/main/__tests__/__utils__/main_utils_test_utils.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export const reportTableMockResponse = [
- {
- _id: '123456',
- _index: 'test',
- _score: 1,
- _source: {
- last_updated: 123456789,
- query_url: 'test_query_url_value.com',
- report_definition: {
- delivery: {
- delivery_type: 'OpenSearch Dashboards user',
- delivery_params: {
- opensearch_dashboards_recipients: [],
- },
- },
- report_params: {
- report_name: 'Test report table response',
- description: 'description',
- report_source: 'Dashboard',
- core_params: {
- base_url: 'test_base_url.com',
- header: '',
- footer: '',
- report_format: 'pdf',
- time_duration: 'PT30M',
- window_height: 800,
- window_width: 1200,
- },
- },
- trigger: {
- trigger_type: 'On demand',
- },
- state: 'Created',
- time_created: 123456780,
- time_from: 123456780,
- time_to: 123456799,
- },
- },
- _type: 'doc',
- },
-];
-
-export const mockReportsTableItems = [
- {
- id: '123456',
- reportName: 'Test report table response',
- type: 'On demand',
- sender: '—',
- opensearchDashboardsRecipients: '—',
- emailRecipients: '—',
- reportSource: 'Dashboard',
- timeCreated: undefined,
- state: undefined,
- url: 'test_query_url_value.com',
- format: 'pdf',
- },
-];
-
-export const reportDefinitionsTableMockResponse = [
- {
- _index: 'report_definition',
- _type: '_doc',
- _id: '42MmKXUBDW-VXnk7pa6d',
- _score: 1,
- _source: {
- report_definition: {
- report_params: {
- report_name: 'schedule definition',
- report_source: 'Dashboard',
- description: 'description',
- core_params: {
- base_url: 'test_base_url.com',
- report_format: 'pdf',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- window_width: 1200,
- window_height: 800,
- },
- },
- delivery: {
- delivery_type: 'OpenSearch Dashboards user',
- delivery_params: { opensearch_dashboards_recipients: [] },
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- enabled_time: 1602713178321,
- schedule: {
- period: 1,
- interval: 'DAYS',
- },
- schedule_type: 'Recurring',
- enabled: false,
- },
- },
- time_created: 1602713199604,
- last_updated: 1602713211007,
- status: 'Disabled',
- },
- },
- },
-];
-
-export const reportDefinitionsTableMockContent = [
- {
- id: '42MmKXUBDW-VXnk7pa6d',
- reportName: 'schedule definition',
- type: 'Schedule',
- owner: '—',
- source: 'Dashboard',
- baseUrl: 'test_base_url.com',
- lastUpdated: 1602713211007,
- details: 'Recurring',
- status: 'Disabled',
- },
-];
diff --git a/dashboards-reports/public/components/main/__tests__/main.test.tsx b/dashboards-reports/public/components/main/__tests__/main.test.tsx
deleted file mode 100644
index 3142326e..00000000
--- a/dashboards-reports/public/components/main/__tests__/main.test.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { Main } from '../main';
-import httpClientMock from '../../../../test/httpMockClient';
-import { configure, mount } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
-import { act } from 'react-dom/test-utils';
-
-function setBreadcrumbs(array: []) {
- jest.fn();
-}
-
-describe('
panel', () => {
- configure({ adapter: new Adapter() });
- test('render component', (done) => {
- window = Object.create(window);
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- assign: jest.fn(),
- href: 'reports-dashboards#/',
- },
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- done();
- });
-
- test('render component after create success', async () => {
- delete window.location;
-
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- assign: jest.fn(),
- href: 'reports-dashboards#/create=success',
- },
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render component after edit success', async () => {
- delete window.location;
-
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- assign: jest.fn(),
- href: 'reports-dashboards#/edit=success',
- },
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render component after delete success', async () => {
- delete window.location;
-
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- assign: jest.fn(),
- href: 'reports-dashboards#/delete=success',
- },
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- })
-
- test('test refresh reports definitions button', async () => {
- const promise = Promise.resolve();
- const data = [
- {
- _id: 'abcdefg',
- _source: {
- query_url: '/app/visualize/edit/1234567890',
- state: 'Created',
- time_created: 123456789,
- time_from: 123456789,
- time_to: 1234567890,
- report_definition: {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'png',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {},
- },
- },
- },
- },
- ];
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- data,
- });
-
- const component = mount(
-
- );
- await act(() => promise);
-
- const generate = component.find('button').at(7);
- generate.simulate('click');
- await act(() => promise);
- });
-
- test('test refresh reports table button', async () => {
- const promise = Promise.resolve();
- const data = [
- {
- _id: 'abcdefg',
- _source: {
- query_url: '/app/visualize/edit/1234567890',
- state: 'Created',
- time_created: 123456789,
- time_from: 123456789,
- time_to: 1234567890,
- report_definition: {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'png',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {},
- },
- },
- },
- },
- ];
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- data,
- });
-
- const component = mount(
-
- );
- await act(() => promise);
-
- const generate = component.find('button').at(0);
- generate.simulate('click');
- await act(() => promise);
- });
-
- // TODO: mock catch() error response to contain status code
- test.skip('test error toasts posted', async () => {
- jest.spyOn(console, 'log').mockImplementation(() => {}); // silence console log error from main
- const promise = Promise.resolve();
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- response: null,
- });
-
- const component = mount(
-
- );
- const generate = component.find('button').at(7);
- try {
- generate.simulate('click');
- await act(() => promise);
- } catch (e) {
- await act(() => promise);
- }
- });
-});
diff --git a/dashboards-reports/public/components/main/__tests__/main_utils.test.tsx b/dashboards-reports/public/components/main/__tests__/main_utils.test.tsx
deleted file mode 100644
index 8f852a45..00000000
--- a/dashboards-reports/public/components/main/__tests__/main_utils.test.tsx
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import {
- humanReadableDate,
- extractFilename,
- extractFileFormat,
- getFileFormatPrefix,
- addReportsTableContent,
- addReportDefinitionsTableContent,
- removeDuplicatePdfFileFormat,
- readStreamToFile,
- generateReportFromDefinitionId,
- generateReportById,
-} from '../main_utils';
-import {
- reportDefinitionsTableMockResponse,
- mockReportsTableItems,
- reportTableMockResponse,
- reportDefinitionsTableMockContent,
-} from './__utils__/main_utils_test_utils';
-import sinon from 'sinon';
-import httpClientMock from '../../../../test/httpMockClient';
-
-describe('main_utils tests', () => {
- global.URL.createObjectURL = jest.fn();
- let mockElement = document.createElement('a');
- mockElement.download = 'string';
- mockElement.click = function name() {};
- sinon.stub(document, 'createElement').returns(mockElement);
-
- test('test humanReadableDate', () => {
- const readableDate = new Date(2018, 11, 24, 10, 33, 30);
- const humanReadable = humanReadableDate(readableDate);
-
- expect(humanReadable).toBe('Mon Dec 24 2018 @ 10:33:30 AM');
- });
-
- test('test extractFileName', () => {
- const fullFile = 'test_file_name_extracted_correctly.pdf';
- const fileName = extractFilename(fullFile);
-
- expect(fileName).toBe('test_file_name_extracted_correctly');
- });
-
- test('test extractFileFormat', () => {
- const fullFile = 'test_file_format_extracted_correctly.png';
- const fileFormat = extractFileFormat(fullFile);
-
- expect(fileFormat).toBe('png');
- });
-
- test('test getFileFormatPrefix', () => {
- const fileFormat = 'pdf';
- const fileFormatPrefix = getFileFormatPrefix(fileFormat);
-
- expect(fileFormatPrefix).toBe('data:pdf;base64,');
- });
-
- test('test addReportsTableContent', () => {
- const reportsTableItems = addReportsTableContent(reportTableMockResponse);
-
- expect(reportsTableItems).toStrictEqual(mockReportsTableItems);
- });
-
- test('test addReportDefinitionsTableContent', () => {
- const reportDefinitionsTableItems = addReportDefinitionsTableContent(
- reportDefinitionsTableMockResponse
- );
-
- expect(reportDefinitionsTableItems).toStrictEqual(
- reportDefinitionsTableMockContent
- );
- });
-
- test('test removeDuplicatePdfFileFormat', () => {
- const duplicateFormat = 'test_duplicate_remove.pdf.pdf';
- const duplicateRemoved = removeDuplicatePdfFileFormat(duplicateFormat);
-
- expect(duplicateRemoved).toBe('test_duplicate_remove.pdf');
- });
-
- test('test readStreamToFile csv compile', () => {
- const stream =
- 'category,customer_gender\n' +
- 'c1,Male\n' +
- 'c2,Male\n' +
- 'c3,Male\n' +
- 'c4,Male\n' +
- 'c5,Male';
-
- const fileFormat = 'csv';
- const fileName = 'test_data_report.csv';
- readStreamToFile(stream, fileFormat, fileName);
- });
-
- test('test readStreamToFile pdf compile', () => {
- const stream = 'data:pdf;base64,zxvniaorbguw40absdoanlsdf';
- const fileFormat = 'pdf';
- const fileName = 'test_pdf_report.pdf';
- readStreamToFile(stream, fileFormat, fileName);
- });
-
- test('test generateReport compile', () => {
- const reportDefinitionId = '1';
- generateReportFromDefinitionId(reportDefinitionId, httpClientMock);
- });
-
- test('test generateReportById compile', () => {
- const reportId = '1';
- const handleSuccessToast = jest.fn();
- const handleErrorToast = jest.fn();
- generateReportById(
- reportId,
- httpClientMock,
- handleSuccessToast,
- handleErrorToast
- );
- });
-
- test('test generateReportById timeout error handling', async () => {
- expect.assertions(1);
- const reportId = '1';
- const handleSuccessToast = jest.fn();
- const handleErrorToast = jest.fn();
- const handlePermissionsMissingToast = jest.fn();
-
- httpClientMock.get.mockReturnValue(
- Promise.reject({ body: { statusCode: 503 } })
- );
-
- await generateReportById(
- reportId,
- httpClientMock,
- handleSuccessToast,
- handleErrorToast,
- handlePermissionsMissingToast
- );
- expect(handleErrorToast).toHaveBeenCalledWith(
- 'Error generating report.',
- 'Timed out generating report ID 1. Try again later.'
- );
- });
-});
diff --git a/dashboards-reports/public/components/main/__tests__/report_definitions_table.test.tsx b/dashboards-reports/public/components/main/__tests__/report_definitions_table.test.tsx
deleted file mode 100644
index c6ff2d63..00000000
--- a/dashboards-reports/public/components/main/__tests__/report_definitions_table.test.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { ReportDefinitions } from '../report_definitions_table';
-import { configure, mount } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
-
-const pagination = {
- initialPageSize: 10,
- pageSizeOptions: [8, 10, 13],
-};
-
-describe('
panel', () => {
- configure({ adapter: new Adapter() });
- test('render component', () => {
- let reportDefinitionsTableContent = [
- {
- reportName: 'test report name',
- type: 'Download',
- owner: 'davidcui',
- source: 'Dashboard',
- lastUpdated: 'test updated time',
- details: '',
- status: 'Created',
- },
- {
- reportName: 'test report name 2',
- type: 'Download',
- owner: 'davidcui',
- source: 'Dashboard',
- lastUpdated: 'test updated time',
- details: '',
- status: 'Created',
- },
- ];
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render empty table', () => {
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('test click on report definition row', async () => {
- window = Object.create(window);
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- assign: jest.fn(),
- },
- });
- let promise = Promise.resolve();
- let reportDefinitionsTableContent = [
- {
- reportName: 'test report name',
- type: 'Download',
- owner: 'davidcui',
- source: 'Dashboard',
- lastUpdated: 'test updated time',
- details: '',
- status: 'Created',
- },
- {
- reportName: 'test report name 2',
- type: 'Download',
- owner: 'davidcui',
- source: 'Dashboard',
- lastUpdated: 'test updated time',
- details: '',
- status: 'Created',
- },
- ];
-
- const component = mount(
-
- );
-
- const nameLink = component.find('button').at(3);
- nameLink.simulate('click');
- });
-});
diff --git a/dashboards-reports/public/components/main/__tests__/reports_table.test.tsx b/dashboards-reports/public/components/main/__tests__/reports_table.test.tsx
deleted file mode 100644
index 0ec69731..00000000
--- a/dashboards-reports/public/components/main/__tests__/reports_table.test.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { ReportsTable } from '../reports_table';
-import httpClientMock from '../../../../test/httpMockClient';
-import { configure, mount } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
-import { act } from 'react-dom/test-utils';
-
-const pagination = {
- initialPageSize: 10,
- pageSizeOptions: [8, 10, 13],
-};
-
-describe('
panel', () => {
- configure({ adapter: new Adapter() });
- test('render component', () => {
- let reportsTableItems = [
- {
- id: '1',
- reportName: 'test report table item',
- type: 'Test type',
- sender: 'N/A',
- recipients: 'N/A',
- reportSource: 'Test report source',
- lastUpdated: 'test updated time',
- state: 'Created',
- url: 'Test url',
- },
- ];
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render empty component', async () => {
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('click on generate button', async () => {
- const promise = Promise.resolve();
- let reportsTableItems = [
- {
- id: '1',
- reportName: 'test report table item',
- type: 'Test type',
- sender: 'N/A',
- recipients: 'N/A',
- reportSource: 'Test report source',
- lastUpdated: 'test updated time',
- state: 'Created',
- url: 'Test url',
- },
- ];
-
- const component = mount(
-
- );
-
- const generateClick = component.find('button').at(6);
- // console.log(generateClick.debug());
- generateClick.simulate('click');
- await act(() => promise);
- });
-});
diff --git a/dashboards-reports/public/components/main/index.ts b/dashboards-reports/public/components/main/index.ts
deleted file mode 100644
index 7dd7bc03..00000000
--- a/dashboards-reports/public/components/main/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { Main } from './main';
-export { ReportDetails } from './report_details/report_details';
diff --git a/dashboards-reports/public/components/main/loading_modal/index.ts b/dashboards-reports/public/components/main/loading_modal/index.ts
deleted file mode 100644
index 2f6c609b..00000000
--- a/dashboards-reports/public/components/main/loading_modal/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
- export { GenerateReportLoadingModal } from './loading_modal';
\ No newline at end of file
diff --git a/dashboards-reports/public/components/main/loading_modal/loading_modal.tsx b/dashboards-reports/public/components/main/loading_modal/loading_modal.tsx
deleted file mode 100644
index 61c53968..00000000
--- a/dashboards-reports/public/components/main/loading_modal/loading_modal.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import {
- EuiOverlayMask,
- EuiModal,
- EuiModalHeader,
- EuiTitle,
- EuiText,
- EuiModalBody,
- EuiSpacer,
- EuiFlexGroup,
- EuiFlexItem,
- EuiLoadingSpinner,
- EuiButton,
-} from '@elastic/eui';
-import { i18n } from '@osd/i18n';
-import React, { useState } from 'react';
-
-export function GenerateReportLoadingModal(props: { setShowLoading: any }) {
- const { setShowLoading } = props;
-
- const [isModalVisible, setIsModalVisible] = useState(true);
-
- const closeModal = () => {
- setIsModalVisible(false);
- setShowLoading(false);
- };
- const showModal = () => setIsModalVisible(true);
-
- return (
-
-
-
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.loading.generatingReport',
- { defaultMessage: 'Generating report' }
- )}
-
-
-
-
-
-
- {i18n.translate('opensearch.reports.loading.preparingYourFile', {
- defaultMessage: 'Preparing your file for download.',
- })}
-
-
- {i18n.translate('opensearch.reports.loading.youCanClose', {
- defaultMessage:
- 'Please keep this dialog open while report is being generated.',
- })}
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/main/main.tsx b/dashboards-reports/public/components/main/main.tsx
deleted file mode 100644
index bfbb8cb9..00000000
--- a/dashboards-reports/public/components/main/main.tsx
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { Fragment, useState, useEffect } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiFlexGroup,
- EuiFlexItem,
- EuiButton,
- EuiTitle,
- // @ts-ignore
- EuiHorizontalRule,
- EuiSpacer,
- EuiPanel,
- EuiGlobalToastList,
-} from '@elastic/eui';
-import { ReportsTable } from './reports_table';
-import { ReportDefinitions } from './report_definitions_table';
-import {
- addReportsTableContent,
- addReportDefinitionsTableContent,
-} from './main_utils';
-import CSS from 'csstype';
-import {
- permissionsMissingToast,
- permissionsMissingActions,
-} from '../utils/utils';
-
-const reportCountStyles: CSS.Properties = {
- color: 'gray',
- display: 'inline',
-};
-
-export function Main(props) {
- const [reportsTableContent, setReportsTableContent] = useState([]);
- const [
- reportDefinitionsTableContent,
- setReportDefinitionsTableContent,
- ] = useState([]);
- const [toasts, setToasts] = useState([]);
-
- const addPermissionsMissingDownloadToastHandler = () => {
- const toast = permissionsMissingToast(
- permissionsMissingActions.GENERATING_REPORT
- );
- setToasts(toasts.concat(toast));
- };
-
- const handlePermissionsMissingDownloadToast = () => {
- addPermissionsMissingDownloadToastHandler();
- };
-
- const addReportsTableContentErrorToastHandler = (errorType: string) => {
- let toast = {};
- if (errorType === 'permissions') {
- toast = permissionsMissingToast(
- permissionsMissingActions.LOADING_REPORTS_TABLE
- );
- } else if (errorType === 'API') {
- toast = {
- title: i18n.translate(
- 'opensearch.reports.main.errorGeneratingReportsTable.',
- { defaultMessage: 'Error generating reports table.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'reportsTableErrorToast',
- };
- }
- setToasts(toasts.concat(toast));
- };
-
- const handleReportsTableErrorToast = (errorType: string) => {
- addReportsTableContentErrorToastHandler(errorType);
- };
-
- const addReportDefinitionsTableErrorToastHandler = (errorType: string) => {
- let toast = {};
- if (errorType === 'permissions') {
- toast = permissionsMissingToast(
- permissionsMissingActions.LOADING_DEFINITIONS_TABLE
- );
- } else if (errorType === 'API') {
- toast = {
- title: i18n.translate(
- 'opensearch.reports.main.errorGeneratingReportDefinitionsTable.',
- { defaultMessage: 'Error generating report definitions table.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'reportDefinitionsTableErrorToast',
- };
- }
- setToasts(toasts.concat(toast));
- };
-
- const handleReportDefinitionsTableErrorToast = (errorType: string) => {
- addReportDefinitionsTableErrorToastHandler(errorType);
- };
-
- const addErrorOnDemandDownloadToastHandler = (
- title = i18n.translate('opensearch.reports.main.errorDownloadingReport', {
- defaultMessage: 'Error downloading report.',
- }),
- text = ''
- ) => {
- const errorToast = {
- title,
- text,
- color: 'danger',
- iconType: 'alert',
- id: 'onDemandDownloadErrorToast',
- };
- setToasts(toasts.concat(errorToast));
- };
-
- const handleOnDemandDownloadErrorToast = (title?: string, text?: string) => {
- addErrorOnDemandDownloadToastHandler(title, text);
- };
-
- const addSuccessOnDemandDownloadToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.main.successfullyDownloadedReport',
- { defaultMessage: 'Successfully downloaded report.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'onDemandDownloadSuccessToast',
- };
- setToasts(toasts.concat(successToast));
- };
-
- const handleOnDemandDownloadSuccessToast = () => {
- addSuccessOnDemandDownloadToastHandler();
- };
-
- const addCreateReportDefinitionSuccessToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.main.successfullyCreatedReportDefinition',
- { defaultMessage: 'Successfully created report definition.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'createReportDefinitionSuccessToast',
- };
- setToasts(toasts.concat(successToast));
- };
-
- const handleCreateReportDefinitionSuccessToast = () => {
- addCreateReportDefinitionSuccessToastHandler();
- };
-
- const addEditReportDefinitionSuccessToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.main.successfullyUpdatedReportDefinition',
- { defaultMessage: 'Successfully updated report definition.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'editReportDefinitionSuccessToast',
- };
- setToasts(toasts.concat(successToast));
- };
-
- const handleEditReportDefinitionSuccessToast = () => {
- addEditReportDefinitionSuccessToastHandler();
- };
-
- const addDeleteReportDefinitionSuccessToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.main.successfullyDeletedReportDefinition',
- { defaultMessage: 'Successfully deleted report definition.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'deleteReportDefinitionSuccessToast',
- };
- setToasts(toasts.concat(successToast));
- };
-
- const handleDeleteReportDefinitionSuccessToast = () => {
- addDeleteReportDefinitionSuccessToastHandler();
- };
-
- const removeToast = (removedToast) => {
- setToasts(toasts.filter((toast) => toast.id !== removedToast.id));
- };
-
- const pagination = {
- initialPageSize: 10,
- pageSizeOptions: [5, 10, 20],
- };
-
- useEffect(() => {
- props.setBreadcrumbs([
- {
- text: i18n.translate('opensearch.reports.main.title.reporting', {
- defaultMessage: 'Reporting',
- }),
- href: '#',
- },
- ]);
- refreshReportsTable();
- refreshReportsDefinitionsTable();
-
- if (window.location.href.includes('create=success')) {
- handleCreateReportDefinitionSuccessToast();
- // refresh might not fetch the latest changes when coming from create or edit page
- // workaround to wait 1 second and refresh again
- setTimeout(() => {
- refreshReportsTable();
- refreshReportsDefinitionsTable();
- }, 1000);
- } else if (window.location.href.includes('edit=success')) {
- handleEditReportDefinitionSuccessToast();
- setTimeout(() => {
- refreshReportsTable();
- refreshReportsDefinitionsTable();
- }, 1000);
- } else if (window.location.href.includes('delete=success')) {
- handleDeleteReportDefinitionSuccessToast();
- setTimeout(() => {
- refreshReportsTable();
- refreshReportsDefinitionsTable();
- }, 1000);
- }
- window.location.href = 'reports-dashboards#/';
- }, []);
-
- const refreshReportsTable = async () => {
- const { httpClient } = props;
- await httpClient
- .get('../api/reporting/reports')
- .then((response) => {
- setReportsTableContent(addReportsTableContent(response.data));
- })
- .catch((error) => {
- console.log('error when fetching all reports: ', error);
- // permission denied error
- if (error.body.statusCode === 403) {
- handleReportsTableErrorToast('permissions');
- } else {
- handleReportsTableErrorToast('API');
- }
- });
- };
-
- const refreshReportsDefinitionsTable = async () => {
- const { httpClient } = props;
- await httpClient
- .get('../api/reporting/reportDefinitions')
- .then((response) => {
- setReportDefinitionsTableContent(
- addReportDefinitionsTableContent(response.data)
- );
- })
- .catch((error) => {
- console.log('error when fetching all report definitions: ', error);
- if (error.body.statusCode === 403) {
- handleReportDefinitionsTableErrorToast('permissions');
- } else {
- handleReportDefinitionsTableErrorToast('API');
- }
- });
- };
-
- return (
-
-
-
-
-
-
- {i18n.translate('opensearch.reports.main.title.reports', {
- defaultMessage: 'Reports',
- })}{' '}
- ({reportsTableContent.length})
-
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.main.reports.button.refresh',
- { defaultMessage: 'Refresh' }
- )}
-
-
-
-
-
-
-
-
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.main.title.reportDefinitions',
- { defaultMessage: 'Report definitions' }
- )}
-
- {' '}
- ({reportDefinitionsTableContent.length})
-
-
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.main.reportDefinitions.button.refresh',
- { defaultMessage: 'Refresh' }
- )}
-
-
-
- {
- window.location.assign('reports-dashboards#/create');
- }}
- id={'createReportHomepageButton'}
- >
- {i18n.translate(
- 'opensearch.reports.main.reportDefinitions.button.create',
- { defaultMessage: 'Create' }
- )}
-
-
-
-
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/main/main_utils.tsx b/dashboards-reports/public/components/main/main_utils.tsx
deleted file mode 100644
index f4b32bbf..00000000
--- a/dashboards-reports/public/components/main/main_utils.tsx
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { i18n } from '@osd/i18n';
-import 'babel-polyfill';
-import { HttpSetup } from '../../../../../src/core/public';
-import { uiSettingsService } from '../utils/settings_service';
-import { GENERATE_REPORT_PARAM } from '../visual_report/constants';
-
-export const getAvailableNotificationsChannels = (configList: any) => {
- let availableChannels = [];
- for (let i = 0; i < configList.length; ++i) {
- let channelEntry = {};
- channelEntry = {
- label: configList[i].config.name,
- id: configList[i].config_id,
- };
- availableChannels.push(channelEntry);
- }
- return availableChannels;
-};
-
-type fileFormatsOptions = {
- [key: string]: string;
-};
-
-export const fileFormatsUpper: fileFormatsOptions = {
- csv: 'CSV',
- pdf: 'PDF',
- png: 'PNG',
-};
-
-export const humanReadableDate = (date: string | number | Date) => {
- let readableDate = new Date(date);
- return (
- readableDate.toDateString() + ' @ ' + readableDate.toLocaleTimeString()
- );
-};
-
-export const extractFilename = (filename: string) => {
- return filename.substring(0, filename.length - 4);
-};
-
-export const extractFileFormat = (filename: string) => {
- const fileFormat = filename;
- return fileFormat.substring(filename.length - 3, filename.length);
-};
-
-export const getFileFormatPrefix = (fileFormat: string) => {
- var fileFormatPrefix = 'data:' + fileFormat + ';base64,';
- return fileFormatPrefix;
-};
-
-export const addReportsTableContent = (data: string | any[]) => {
- let reportsTableItems = [];
- for (let index = 0; index < data.length; ++index) {
- let item = data[index];
- let report = item._source;
- let reportDefinition = report.report_definition;
- let reportParams = reportDefinition.report_params;
- let trigger = reportDefinition.trigger;
-
- let reportsTableEntry = {
- id: item._id,
- reportName: reportParams.report_name,
- type: trigger.trigger_type,
- sender: `\u2014`,
- opensearchDashboardsRecipients: `\u2014`,
- emailRecipients: `\u2014`,
- reportSource: reportParams.report_source,
- //TODO: wrong name
- timeCreated: report.time_created,
- state: report.state,
- url: report.query_url,
- format: reportParams.core_params.report_format,
- };
- reportsTableItems.push(reportsTableEntry);
- }
- return reportsTableItems;
-};
-
-export const addReportDefinitionsTableContent = (data: any) => {
- let reportDefinitionsTableItems = [];
- for (let index = 0; index < data.length; ++index) {
- let item = data[index];
- let reportDefinition = item._source.report_definition;
- let reportParams = reportDefinition.report_params;
- let trigger = reportDefinition.trigger;
- let triggerParams = trigger.trigger_params;
- let reportDefinitionsTableEntry = {
- id: item._id,
- reportName: reportParams.report_name,
- type: trigger.trigger_type,
- owner: `\u2014`, // Todo: replace
- source: reportParams.report_source,
- baseUrl: reportParams.core_params.base_url,
- lastUpdated: reportDefinition.last_updated,
- details:
- trigger.trigger_type === 'On demand'
- ? `\u2014`
- : triggerParams.schedule_type, // e.g. recurring, cron based
- status: reportDefinition.status,
- };
- reportDefinitionsTableItems.push(reportDefinitionsTableEntry);
- }
- return reportDefinitionsTableItems;
-};
-
-export const removeDuplicatePdfFileFormat = (filename: string) => {
- return filename.substring(0, filename.length - 4);
-};
-
-export const readDataReportToFile = async (
- stream: string,
- fileFormat: string,
- fileName: string
-) => {
- const blob = new Blob([stream]);
- const url = URL.createObjectURL(blob);
- let link = document.createElement('a');
- link.setAttribute('href', url);
- link.setAttribute('download', fileName);
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
-};
-
-export const readStreamToFile = async (
- stream: string,
- fileFormat: string,
- fileName: string
-) => {
- let link = document.createElement('a');
- if (fileName.includes('csv')) {
- readDataReportToFile(stream, fileFormat, fileName);
- return;
- }
- let fileFormatPrefix = getFileFormatPrefix(fileFormat);
- let url = fileFormatPrefix + stream;
- if (typeof link.download !== 'string') {
- window.open(url, '_blank');
- return;
- }
- link.download = fileName;
- link.href = url;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
-};
-
-export const generateReportFromDefinitionId = async (
- reportDefinitionId: string,
- httpClient: HttpSetup
-) => {
- let status = false;
- let permissionsError = false;
- await httpClient
- .post(`../api/reporting/generateReport/${reportDefinitionId}`, {
- headers: {
- 'Content-Type': 'application/json',
- },
- query: uiSettingsService.getSearchParams(),
- })
- .then(async (response: any) => {
- // for emailing a report, this API response doesn't have response body
- if (!response) return;
- const fileFormat = extractFileFormat(response['filename']);
- const fileName = response['filename'];
- if (fileFormat === 'csv') {
- await readStreamToFile(await response['data'], fileFormat, fileName);
- status = true;
- return;
- }
-
- // generate reports in browser is memory intensive, do it in a new process by removing referrer
- const a = document.createElement('a');
- a.href =
- window.location.origin +
- `${response.queryUrl}&${GENERATE_REPORT_PARAM}=${response.reportId}`;
- a.target = '_blank';
- a.rel = 'noreferrer';
- a.click();
- status = true;
- })
- .catch((error) => {
- console.log('error on generating report:', error);
- if (error.body.statusCode === 403) {
- permissionsError = true;
- }
- status = false;
- });
- return {
- status: status,
- permissionsError: permissionsError,
- };
-};
-
-export const generateReportById = async (
- reportId: string,
- httpClient: HttpSetup,
- handleSuccessToast,
- handleErrorToast,
- handlePermissionsMissingToast
-) => {
- await httpClient
- .get(`../api/reporting/generateReport/${reportId}`, {
- query: uiSettingsService.getSearchParams(),
- })
- .then(async (response) => {
- //TODO: duplicate code, extract to be a function that can reuse. e.g. handleResponse(response)
- const fileFormat = extractFileFormat(response['filename']);
- const fileName = response['filename'];
- if (fileFormat === 'csv') {
- await readStreamToFile(await response['data'], fileFormat, fileName);
- handleSuccessToast();
- return response;
- }
-
- // generate reports in browser is memory intensive, do it in a new process by removing referrer
- const a = document.createElement('a');
- a.href =
- window.location.origin +
- `${response.queryUrl}&${GENERATE_REPORT_PARAM}=${reportId}`;
- a.target = '_blank';
- a.rel = 'noreferrer';
- a.click();
- })
- .catch((error) => {
- console.log('error on generating report by id:', error);
- if (error.body.statusCode === 403) {
- handlePermissionsMissingToast();
- } else if (error.body.statusCode === 503) {
- handleErrorToast(
- i18n.translate('opensearch.reports.utils.errorTitle', {
- defaultMessage: 'Error generating report.',
- }),
- i18n.translate('opensearch.reports.utils.errorText', {
- defaultMessage:
- 'Timed out generating report ID {reportId}. Try again later.',
- values: { reportId: reportId },
- description: 'Error number toast',
- })
- );
- } else {
- handleErrorToast();
- }
- });
-};
diff --git a/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap b/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap
deleted file mode 100644
index e1b1f857..00000000
--- a/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap
+++ /dev/null
@@ -1,1233 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`
panel render 5 hours recurring definition details 1`] = `
-
-
-
- Report definition details
-
-
-
-
-
-
- Report settings
-
-
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- Last updated
-
-
-
-
-
-
-
-
-
-
-
- Time period
-
-
- Last
-
-
-
-
-
-
- File format
-
-
-
- undefined
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header
-
-
-
-
-
-
-
- Report footer
-
-
-
-
-
-
-
-
-
-
-
-
- Report trigger
-
-
-
-
-
-
-
- Schedule details
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render disabled daily definition, click 1`] = `
-
-
-
- Report definition details
-
-
-
-
-
-
- Report settings
-
-
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- Last updated
-
-
-
-
-
-
-
-
-
-
-
- Time period
-
-
- Last
-
-
-
-
-
-
- File format
-
-
-
- undefined
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header
-
-
-
-
-
-
-
- Report footer
-
-
-
-
-
-
-
-
-
-
-
-
- Report trigger
-
-
-
-
-
-
-
- Schedule details
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`
panel render on demand definition details 1`] = `
-
-
-
- Report definition details
-
-
-
-
-
-
- Report settings
-
-
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
- Last updated
-
-
-
-
-
-
-
-
-
-
-
- Time period
-
-
- Last
-
-
-
-
-
-
- File format
-
-
-
- undefined
-
-
-
-
-
-
-
-
-
-
-
-
- Report header
-
-
-
-
-
-
-
- Report footer
-
-
-
-
-
-
-
-
-
-
-
-
- Report trigger
-
-
-
-
-
-
-
- Schedule details
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/main/report_definition_details/__tests__/report_definition_details.test.tsx b/dashboards-reports/public/components/main/report_definition_details/__tests__/report_definition_details.test.tsx
deleted file mode 100644
index 7e26cd63..00000000
--- a/dashboards-reports/public/components/main/report_definition_details/__tests__/report_definition_details.test.tsx
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { act, render } from '@testing-library/react';
-import { ReportDefinitionDetails } from '../report_definition_details';
-import httpClientMock from '../../../../../test/httpMockClient';
-import 'babel-polyfill';
-import { configure, mount } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
-
-function setBreadcrumbs(array: []) {
- jest.fn();
-}
-
-describe('
panel', () => {
- let propsMock = {
- match: {
- params: {
- reportDefinitionId: jest.fn(),
- },
- },
- };
-
- const match = {
- params: {
- reportDefinitionId: '1',
- },
- };
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- configure({ adapter: new Adapter() });
- test('render on demand definition details', async () => {
- const promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'On demand',
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render 5 hours recurring definition details', async () => {
- const promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 5,
- unit: 'HOURS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- const { container } = render(
-
- );
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render disabled daily definition, click', async () => {
- let promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 1,
- unit: 'DAYS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: false,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('simulate click on generateReport', async () => {
- let promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: null,
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'On demand',
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- const component = mount(
-
- );
- await act(() => promise);
- component.update();
- const statusButton = component.find('button').at(1);
-
- statusButton.simulate('click');
- await act(() => promise);
- });
-
- test('simulate click on delete', async () => {
- let promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: null,
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 1,
- unit: 'DAYS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: false,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- const component = mount(
-
- );
-
- const statusButton = component.find('button').at(0);
- statusButton.update();
- statusButton.simulate('click');
-
- await act(() => promise);
- });
-
- test('simulate click to enable', async () => {
- let promise = Promise.resolve();
- const report_definition = {
- status: 'Disabled',
- report_params: {
- report_name: 'test click on enable disable',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 1,
- unit: 'DAYS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: false,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- httpClientMock.put = jest.fn().mockResolvedValue({});
-
- const component = mount(
-
- );
- await act(() => promise);
- component.update();
- const statusButton = component.find('button').at(1);
-
- statusButton.simulate('click');
- await act(() => promise);
- });
-
- test('simulate click to disable', async () => {
- let promise = Promise.resolve();
- const report_definition = {
- status: 'Active',
- report_params: {
- report_name: 'test click on enable disable',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 1,
- unit: 'DAYS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- config_list: []
- });
-
- httpClientMock.put = jest.fn().mockResolvedValue({});
-
- const component = mount(
-
- );
- await act(() => promise);
- component.update();
- const statusButton = component.find('button').at(1);
-
- statusButton.simulate('click');
- await act(() => promise);
- });
-});
diff --git a/dashboards-reports/public/components/main/report_definition_details/report_definition_details.tsx b/dashboards-reports/public/components/main/report_definition_details/report_definition_details.tsx
deleted file mode 100644
index 2d44dfd2..00000000
--- a/dashboards-reports/public/components/main/report_definition_details/report_definition_details.tsx
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiFlexGroup,
- EuiFlexItem,
- EuiPage,
- EuiPageHeader,
- EuiTitle,
- EuiPageBody,
- EuiPageContent,
- EuiHorizontalRule,
- EuiSpacer,
- EuiPageHeaderSection,
- EuiButton,
- EuiIcon,
- EuiLink,
- EuiGlobalToastList,
- EuiOverlayMask,
- EuiConfirmModal,
-} from '@elastic/eui';
-import {
- ReportDetailsComponent,
- formatEmails,
- trimAndRenderAsText,
-} from '../report_details/report_details';
-import {
- fileFormatsUpper,
- generateReportFromDefinitionId,
-} from '../main_utils';
-import { ReportDefinitionSchemaType } from '../../../../server/model';
-import moment from 'moment';
-import {
- permissionsMissingToast,
- permissionsMissingActions,
-} from '../../utils/utils';
-import { GenerateReportLoadingModal } from '../loading_modal';
-
-const ON_DEMAND = 'On demand';
-
-interface ReportDefinitionDetails {
- name: string;
- description: string;
- created: string;
- lastUpdated: string;
- source: string;
- timePeriod: string;
- fileFormat: string;
- status: string | undefined;
- reportHeader: string;
- reportFooter: string;
- triggerType: string;
- scheduleDetails: string;
- baseUrl: string;
-}
-
-export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: any; httpClient?: any; }) {
- const [reportDefinitionDetails, setReportDefinitionDetails] = useState
({
- name: '',
- description: '',
- created: '',
- lastUpdated: '',
- source: '',
- timePeriod: '',
- fileFormat: '',
- status: '',
- reportHeader: '',
- reportFooter: '',
- triggerType: '',
- scheduleDetails: '',
- baseUrl: ''
- });
- const [
- reportDefinitionRawResponse,
- setReportDefinitionRawResponse,
- ] = useState({});
- const [toasts, setToasts] = useState([]);
- const [showDeleteModal, setShowDeleteModal] = useState(false);
- const [showLoading, setShowLoading] = useState(false);
- const reportDefinitionId = props.match['params']['reportDefinitionId'];
-
- const handleLoading = (e: boolean | ((prevState: boolean) => boolean)) => {
- setShowLoading(e);
- };
-
- const handleShowDeleteModal = (e: boolean | ((prevState: boolean) => boolean)) => {
- setShowDeleteModal(e);
- };
-
- const addPermissionsMissingStatusChangeToastHandler = () => {
- const toast = permissionsMissingToast(
- permissionsMissingActions.CHANGE_SCHEDULE_STATUS
- );
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const addPermissionsMissingDeleteToastHandler = () => {
- const toast = permissionsMissingToast(
- permissionsMissingActions.DELETE_REPORT_DEFINITION
- );
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const handlePermissionsMissingDeleteToast = () => {
- addPermissionsMissingDeleteToastHandler();
- };
-
- const addPermissionsMissingGenerateReportToastHandler = () => {
- const toast = permissionsMissingToast(
- permissionsMissingActions.GENERATING_REPORT
- );
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const addErrorLoadingDetailsToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.errorLoadingReportDefinitionDetails. ',
- { defaultMessage: 'Error loading report definition details.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'reportDefinitionDetailsErrorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleDetailsErrorToast = () => {
- addErrorLoadingDetailsToastHandler();
- };
-
- const addSuccessGeneratingReportToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.successfullyGeneratedReport. ',
- { defaultMessage: 'Successfully generated report.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'generateReportSuccessToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(successToast));
- };
-
- const handleSuccessGeneratingReportToast = () => {
- addSuccessGeneratingReportToastHandler();
- };
-
- const addErrorGeneratingReportToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.errorGeneratingReport. ',
- { defaultMessage: 'Error generating report.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'generateReportErrorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleErrorGeneratingReportToast = (errorType: string) => {
- if (errorType === 'permissions') {
- addPermissionsMissingGenerateReportToastHandler();
- } else if (errorType === 'API') {
- addErrorGeneratingReportToastHandler();
- }
- };
-
- const addSuccessEnablingScheduleToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.successfullyEnabledSchedule. ',
- { defaultMessage: 'Successfully enabled schedule.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'successEnableToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(successToast));
- };
-
- const addErrorEnablingScheduleToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.errorEnablingSchedule. ',
- { defaultMessage: 'Error enabling schedule.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const addSuccessDisablingScheduleToastHandler = () => {
- const successToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.successfullyDisabledSchedule. ',
- { defaultMessage: 'Successfully disabled schedule.' }
- ),
- color: 'success',
- iconType: 'check',
- id: 'successDisableToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(successToast));
- };
-
- const handleSuccessChangingScheduleStatusToast = (statusChange: string) => {
- if (statusChange === 'enable') {
- addSuccessEnablingScheduleToastHandler();
- } else if (statusChange === 'disable') {
- addSuccessDisablingScheduleToastHandler();
- }
- };
-
- const addErrorDisablingScheduleToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.errorDisablingSchedule. ',
- { defaultMessage: 'Error disabling schedule.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorDisableToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleErrorChangingScheduleStatusToast = (statusChange: string) => {
- if (statusChange === 'enable') {
- addErrorEnablingScheduleToastHandler();
- } else if (statusChange === 'disable') {
- addErrorDisablingScheduleToastHandler();
- } else if (statusChange === 'permissions') {
- addPermissionsMissingStatusChangeToastHandler();
- }
- };
-
- const addErrorDeletingReportDefinitionToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.toast.errorDeletingReport definition. ',
- { defaultMessage: 'Error deleting report definition.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorDeleteToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleErrorDeletingReportDefinitionToast = () => {
- addErrorDeletingReportDefinitionToastHandler();
- };
-
- const removeToast = (removedToast: { id: string; }) => {
- setToasts(toasts.filter((toast: any) => toast.id !== removedToast.id));
- };
-
- const handleReportDefinitionDetails = (e: ReportDefinitionDetails) => {
- setReportDefinitionDetails(e);
- };
-
- const handleReportDefinitionRawResponse = (e: {} ) => {
- setReportDefinitionRawResponse(e);
- };
-
- const DeleteConfirmationModal = () => {
- const closeModal = () => {
- setShowDeleteModal(false);
- };
-
- return (
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.button.delete.query',
- {
- defaultMessage: 'Are you sure you want to delete "{name}"?',
- values: { name: reportDefinitionDetails.name },
- }
- )}
-
-
-
-
- );
- };
-
- const humanReadableScheduleDetails = (trigger) => {
- let scheduleDetails = '';
- if (trigger.trigger_type === 'Schedule') {
- if (trigger.trigger_params.schedule_type === 'Recurring') {
- // Daily
- if (
- trigger.trigger_params.schedule.interval.unit === 'DAYS' &&
- trigger.trigger_params.schedule.interval.period === 1
- ) {
- const date = new Date(
- trigger.trigger_params.schedule.interval.start_time
- );
- scheduleDetails = i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.dailyAt',
- {
- defaultMessage: 'Daily @ {time}',
- values: { time: date.toTimeString() },
- }
- );
- }
- // By interval
- else {
- const date = new Date(
- trigger.trigger_params.schedule.interval.start_time
- );
- scheduleDetails = i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.byInterval',
- {
- defaultMessage:
- 'By interval, every {period} {unit}, starting @ {time}',
- values: {
- period: trigger.trigger_params.schedule.interval.period,
- unit: trigger.trigger_params.schedule.interval.unit.toLowerCase(),
- time: date.toTimeString(),
- },
- }
- );
- }
- }
- // Cron
- else if (trigger.trigger_params.schedule_type === 'Cron based') {
- scheduleDetails = i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.cronBased',
- {
- defaultMessage: 'Cron based: {expression} ({timezone})',
- values: {
- expression: trigger.trigger_params.schedule.cron.expression,
- timezone: trigger.trigger_params.schedule.cron.timezone,
- },
- }
- );
- }
- }
- return scheduleDetails;
- };
-
- const getReportDefinitionDetailsMetadata = (
- data: ReportDefinitionSchemaType
- ) : ReportDefinitionDetails => {
- const reportDefinition: ReportDefinitionSchemaType = data;
- const {
- report_params: reportParams,
- trigger,
- delivery,
- time_created: timeCreated,
- last_updated: lastUpdated,
- } = reportDefinition;
- const {
- trigger_type: triggerType,
- trigger_params: triggerParams,
- } = trigger;
- const {
- core_params: {
- base_url: baseUrl,
- report_format: reportFormat,
- time_duration: timeDuration,
- },
- } = reportParams;
-
- let readableDate = new Date(timeCreated);
- let displayCreatedDate =
- readableDate.toDateString() + ' ' + readableDate.toLocaleTimeString();
-
- let readableUpdatedDate = new Date(lastUpdated);
- let displayUpdatedDate =
- readableUpdatedDate.toDateString() +
- ' ' +
- readableUpdatedDate.toLocaleTimeString();
-
- let reportDefinitionDetails = {
- name: reportParams.report_name,
- description:
- reportParams.description === '' ? `\u2014` : reportParams.description,
- created: displayCreatedDate,
- lastUpdated: displayUpdatedDate,
- source: reportParams.report_source,
- baseUrl: baseUrl,
- // TODO: need better display
- timePeriod: moment.duration(timeDuration).humanize(),
- fileFormat: reportFormat,
- reportHeader:
- reportParams.core_params.hasOwnProperty('header') &&
- reportParams.core_params.header != ''
- ? reportParams.core_params.header
- : `\u2014`,
- reportFooter:
- reportParams.core_params.hasOwnProperty('footer') &&
- reportParams.core_params.footer != ''
- ? reportParams.core_params.footer
- : `\u2014`,
- triggerType: triggerType,
- scheduleDetails: triggerParams
- ? humanReadableScheduleDetails(data.trigger)
- : `\u2014`,
- status: reportDefinition.status,
- };
- return reportDefinitionDetails;
- };
-
- useEffect(() => {
- const { httpClient } = props;
- httpClient
- .get(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
- .then((response: {report_definition: ReportDefinitionSchemaType}) => {
- handleReportDefinitionRawResponse(response);
- handleReportDefinitionDetails(getReportDefinitionDetailsMetadata(response.report_definition));
- props.setBreadcrumbs([
- {
- text: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.breadcrumb.reporting',
- { defaultMessage: 'Reporting' }
- ),
- href: '#',
- },
- {
- text: i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.breadcrumb.reportDefinitionDetails',
- {
- defaultMessage: 'Report definition details: {name}',
- values: {
- name: response.report_definition.report_params.report_name,
- },
- }
- ),
- },
- ]);
- })
- .catch((error: any) => {
- console.error(
- i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.schedule.breadcrumb.error',
- {
- defaultMessage:
- 'error when getting report definition details: {error}',
- values: { error: error },
- }
- )
- );
- handleDetailsErrorToast();
- });
- }, []);
-
- const downloadIconDownload = async () => {
- handleLoading(true);
- await generateReportFromDetails();
- handleLoading(false);
- };
-
- const fileFormatDownload = (data: { [x: string]: any; }) => {
- let formatUpper = data['fileFormat'];
- formatUpper = fileFormatsUpper[formatUpper];
- return (
-
- {formatUpper + ' '}
-
-
- );
- };
-
- const sourceURL = (data: ReportDefinitionDetails) => {
- return (
-
- {data['source']}
-
- );
- };
-
- const changeScheduledReportDefinitionStatus = (statusChange: string) => {
- let updatedReportDefinition = reportDefinitionRawResponse.report_definition;
- if (statusChange === 'Disable') {
- updatedReportDefinition.trigger.trigger_params.enabled = false;
- updatedReportDefinition.status = 'Disabled';
- } else if (statusChange === 'Enable') {
- updatedReportDefinition.trigger.trigger_params.enabled = true;
- updatedReportDefinition.status = 'Active';
- }
- const { httpClient } = props;
- httpClient
- .put(`../api/reporting/reportDefinitions/${reportDefinitionId}`, {
- body: JSON.stringify(updatedReportDefinition),
- params: reportDefinitionId.toString(),
- })
- .then(() => {
- const updatedRawResponse = { report_definition: {} };
- updatedRawResponse.report_definition = updatedReportDefinition;
- handleReportDefinitionRawResponse(updatedRawResponse);
- setReportDefinitionDetails(
- getReportDefinitionDetailsMetadata(updatedReportDefinition)
- );
- if (statusChange === 'Enable') {
- handleSuccessChangingScheduleStatusToast('enable');
- } else if (statusChange === 'Disable') {
- handleSuccessChangingScheduleStatusToast('disable');
- }
- })
- .catch((error: { body: { statusCode: number; }; }) => {
- console.error('error in updating report definition status:', error);
- if (error.body.statusCode === 403) {
- handleErrorChangingScheduleStatusToast('permissions');
- } else {
- if (statusChange === 'Enable') {
- handleErrorChangingScheduleStatusToast('enable');
- } else if (statusChange === 'Disable') {
- handleErrorChangingScheduleStatusToast('disable');
- }
- }
- });
- };
-
- const ScheduledDefinitionStatus = () => {
- const status =
- reportDefinitionDetails.status === 'Active' ? 'Disable' : 'Enable';
-
- return (
- changeScheduledReportDefinitionStatus(status)}
- id={'changeStatusFromDetailsButton'}
- >
- {status}
-
- );
- };
-
- const generateReportFromDetails = async () => {
- const { httpClient } = props;
- handleLoading(true);
- let generateReportSuccess = await generateReportFromDefinitionId(
- reportDefinitionId,
- httpClient
- );
- handleLoading(false);
- if (generateReportSuccess.status) {
- handleSuccessGeneratingReportToast();
- } else {
- if (generateReportSuccess.permissionsError) {
- handleErrorGeneratingReportToast('permissions');
- } else {
- handleErrorGeneratingReportToast('API');
- }
- }
- };
-
- const deleteReportDefinition = () => {
- const { httpClient } = props;
- httpClient
- .delete(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
- .then(() => {
- window.location.assign(`reports-dashboards#/delete=success`);
- })
- .catch((error: { body: { statusCode: number; }; }) => {
- console.log('error when deleting report definition:', error);
- if (error.body.statusCode === 403) {
- handlePermissionsMissingDeleteToast();
- } else {
- handleErrorDeletingReportDefinitionToast();
- }
- });
- };
-
- const showActionButton =
- reportDefinitionDetails.triggerType === ON_DEMAND ? (
- generateReportFromDetails()}
- id={'generateReportFromDetailsButton'}
- >
- Generate report
-
- ) : (
-
- );
-
- const triggerSection =
- reportDefinitionDetails.triggerType === ON_DEMAND ? (
-
- ) : (
-
-
-
-
-
-
- );
-
- const showDeleteConfirmationModal = showDeleteModal ? (
-
- ) : null;
-
- const showLoadingModal = showLoading ? (
-
- ) : null;
-
- return (
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.title',
- { defaultMessage: 'Report definition details' }
- )}
-
-
-
-
-
-
-
-
-
- {reportDefinitionDetails.name}
-
-
-
-
-
-
- handleShowDeleteModal(show)}
- id={'deleteReportDefinitionButton'}
- >
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.deleteReportDefinitionButton',
- { defaultMessage: 'Delete' }
- )}
-
-
- {showActionButton}
-
- {
- window.location.assign(
- `reports-dashboards#/edit/${reportDefinitionId}`
- );
- }}
- id={'editReportDefinitionButton'}
- >
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.editReportDefinitionButton',
- { defaultMessage: 'Edit' }
- )}
-
-
-
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsDetails.reportSettings',
- { defaultMessage: 'Report settings' }
- )}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {triggerSection}
-
-
- {showDeleteConfirmationModal}
- {showLoadingModal}
-
-
- );
-}
diff --git a/dashboards-reports/public/components/main/report_definitions_table.tsx b/dashboards-reports/public/components/main/report_definitions_table.tsx
deleted file mode 100644
index b0d255b3..00000000
--- a/dashboards-reports/public/components/main/report_definitions_table.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useState } from 'react';
-import {
- EuiLink,
- EuiInMemoryTable,
- EuiButton,
- EuiEmptyPrompt,
- EuiText,
- EuiIcon,
-} from '@elastic/eui';
-import { i18n } from '@osd/i18n';
-import { humanReadableDate } from './main_utils';
-
-const emptyMessageReportDefinitions = (
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.noReportDefinitions',
- { defaultMessage: 'No report definitions to display' }
- )}
-
- }
- titleSize="xs"
- body={
-
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.createANewDefinition',
- { defaultMessage: 'Create a new report definition to get started' }
- )}
-
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.toLearnMore',
- { defaultMessage: 'To learn more, see' }
- )}{' '}
-
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.getStarted',
- {
- defaultMessage:
- 'Get started with OpenSearch Dashboards reporting',
- }
- )}
-
-
-
-
- }
- actions={
-
- {
- window.location.assign('reports-dashboards#/create');
- }}
- >
- {i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.createReportDefinition',
- { defaultMessage: 'Create report definition' }
- )}
-
-
- }
- />
-);
-
-const reportDefinitionsSearch = {
- box: {
- incremental: true,
- },
- filters: [],
-};
-
-export function ReportDefinitions(props) {
- const { pagination, reportDefinitionsTableContent } = props;
-
- const [sortField, setSortField] = useState('lastUpdated');
- const [sortDirection, setSortDirection] = useState('des');
-
- const sorting = {
- sort: {
- field: sortField,
- direction: sortDirection,
- },
- };
-
- const getDefinitionTableItemId = (name) => {
- let index;
- for (
- index = 0;
- index < props.reportDefinitionsTableContent.length;
- ++index
- ) {
- if (name === reportDefinitionsTableContent[index].reportName) {
- return reportDefinitionsTableContent[index].id;
- }
- }
- };
-
- const navigateToDefinitionDetails = (name: any) => {
- let id = getDefinitionTableItemId(name);
- window.location.assign(
- `reports-dashboards#/report_definition_details/${id}`
- );
- };
-
- const reportDefinitionsColumns = [
- {
- field: 'reportName',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.name',
- {
- defaultMessage: 'Name',
- }
- ),
- render: (name) => (
- navigateToDefinitionDetails(name)}
- id={'reportDefinitionDetailsLink'}
- >
- {name}
-
- ),
- },
- {
- field: 'source',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.source',
- { defaultMessage: 'Source' }
- ),
- render: (value, item) => (
-
- {value}
-
- ),
- },
- {
- field: 'type',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.type',
- {
- defaultMessage: 'Type',
- }
- ),
- sortable: true,
- truncateText: false,
- },
- {
- field: 'details',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.scheduleDetails',
- { defaultMessage: 'Schedule details' }
- ),
- sortable: false,
- truncateText: true,
- },
- {
- field: 'lastUpdated',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.lastUpdated',
- { defaultMessage: 'Last Updated' }
- ),
- render: (date) => {
- let readable = humanReadableDate(date);
- return {readable} ;
- },
- },
- {
- field: 'status',
- name: i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.columns.status',
- { defaultMessage: 'Status' }
- ),
- sortable: true,
- truncateText: false,
- },
- ];
-
- const displayMessage =
- reportDefinitionsTableContent.length === 0
- ? emptyMessageReportDefinitions
- : i18n.translate(
- 'opensearch.reports.reportDefinitionsTable.emptyMessageReports.noDefinitionsFound',
- {
- defaultMessage:
- '0 report definitions match the search criteria. Search again.',
- }
- );
-
- return (
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/main/report_details/__tests__/__snapshots__/report_details.test.tsx.snap b/dashboards-reports/public/components/main/report_details/__tests__/__snapshots__/report_details.test.tsx.snap
deleted file mode 100644
index 7d0b79f6..00000000
--- a/dashboards-reports/public/components/main/report_details/__tests__/__snapshots__/report_details.test.tsx.snap
+++ /dev/null
@@ -1,760 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[` panel render 5 hours recurring component 1`] = `
-
-
-
- Report details
-
-
-
-
-
-
- Report Settings
-
-
-
-
-
-
- Name
-
-
- test create report definition trigger
-
-
-
-
-
-
- Description
-
-
- —
-
-
-
-
-
-
- Created
-
-
- —
-
-
-
-
-
-
- Last updated
-
-
- —
-
-
-
-
-
-
-
-
-
-
- Time period
-
-
- Invalid Date -> 10/23/2020, 8:53:35 PM
-
-
-
-
-
-
- File format
-
-
-
- undefined
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header
-
-
-
- —
-
-
-
-
-
-
-
- Report footer
-
-
-
- —
-
-
-
-
-
-
-
-
-
-
-
-
- Report trigger
-
-
- Schedule
-
-
-
-
-
-
- Schedule type
-
-
- Recurring
-
-
-
-
-
-
- Schedule details
-
-
- —
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render on-demand component 1`] = `
-
-
-
- Report details
-
-
-
-
-
-
- Report Settings
-
-
-
-
-
-
- Name
-
-
- test create report definition trigger
-
-
-
-
-
-
- Description
-
-
- —
-
-
-
-
-
-
- Created
-
-
- —
-
-
-
-
-
-
- Last updated
-
-
- —
-
-
-
-
-
-
-
-
-
-
- Time period
-
-
- Invalid Date -> 10/23/2020, 8:53:35 PM
-
-
-
-
-
-
- File format
-
-
-
- undefined
-
-
-
-
-
-
-
-
-
-
-
-
- Report header
-
-
-
- —
-
-
-
-
-
-
-
- Report footer
-
-
-
- —
-
-
-
-
-
-
-
-
-
-
-
- Report trigger
-
-
- On demand
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/main/report_details/__tests__/report_details.test.tsx b/dashboards-reports/public/components/main/report_details/__tests__/report_details.test.tsx
deleted file mode 100644
index 4bad6fa7..00000000
--- a/dashboards-reports/public/components/main/report_details/__tests__/report_details.test.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { ReportDetails } from '../report_details';
-import propsMock from '../../../../../test/propsMock';
-import httpClientMock from '../../../../../test/httpMockClient';
-import 'babel-polyfill';
-import { act } from 'react-dom/test-utils';
-
-function setBreadcrumbs(array: []) {
- jest.fn();
-}
-
-describe(' panel', () => {
- const match = {
- params: {
- reportId: '1',
- },
- };
-
- test('render on-demand component', async () => {
- const promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'On demand',
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- query_url: `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(time:(from:'2020-10-23T20:53:35.315Z',to:'2020-10-23T21:23:35.316Z'))`,
- config_list: []
- });
-
- const { container } = render(
-
- );
- await act(() => promise);
- await expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render 5 hours recurring component', async () => {
- const promise = Promise.resolve();
- const report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 5,
- unit: 'HOURS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- query_url: `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(time:(from:'2020-10-23T20:53:35.315Z',to:'2020-10-23T21:23:35.316Z'))`,
- config_list: []
- });
-
- const { container } = render(
-
- );
- await act(() => promise);
- await expect(container.firstChild).toMatchSnapshot();
- });
-});
diff --git a/dashboards-reports/public/components/main/report_details/report_details.tsx b/dashboards-reports/public/components/main/report_details/report_details.tsx
deleted file mode 100644
index 65fa02aa..00000000
--- a/dashboards-reports/public/components/main/report_details/report_details.tsx
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiFlexGroup,
- EuiFlexItem,
- EuiPage,
- EuiPageHeader,
- EuiTitle,
- EuiPageBody,
- EuiPageContent,
- EuiHorizontalRule,
- EuiSpacer,
- EuiDescriptionList,
- EuiDescriptionListTitle,
- EuiDescriptionListDescription,
- EuiPageHeaderSection,
- EuiLink,
- EuiIcon,
- EuiGlobalToastList,
-} from '@elastic/eui';
-import { fileFormatsUpper, generateReportById } from '../main_utils';
-import { GenerateReportLoadingModal } from '../loading_modal';
-import { ReportSchemaType } from '../../../../server/model';
-import dateMath from '@elastic/datemath';
-import {
- permissionsMissingActions,
- permissionsMissingToast,
- timeRangeMatcher,
-} from '../../utils/utils';
-import { TRIGGER_TYPE } from '../../../../server/routes/utils/constants';
-
-interface ReportDetails {
- reportName: string;
- description: string;
- created: string;
- lastUpdated: string;
- source: string;
- time_period: string;
- defaultFileFormat: string;
- state: string | undefined;
- reportHeader: string;
- reportFooter: string;
- triggerType: string;
- scheduleType: string;
- scheduleDetails: string;
- queryUrl: string;
-}
-
-export const ReportDetailsComponent = (props: { reportDetailsComponentTitle: any; reportDetailsComponentContent: any; }) => {
- const { reportDetailsComponentTitle, reportDetailsComponentContent } = props;
-
- return (
-
-
-
- {reportDetailsComponentTitle}
-
-
- {reportDetailsComponentContent}
-
-
-
- );
-};
-
-// convert markdown to plain text, trim it if it's longer than 3 lines
-export const trimAndRenderAsText = (markdown: string) => {
- if (!markdown) return markdown;
- const lines = markdown.split('\n').filter((line) => line);
- const elements = lines.slice(0, 3).map((line, i) => {line}
);
- return lines.length <= 3 ? elements : elements.concat(...
);
-};
-
-export const formatEmails = (emails: string[]) => {
- return Array.isArray(emails) ? emails.join(', ') : emails;
-};
-
-export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpClient: any; }) {
- const [reportDetails, setReportDetails] = useState({
- reportName: '',
- description: '',
- created: '',
- lastUpdated: '',
- source: '',
- time_period: '',
- defaultFileFormat: '',
- state: '',
- reportHeader: '',
- reportFooter: '',
- triggerType: '',
- scheduleType: '',
- scheduleDetails: '',
- queryUrl: ''
- });
- const [toasts, setToasts] = useState([]);
- const [showLoading, setShowLoading] = useState(false);
-
- const reportId = props.match['params']['reportId'];
-
- const handleLoading = (e: boolean | ((prevState: boolean) => boolean)) => {
- setShowLoading(e);
- };
-
- const addPermissionsMissingDownloadToastHandler = () => {
- const toast = permissionsMissingToast(
- permissionsMissingActions.GENERATING_REPORT
- );
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const handlePermissionsMissingDownloadToast = () => {
- addPermissionsMissingDownloadToastHandler();
- };
-
- const addErrorToastHandler = (
- title = i18n.translate(
- 'opensearch.reports.details.errorLoadingReportDetails',
- { defaultMessage: 'Error loading report details.' }
- ),
- text = ''
- ) => {
- const errorToast = {
- title,
- text,
- color: 'danger',
- iconType: 'alert',
- id: 'reportDetailsErrorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleErrorToast = (title?: string, text?: string) => {
- addErrorToastHandler(title, text);
- };
-
- const addSuccessToastHandler = () => {
- const successToast = {
- title: 'Success',
- color: 'success',
- text: (
-
- {i18n.translate(
- 'opensearch.reports.details.reportSuccessfullyDownloaded',
- { defaultMessage: 'Report successfully downloaded!' }
- )}
-
- ),
- id: 'onDemandDownloadSuccessToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(successToast));
- };
-
- const handleSuccessToast = () => {
- addSuccessToastHandler();
- };
-
- const removeToast = (removedToast: { id: any; }) => {
- setToasts(toasts.filter((toast : any) => toast.id !== removedToast.id));
- };
-
- const handleReportDetails = (e: React.SetStateAction) => {
- setReportDetails(e);
- };
-
- const convertTimestamp = (timestamp: number | undefined) => {
- let displayDate = `\u2014`;
- if (timestamp) {
- let readableDate = new Date(timestamp);
- displayDate = readableDate.toLocaleString();
- }
- return displayDate;
- };
-
- const parseTimePeriod = (queryUrl: string) => {
- let [fromDateString, toDateString] : RegExpMatchArray | null = queryUrl.match(
- timeRangeMatcher
- );
-
- fromDateString = decodeURIComponent(fromDateString.replace(/[']+/g, ''));
- toDateString = decodeURIComponent(toDateString.replace(/[']+/g, ''));
-
- let fromDateParsed = dateMath.parse(fromDateString);
- let toDateParsed = dateMath.parse(toDateString, { roundUp: true });
-
- const fromTimePeriod = fromDateParsed?.toDate();
- const toTimePeriod = toDateParsed?.toDate();
- return (
- fromTimePeriod?.toLocaleString() + ' -> ' + toTimePeriod?.toLocaleString()
- );
- };
-
- const getReportDetailsData = (
- report: ReportSchemaType
- ) : ReportDetails => {
- const {
- report_definition: reportDefinition,
- last_updated: lastUpdated,
- state,
- query_url: queryUrl,
- } = report;
- const { report_params: reportParams, trigger } = reportDefinition;
- const {
- trigger_type: triggerType,
- trigger_params: triggerParams,
- } = trigger;
- const coreParams = reportParams.core_params;
- // covert timestamp to local date-time string
- let reportDetails = {
- reportName: reportParams.report_name,
- description:
- reportParams.description === '' ? `\u2014` : reportParams.description,
- created: convertTimestamp(report.time_created),
- lastUpdated: convertTimestamp(report.last_updated),
- source: reportParams.report_source,
- // TODO: we have all data needed, time_from, time_to, time_duration,
- // think of a way to better display
- time_period: (reportParams.report_source !== 'Notebook') ? parseTimePeriod(queryUrl) : `\u2014`,
- defaultFileFormat: coreParams.report_format,
- state: state,
- reportHeader:
- reportParams.core_params.hasOwnProperty('header') &&
- reportParams.core_params.header != ''
- ? reportParams.core_params.header
- : `\u2014`,
- reportFooter:
- reportParams.core_params.hasOwnProperty('footer') &&
- reportParams.core_params.footer != ''
- ? reportParams.core_params.footer
- : `\u2014`,
- triggerType: triggerType,
- scheduleType: triggerParams ? triggerParams.schedule_type : `\u2014`,
- scheduleDetails: `\u2014`,
- queryUrl: queryUrl,
- };
- return reportDetails;
- };
-
- useEffect(() => {
- const { httpClient } = props;
- httpClient
- .get('../api/reporting/reports/' + reportId)
- .then((response: ReportSchemaType) => {
- handleReportDetails(getReportDetailsData(response));
- props.setBreadcrumbs([
- {
- text: i18n.translate(
- 'opensearch.reports.details.breadcrumb.reporting',
- { defaultMessage: 'Reporting' }
- ),
- href: '#',
- },
- {
- text: i18n.translate(
- 'opensearch.reports.details.breadcrumb.reportDetails',
- {
- defaultMessage: 'Report details: {name}',
- values: {
- name: response.report_definition.report_params.report_name,
- },
- }
- ),
- },
- ]);
- })
- .catch((error: any) => {
- console.log('Error when fetching report details: ', error);
- handleErrorToast();
- });
- }, []);
-
- const downloadIconDownload = async () => {
- handleLoading(true);
- await generateReportById(
- reportId,
- props.httpClient,
- handleSuccessToast,
- handleErrorToast,
- handlePermissionsMissingDownloadToast
- );
- handleLoading(false);
- };
-
- const fileFormatDownload = (data: ReportDetails) => {
- let formatUpper = data['defaultFileFormat'];
- formatUpper = fileFormatsUpper[formatUpper];
- return (
-
- {formatUpper + ' '}
-
-
- );
- };
-
- const sourceURL = (data: ReportDetails) => {
- return (
-
- {data['source']}
-
- );
- };
-
- const triggerSection =
- reportDetails.triggerType === TRIGGER_TYPE.onDemand ? (
-
- ) : (
-
-
-
-
-
-
- )
-
- const showLoadingModal = showLoading ? (
-
- ) : null;
-
- return (
-
-
-
-
- {i18n.translate('opensearch.reports.details.title', {
- defaultMessage: 'Report details',
- })}
-
-
-
-
-
-
-
-
-
- {reportDetails.reportName}
-
-
-
-
-
-
-
-
- {i18n.translate('opensearch.reports.details.reportSettings', {
- defaultMessage: 'Report Settings',
- })}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {triggerSection}
-
-
- {showLoadingModal}
-
-
- );
-}
diff --git a/dashboards-reports/public/components/main/reports_table.tsx b/dashboards-reports/public/components/main/reports_table.tsx
deleted file mode 100644
index 90b85563..00000000
--- a/dashboards-reports/public/components/main/reports_table.tsx
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { Fragment, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiButton,
- // @ts-ignore
- EuiLink,
- EuiText,
- EuiIcon,
- EuiEmptyPrompt,
- EuiInMemoryTable,
-} from '@elastic/eui';
-import {
- fileFormatsUpper,
- humanReadableDate,
- generateReportById,
-} from './main_utils';
-import { GenerateReportLoadingModal } from './loading_modal';
-
-const reportStatusOptions = [
- 'Created',
- 'Error',
- 'Pending',
- 'Shared',
- 'Archived',
-];
-const reportTypeOptions = ['Schedule', 'On demand'];
-
-const emptyMessageReports = (
-
- {i18n.translate(
- 'opensearch.reports.reportsTable.emptyMessageReports.noReportsToDisplay',
- { defaultMessage: 'No reports to display' }
- )}
-
- }
- titleSize="xs"
- body={
-
-
- {i18n.translate(
- 'opensearch.reports.reportsTable.emptyMessageReports.createAReportDefinition',
- {
- defaultMessage:
- 'Create a report definition, or share/download a report from a dashboard, saved search or visualization.',
- }
- )}
-
-
- {i18n.translate(
- 'opensearch.reports.reportsTable.emptyMessageReports.toLearnMore',
- { defaultMessage: 'To learn more, see' }
- )}{' '}
-
- {i18n.translate(
- 'opensearch.reports.reportsTable.emptyMessageReports.getStarted',
- {
- defaultMessage:
- 'Get started with OpenSearch Dashboards reporting',
- }
- )}
-
-
-
-
- }
- />
-);
-
-export function ReportsTable(props) {
- const {
- pagination,
- reportsTableItems,
- httpClient,
- handleSuccessToast,
- handleErrorToast,
- handlePermissionsMissingToast,
- } = props;
-
- const [sortField, setSortField] = useState('timeCreated');
- const [sortDirection, setSortDirection] = useState('des');
- const [showLoading, setShowLoading] = useState(false);
- const [message, setMessage] = useState('');
-
- const handleLoading = (e) => {
- setShowLoading(e);
- };
-
- const onDemandDownload = async (id: any) => {
- handleLoading(true);
- await generateReportById(
- id,
- httpClient,
- handleSuccessToast,
- handleErrorToast,
- handlePermissionsMissingToast
- );
- handleLoading(false);
- };
-
- const reportsTableColumns = [
- {
- field: 'reportName',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.Name',
- { defaultMessage: 'Name' }
- ),
- render: (reportName, item) => (
- {
- window.location.assign(
- `reports-dashboards#/report_details/${item.id}`
- );
- }}
- id={'reportDetailsLink'}
- >
- {reportName}
-
- ),
- },
- {
- // TODO: link to dashboard/visualization snapshot, use "queryUrl" field. Display dashboard name?
- field: 'reportSource',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.Source',
- { defaultMessage: 'Source' }
- ),
- render: (source, item) =>
- item.state === 'Pending' ? (
- {source}
- ) : (
-
- {source}
-
- ),
- },
- {
- field: 'type',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.Type',
- { defaultMessage: 'Type' }
- ),
- sortable: true,
- truncateText: false,
- },
- {
- field: 'timeCreated',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.creationTime',
- { defaultMessage: 'Creation time' }
- ),
- render: (date) => {
- let readable = humanReadableDate(date);
- return {readable} ;
- },
- },
- {
- field: 'state',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.State',
- { defaultMessage: 'State' }
- ),
- sortable: true,
- truncateText: false,
- },
- {
- field: 'id',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsTableColumns.Generate',
- { defaultMessage: 'Generate' }
- ),
- render: (id, item) =>
- item.state === 'Pending' ? (
-
- {fileFormatsUpper[item.format]}
-
- ) : (
- onDemandDownload(id)}
- id="landingPageOnDemandDownload"
- >
- {fileFormatsUpper[item.format]}
-
- ),
- },
- ];
-
- const sorting = {
- sort: {
- field: sortField,
- direction: sortDirection,
- },
- };
-
- const reportsListSearch = {
- box: {
- incremental: true,
- },
- filters: [
- {
- type: 'field_value_selection',
- field: 'type',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsListSearch.Type',
- { defaultMessage: 'Type' }
- ),
- multiSelect: 'or',
- options: reportTypeOptions.map((type) => ({
- value: type,
- name: type,
- view: type,
- })),
- },
- {
- type: 'field_value_selection',
- field: 'state',
- name: i18n.translate(
- 'opensearch.reports.reportsTable.reportsListSearch.State',
- { defaultMessage: 'State' }
- ),
- multiSelect: 'or',
- options: reportStatusOptions.map((state) => ({
- value: state,
- name: state,
- view: state,
- })),
- },
- ],
- };
-
- const displayMessage =
- reportsTableItems.length === 0
- ? emptyMessageReports
- : i18n.translate(
- 'opensearch.reports.reportsTable.reportsListSearch.noRreportsMatch',
- {
- defaultMessage: '0 reports match the search criteria. Search again',
- }
- );
-
- const showLoadingModal = showLoading ? (
-
- ) : null;
-
- return (
-
-
- {showLoadingModal}
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/create/create_report_definition.tsx b/dashboards-reports/public/components/report_definitions/create/create_report_definition.tsx
deleted file mode 100644
index eed7015a..00000000
--- a/dashboards-reports/public/components/report_definitions/create/create_report_definition.tsx
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiButtonEmpty,
- EuiFlexGroup,
- EuiFlexItem,
- EuiGlobalToastList,
- EuiButton,
- EuiTitle,
- EuiPageBody,
- EuiSpacer,
-} from '@elastic/eui';
-import { ReportSettings } from '../report_settings';
-import { generateReportFromDefinitionId } from '../../main/main_utils';
-import { converter } from '../utils';
-import {
- permissionsMissingToast,
- permissionsMissingActions,
-} from '../../utils/utils';
-import { definitionInputValidation } from '../utils/utils';
-
-interface reportParamsType {
- report_name: string;
- report_source: string;
- description: string;
- core_params: visualReportParams | dataReportParams;
-}
-interface visualReportParams {
- base_url: string;
- report_format: string;
- header: string;
- footer: string;
- time_duration: string;
-}
-
-interface dataReportParams {
- saved_search_id: number;
- base_url: string;
- report_format: string;
- time_duration: string;
-}
-interface triggerType {
- trigger_type: string;
- trigger_params?: any;
-}
-
-interface deliveryType {
- configIds: Array;
- title: string;
- textDescription: string;
- htmlDescription: string;
-}
-
-export interface TriggerParamsType {
- schedule_type: string;
- schedule: Recurring | Cron;
- enabled_time: number;
- enabled: boolean;
-}
-
-interface Recurring {
- interval: {
- period: number;
- unit: string;
- start_time: number;
- };
-}
-
-interface Cron {
- cron: {
- cron_expression: string;
- time_zone: string;
- };
-}
-
-export interface reportDefinitionParams {
- report_params: reportParamsType;
- delivery: deliveryType;
- trigger: triggerType;
-}
-
-export interface timeRangeParams {
- timeFrom: Date;
- timeTo: Date;
-}
-
-export function CreateReport(props: { [x: string]: any; setBreadcrumbs?: any; httpClient?: any; }) {
- let createReportDefinitionRequest: reportDefinitionParams = {
- report_params: {
- report_name: '',
- report_source: '',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: '',
- },
- };
-
- const [toasts, setToasts] = useState([]);
- const [comingFromError, setComingFromError] = useState(false);
- const [preErrorData, setPreErrorData] = useState({});
-
- const [
- showSettingsReportNameError,
- setShowSettingsReportNameError,
- ] = useState(false);
- const [
- settingsReportNameErrorMessage,
- setSettingsReportNameErrorMessage,
- ] = useState('');
- const [
- showSettingsReportSourceError,
- setShowSettingsReportSourceError,
- ] = useState(false);
- const [
- settingsReportSourceErrorMessage,
- setSettingsReportSourceErrorMessage,
- ] = useState('');
- const [
- showTriggerIntervalNaNError,
- setShowTriggerIntervalNaNError,
- ] = useState(false);
- const [showCronError, setShowCronError] = useState(false);
- const [showTimeRangeError, setShowTimeRangeError] = useState(false);
-
- // preserve the state of the request after an invalid create report definition request
- if (comingFromError) {
- createReportDefinitionRequest = preErrorData;
- }
-
- const addInputValidationErrorToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.createReportDefinition.error.fieldsHaveAnError',
- {
- defaultMessage:
- 'One or more fields have an error. Please check and try again.',
- }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleInputValidationErrorToast = () => {
- addInputValidationErrorToastHandler();
- };
-
- const addErrorOnCreateToastHandler = (errorType: string) => {
- let toast = {};
- if (errorType === 'permissions') {
- toast = permissionsMissingToast(
- permissionsMissingActions.CREATING_REPORT_DEFINITION
- );
- } else if (errorType === 'API') {
- toast = {
- title: i18n.translate(
- 'opensearch.reports.createReportDefinition.error.errorCreating',
- { defaultMessage: 'Error creating report definition.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- }
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const handleErrorOnCreateToast = (errorType: string) => {
- addErrorOnCreateToastHandler(errorType);
- };
-
- const addInvalidTimeRangeToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.createReportDefinition.error.invalidTimeRange',
- { defaultMessage: 'Invalid time range selected.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'timeRangeErrorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleInvalidTimeRangeToast = () => {
- addInvalidTimeRangeToastHandler();
- };
-
- const removeToast = (removedToast: { id: string; }) => {
- setToasts(toasts.filter((toast: any) => toast.id !== removedToast.id));
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- const createNewReportDefinition = async (
- metadata: reportDefinitionParams,
- timeRange: timeRangeParams
- ) => {
- const { httpClient } = props;
- //TODO: need better handle
- if (
- metadata.trigger.trigger_type === 'On demand' &&
- metadata.trigger.trigger_params !== undefined
- ) {
- delete metadata.trigger.trigger_params;
- }
-
- let error = false;
- await definitionInputValidation(
- metadata,
- error,
- setShowSettingsReportNameError,
- setSettingsReportNameErrorMessage,
- setShowSettingsReportSourceError,
- setSettingsReportSourceErrorMessage,
- setShowTriggerIntervalNaNError,
- timeRange,
- setShowTimeRangeError,
- setShowCronError,
- ).then((response) => {
- error = response;
- });
- if (error) {
- handleInputValidationErrorToast();
- setPreErrorData(metadata);
- setComingFromError(true);
- } else {
- httpClient
- .post('../api/reporting/reportDefinition', {
- body: JSON.stringify(metadata),
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .then(async (resp: { scheduler_response: { reportDefinitionId: string; }; }) => {
- //TODO: consider handle the on demand report generation from server side instead
- if (metadata.trigger.trigger_type === 'On demand') {
- const reportDefinitionId =
- resp.scheduler_response.reportDefinitionId;
- generateReportFromDefinitionId(reportDefinitionId, httpClient);
- }
- window.location.assign(`reports-dashboards#/create=success`);
- })
- .catch((error: {body: { statusCode: number; }; }) => {
- console.log('error in creating report definition: ' + error);
- if (error.body.statusCode === 403) {
- handleErrorOnCreateToast('permissions');
- } else {
- handleErrorOnCreateToast('API');
- }
- });
- }
- };
-
- useEffect(() => {
- window.scrollTo(0, 0);
- props.setBreadcrumbs([
- {
- text: i18n.translate(
- 'opensearch.reports.createReportDefinition.breadcrumb.reporting',
- { defaultMessage: 'Reporting' }
- ),
- href: '#',
- },
- {
- text: i18n.translate(
- 'opensearch.reports.createReportDefinition.breadcrumb.createReportDefinition',
- { defaultMessage: 'Create report definition' }
- ),
- href: '#/create',
- },
- ]);
- }, []);
-
- return (
-
-
-
-
- {i18n.translate('opensearch.reports.createReportDefinition.title', {
- defaultMessage: 'Create report definition',
- })}
-
-
-
-
-
-
-
- {
- window.location.assign(`reports-dashboards#/`);
- }}
- >
- {i18n.translate(
- 'opensearch.reports.createReportDefinition.cancel',
- { defaultMessage: 'Cancel' }
- )}
-
-
-
-
- createNewReportDefinition(
- createReportDefinitionRequest,
- timeRange
- )
- }
- id={'createNewReportDefinition'}
- >
- {i18n.translate(
- 'opensearch.reports.createReportDefinition.create',
- { defaultMessage: 'Create' }
- )}
-
-
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/create/index.ts b/dashboards-reports/public/components/report_definitions/create/index.ts
deleted file mode 100644
index 4f247918..00000000
--- a/dashboards-reports/public/components/report_definitions/create/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { CreateReport } from './create_report_definition';
diff --git a/dashboards-reports/public/components/report_definitions/delivery/__tests__/__snapshots__/delivery.test.tsx.snap b/dashboards-reports/public/components/report_definitions/delivery/__tests__/__snapshots__/delivery.test.tsx.snap
deleted file mode 100644
index 3df27334..00000000
--- a/dashboards-reports/public/components/report_definitions/delivery/__tests__/__snapshots__/delivery.test.tsx.snap
+++ /dev/null
@@ -1,83 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[` panel render create component 1`] = `
-
-
-
-
-
-
-
-
- Send notification when report is available
-
-
-
-
-`;
-
-exports[` panel render edit component 1`] = `
-
-
-
-
-
-
-
-
- Send notification when report is available
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/report_definitions/delivery/__tests__/delivery.test.tsx b/dashboards-reports/public/components/report_definitions/delivery/__tests__/delivery.test.tsx
deleted file mode 100644
index fed5f8a8..00000000
--- a/dashboards-reports/public/components/report_definitions/delivery/__tests__/delivery.test.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { ReportDelivery } from '../delivery';
-import httpClientMock from '../../../../../test/httpMockClient';
-import { act } from 'react-dom/test-utils';
-
-const emptyRequest = {
- report_params: {
- report_name: '',
- report_source: '',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: '',
- trigger_params: {},
- },
- time_created: 0,
- last_updated: 0,
- status: '',
-};
-
-const timeRange = {
- timeFrom: new Date(1234567800),
- timeTo: new Date(1234567890),
-};
-
-global.fetch = jest.fn(() => ({
- then: jest.fn(() => ({
- then: jest.fn()
- }))
-}));
-
-describe(' panel', () => {
- test('render create component', () => {
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render edit component', async () => {
- const promise = Promise.resolve();
- let editReportDefinitionRequest = {
- report_params: {
- report_name: 'edit cron schedule component',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'On demand',
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition: editReportDefinitionRequest,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-});
diff --git a/dashboards-reports/public/components/report_definitions/delivery/delivery.tsx b/dashboards-reports/public/components/report_definitions/delivery/delivery.tsx
deleted file mode 100644
index b3ab50f3..00000000
--- a/dashboards-reports/public/components/report_definitions/delivery/delivery.tsx
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import {
- EuiFormRow,
- EuiPageHeader,
- EuiTitle,
- EuiPageContent,
- EuiPageContentBody,
- EuiHorizontalRule,
- EuiSpacer,
- EuiCheckbox,
- EuiComboBox,
- EuiFieldText,
- EuiButton,
-} from '@elastic/eui';
-import CSS from 'csstype';
-import {
- getChannelsQueryObject,
- noDeliveryChannelsSelectedMessage,
- testMessageConfirmationMessage,
- testMessageFailureMessage,
-} from './delivery_constants';
-import 'react-mde/lib/styles/css/react-mde-all.css';
-import { reportDefinitionParams } from '../create/create_report_definition';
-import ReactMDE from 'react-mde';
-import { converter } from '../utils';
-import { getAvailableNotificationsChannels } from '../../main/main_utils';
-import { REPORTING_NOTIFICATIONS_DASHBOARDS_API } from '../../../../common';
-
-const styles: CSS.Properties = {
- maxWidth: '800px',
-};
-
-// TODO: add to schema to avoid need for export
-export let includeDelivery = false;
-
-export type ReportDeliveryProps = {
- edit: boolean;
- editDefinitionId: string;
- reportDefinitionRequest: reportDefinitionParams;
- httpClientProps: any;
- showDeliveryChannelError: boolean;
- deliveryChannelError: string;
- showDeliverySubjectError: boolean;
- deliverySubjectError: string;
- showDeliveryTextError: boolean;
- deliveryTextError: string;
-};
-
-export function ReportDelivery(props: ReportDeliveryProps) {
- const {
- edit,
- editDefinitionId,
- reportDefinitionRequest,
- httpClientProps,
- showDeliveryChannelError,
- deliveryChannelError,
- showDeliverySubjectError,
- deliverySubjectError,
- showDeliveryTextError,
- deliveryTextError,
- } = props;
-
- const [isDeliveryHidden, setIsHidden] = useState(false);
- const [sendNotification, setSendNotification] = useState(false);
- const [channels, setChannels] = useState([]);
- const [selectedChannels, setSelectedChannels] = useState([]);
- const [notificationSubject, setNotificationSubject] = useState('New report');
- const [notificationMessage, setNotificationMessage] = useState(
- 'New report available to view'
- );
- const [selectedTab, setSelectedTab] = React.useState<'write' | 'preview'>(
- 'write'
- );
- const [testMessageConfirmation, setTestMessageConfirmation] = useState('');
-
- const handleSendNotification = (e: { target: { checked: boolean } }) => {
- setSendNotification(e.target.checked);
- includeDelivery = e.target.checked;
- if (includeDelivery) {
- reportDefinitionRequest.delivery.title = 'New report';
- reportDefinitionRequest.delivery.textDescription =
- 'New report available to view';
- reportDefinitionRequest.delivery.htmlDescription = converter.makeHtml(
- 'New report available to view'
- );
- } else {
- reportDefinitionRequest.delivery.title = `\u2014`;
- reportDefinitionRequest.delivery.textDescription = `\u2014`;
- }
- };
-
- const handleSelectedChannels = (e: Array<{ label: string; id: string }>) => {
- setSelectedChannels(e);
- reportDefinitionRequest.delivery.configIds = [];
- for (let i = 0; i < e.length; ++i) {
- reportDefinitionRequest.delivery.configIds.push(e[i].id);
- }
- };
-
- const handleNotificationSubject = (e: { target: { value: string } }) => {
- setNotificationSubject(e.target.value);
- reportDefinitionRequest.delivery.title = e.target.value;
- };
-
- const handleNotificationMessage = (e: string) => {
- setNotificationMessage(e);
- reportDefinitionRequest.delivery.textDescription = e.toString();
- reportDefinitionRequest.delivery.htmlDescription = converter.makeHtml(
- e.toString()
- );
- };
-
- const handleTestMessageConfirmation = (e: JSX.Element) => {
- setTestMessageConfirmation(e);
- };
-
- const defaultCreateDeliveryParams = () => {
- includeDelivery = false;
- reportDefinitionRequest.delivery = {
- configIds: [],
- title: `\u2014`, // default values before any Notifications settings are configured
- textDescription: `\u2014`,
- htmlDescription: '',
- };
- };
-
- const isStatusCodeSuccess = (statusCode: string) => {
- if (!statusCode) return true;
- return /^2\d\d/.test(statusCode);
- };
-
- const eventToNotification = (event: any) => {
- const success = event.event.status_list.every((status: any) =>
- isStatusCodeSuccess(status.delivery_status.status_code)
- );
- return {
- event_source: event.event.event_source,
- status_list: event.event.status_list,
- event_id: event.event_id,
- created_time_ms: event.created_time_ms,
- last_updated_time_ms: event.last_updated_time_ms,
- success,
- };
- };
-
- const getNotification = async (id: string) => {
- const response = await httpClientProps.get(
- `${REPORTING_NOTIFICATIONS_DASHBOARDS_API.GET_EVENT}/${id}`
- );
- return eventToNotification(response.event_list[0]);
- };
-
- const sendTestNotificationsMessage = async () => {
- if (selectedChannels.length === 0) {
- handleTestMessageConfirmation(noDeliveryChannelsSelectedMessage);
- }
- let testMessageFailures = false;
- let failedChannels: string[] = [];
- // for each config ID in the current channels list
- for (let i = 0; i < selectedChannels.length; ++i) {
- try {
- const eventId = await httpClientProps
- .get(
- `${REPORTING_NOTIFICATIONS_DASHBOARDS_API.SEND_TEST_MESSAGE}/${selectedChannels[i].id}`,
- {
- query: {
- feature: 'reports',
- },
- }
- )
- .then((response) => response.event_id);
-
- await getNotification(eventId).then((response) => {
- if (!response.success) {
- const error = new Error('Failed to send the test message.');
- failedChannels.push(response.status_list[0].config_name);
- error.stack = JSON.stringify(response.status_list, null, 2);
- throw error;
- }
- });
- } catch (error) {
- testMessageFailures = true;
- }
- }
- if (testMessageFailures) {
- handleTestMessageConfirmation(testMessageFailureMessage(failedChannels));
- } else {
- handleTestMessageConfirmation(testMessageConfirmationMessage);
- }
- };
-
- const checkIfNotificationsPluginIsInstalled = () => {
- fetch(
- '../api/console/proxy?path=%2F_cat%2Fplugins%3Fv%3Dtrue%26s%3Dcomponent%26h%3Dcomponent&method=GET',
- {
- credentials: 'include',
- headers: {
- Accept: 'text/plain, */*; q=0.01',
- 'Accept-Language': 'en-US,en;q=0.5',
- 'osd-xsrf': 'true',
- },
- method: 'POST',
- mode: 'cors',
- }
- )
- .then((response) => {
- return response.text();
- })
- .then(function (data) {
- if (data.includes('opensearch-notifications')) {
- setIsHidden(false);
- return;
- }
- setIsHidden(true);
- });
- };
-
- useEffect(() => {
- checkIfNotificationsPluginIsInstalled();
- httpClientProps
- .get(`${REPORTING_NOTIFICATIONS_DASHBOARDS_API.GET_CONFIGS}`, {
- query: getChannelsQueryObject,
- })
- .then(async (response: any) => {
- let availableChannels = getAvailableNotificationsChannels(
- response.config_list
- );
- setChannels(availableChannels);
- return availableChannels;
- })
- .then((availableChannels: any) => {
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response: any) => {
- if (response.report_definition.delivery.configIds.length > 0) {
- // add config IDs
- handleSendNotification({ target: { checked: true } });
- let delivery = response.report_definition.delivery;
- let editChannelOptions = [];
- for (let i = 0; i < delivery.configIds.length; ++i) {
- for (let j = 0; j < availableChannels.length; ++j) {
- if (delivery.configIds[i] === availableChannels[j].id) {
- let editChannelOption = {
- label: availableChannels[j].label,
- id: availableChannels[j].id,
- };
- editChannelOptions.push(editChannelOption);
- break;
- }
- }
- }
- setSelectedChannels(editChannelOptions);
- setNotificationSubject(delivery.title);
- setNotificationMessage(delivery.textDescription);
- reportDefinitionRequest.delivery = delivery;
- }
- });
- } else {
- defaultCreateDeliveryParams();
- }
- })
- .catch((error: string) => {
- console.log(
- 'error: cannot get available channels from Notifications plugin:',
- error
- );
- });
- }, []);
-
- const showNotificationsBody = sendNotification ? (
-
-
-
-
-
-
-
-
-
-
-
-
- Promise.resolve(converter.makeHtml(markdown))
- }
- />
-
-
-
-
- Send test message
-
-
-
- ) : null;
-
- return (
-
-
-
- Notification settings
-
-
-
-
-
- {showNotificationsBody}
-
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/delivery/delivery_constants.tsx b/dashboards-reports/public/components/report_definitions/delivery/delivery_constants.tsx
deleted file mode 100644
index 3e049470..00000000
--- a/dashboards-reports/public/components/report_definitions/delivery/delivery_constants.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from "react";
-import { EuiIcon, EuiText } from '@elastic/eui'
-
-export const noDeliveryChannelsSelectedMessage = (
-
- Please select a channel.
-
-)
-
-export const testMessageConfirmationMessage = (
-
- Test message sent to selected channels. If no test message is received, try again or check your channel settings in Notifications.
-
-);
-
-export const testMessageFailureMessage = (failedChannels: Array) => (
-
- Failed to send test message for some channels. Please adjust channel settings for {failedChannels.toString()}
-
-)
-
-export const getChannelsQueryObject = {
- config_type: ['slack', 'email', 'chime', 'webhook', 'sns', 'ses'],
- from_index: 0,
- max_items: 1000,
- sort_field: 'name',
- sort_order: 'asc',
- feature_list: ['reports']
-}
diff --git a/dashboards-reports/public/components/report_definitions/delivery/index.ts b/dashboards-reports/public/components/report_definitions/delivery/index.ts
deleted file mode 100644
index 91d85f4a..00000000
--- a/dashboards-reports/public/components/report_definitions/delivery/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { ReportDelivery } from './delivery';
diff --git a/dashboards-reports/public/components/report_definitions/edit/edit_report_definition.tsx b/dashboards-reports/public/components/report_definitions/edit/edit_report_definition.tsx
deleted file mode 100644
index 3e876931..00000000
--- a/dashboards-reports/public/components/report_definitions/edit/edit_report_definition.tsx
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiButtonEmpty,
- EuiFlexGroup,
- EuiFlexItem,
- EuiButton,
- EuiPage,
- EuiTitle,
- EuiPageBody,
- EuiSpacer,
- EuiGlobalToastList,
-} from '@elastic/eui';
-import { ReportSettings } from '../report_settings';
-import { ReportTrigger } from '../report_trigger';
-import { ReportDefinitionSchemaType } from 'server/model';
-import { converter } from '../utils';
-import {
- permissionsMissingToast,
- permissionsMissingActions,
-} from '../../utils/utils';
-import { definitionInputValidation } from '../utils/utils';
-
-export function EditReportDefinition(props: { [x: string]: any; setBreadcrumbs?: any; httpClient?: any; }) {
- const [toasts, setToasts] = useState([]);
- const [comingFromError, setComingFromError] = useState(false);
- const [preErrorData, setPreErrorData] = useState({});
-
- const [
- showSettingsReportNameError,
- setShowSettingsReportNameError,
- ] = useState(false);
- const [
- settingsReportNameErrorMessage,
- setSettingsReportNameErrorMessage,
- ] = useState('');
- const [
- showSettingsReportSourceError,
- setShowSettingsReportSourceError,
- ] = useState(false);
- const [
- settingsReportSourceErrorMessage,
- setSettingsReportSourceErrorMessage,
- ] = useState('');
- const [
- showTriggerIntervalNaNError,
- setShowTriggerIntervalNaNError,
- ] = useState(false);
- const [showCronError, setShowCronError] = useState(false);
- const [showTimeRangeError, setShowTimeRangeError] = useState(false);
-
- const addPermissionsMissingViewEditPageToastHandler = (errorType: string) => {
- let toast = {};
- if (errorType === 'permissions') {
- toast = permissionsMissingToast(
- permissionsMissingActions.VIEWING_EDIT_PAGE
- );
- } else if (errorType === 'API') {
- toast = {
- title: i18n.translate(
- 'opensearch.reports.editReportDefinition.errorLoading',
- { defaultMessage: 'Error loading report definition values.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- }
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const handleViewEditPageErrorToast = (errorType: string) => {
- addPermissionsMissingViewEditPageToastHandler(errorType);
- };
-
- const addInputValidationErrorToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.editReportDefinition.fieldsHaveAnError',
- {
- defaultMessage:
- 'One or more fields have an error. Please check and try again.',
- }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleInputValidationErrorToast = () => {
- addInputValidationErrorToastHandler();
- };
-
- const addErrorUpdatingReportDefinitionToastHandler = (errorType: string) => {
- let toast = {};
- if (errorType === 'permissions') {
- toast = permissionsMissingToast(
- permissionsMissingActions.UPDATING_DEFINITION
- );
- } else if (errorType === 'API') {
- toast = {
- title: i18n.translate(
- 'opensearch.reports.editReportDefinition.errorUpdating',
- { defaultMessage: 'Error updating report definition.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorToast',
- };
- }
- // @ts-ignore
- setToasts(toasts.concat(toast));
- };
-
- const handleErrorUpdatingReportDefinitionToast = (errorType: string) => {
- addErrorUpdatingReportDefinitionToastHandler(errorType);
- };
-
- const addErrorDeletingReportDefinitionToastHandler = () => {
- const errorToast = {
- title: i18n.translate(
- 'opensearch.reports.editReportDefinition.errorDeleting',
- { defaultMessage: 'Error deleting old scheduled report definition.' }
- ),
- color: 'danger',
- iconType: 'alert',
- id: 'errorDeleteToast',
- };
- // @ts-ignore
- setToasts(toasts.concat(errorToast));
- };
-
- const handleErrorDeletingReportDefinitionToast = () => {
- addErrorDeletingReportDefinitionToastHandler();
- };
-
- const removeToast = (removedToast: { id: any; }) => {
- setToasts(toasts.filter((toast: any) => toast.id !== removedToast.id));
- };
-
- const reportDefinitionId = props['match']['params']['reportDefinitionId'];
- let reportDefinition: ReportDefinitionSchemaType;
- let editReportDefinitionRequest = {
- report_params: {
- report_name: '',
- report_source: '',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: '',
- },
- time_created: 0,
- last_updated: 0,
- status: '',
- };
- reportDefinition = editReportDefinitionRequest; // initialize reportDefinition object
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- if (comingFromError) {
- editReportDefinitionRequest = preErrorData;
- }
-
- const callUpdateAPI = async (metadata) => {
- const { httpClient } = props;
- httpClient
- .put(`../api/reporting/reportDefinitions/${reportDefinitionId}`, {
- body: JSON.stringify(metadata),
- params: reportDefinitionId.toString(),
- })
- .then(async () => {
- window.location.assign(`reports-dashboards#/edit=success`);
- })
- .catch((error: { body: { statusCode: number; }; }) => {
- console.log('error in updating report definition:', error);
- if (error.body.statusCode === 400) {
- handleInputValidationErrorToast();
- } else if (error.body.statusCode === 403) {
- handleErrorUpdatingReportDefinitionToast('permissions');
- } else {
- handleErrorUpdatingReportDefinitionToast('API');
- }
- setPreErrorData(metadata);
- setComingFromError(true);
- });
- };
-
- const editReportDefinition = async (metadata: { report_params: {core_params: {header: string, footer: string}}}) => {
- if ('header' in metadata.report_params.core_params) {
- metadata.report_params.core_params.header = converter.makeHtml(
- metadata.report_params.core_params.header
- );
- }
- if ('footer' in metadata.report_params.core_params) {
- metadata.report_params.core_params.footer = converter.makeHtml(
- metadata.report_params.core_params.footer
- );
- }
-
- // client-side input validation
- let error = false;
- await definitionInputValidation(
- metadata,
- error,
- setShowSettingsReportNameError,
- setSettingsReportNameErrorMessage,
- setShowSettingsReportSourceError,
- setSettingsReportSourceErrorMessage,
- setShowTriggerIntervalNaNError,
- timeRange,
- setShowTimeRangeError,
- setShowCronError,
- ).then((response) => {
- error = response;
- });
- if (error) {
- handleInputValidationErrorToast();
- setPreErrorData(metadata);
- setComingFromError(true);
- } else {
- await callUpdateAPI(metadata);
- }
- };
-
- useEffect(() => {
- window.scrollTo(0, 0);
- const { httpClient } = props;
- httpClient
- .get(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
- .then((response) => {
- reportDefinition = response.report_definition;
- const {
- time_created: timeCreated,
- status,
- last_updated: lastUpdated,
- report_params: { report_name: reportName },
- } = reportDefinition;
- // configure non-editable fields
- editReportDefinitionRequest.time_created = timeCreated;
- editReportDefinitionRequest.last_updated = lastUpdated;
- editReportDefinitionRequest.status = status;
-
- props.setBreadcrumbs([
- {
- text: 'Reporting',
- href: '#',
- },
- {
- text: `Report definition details: ${reportName}`,
- href: `#/report_definition_details/${reportDefinitionId}`,
- },
- {
- text: `Edit report definition: ${reportName}`,
- },
- ]);
- })
- .catch((error: { body: { statusCode: number; }; }) => {
- console.error(
- 'error when loading edit report definition page: ',
- error
- );
- if (error.body.statusCode === 403) {
- handleViewEditPageErrorToast('permissions');
- } else {
- handleViewEditPageErrorToast('API');
- }
- });
- }, []);
-
- return (
-
-
-
-
- {i18n.translate('opensearch.reports.editReportDefinition.title', {
- defaultMessage: 'Edit report definition',
- })}
-
-
-
-
-
-
-
- {
- window.location.assign('reports-dashboards#/');
- }}
- >
- {i18n.translate(
- 'opensearch.reports.editReportDefinition.cancel',
- { defaultMessage: 'Cancel' }
- )}
-
-
-
- editReportDefinition(editReportDefinitionRequest)}
- id={'editReportDefinitionButton'}
- >
- {i18n.translate('opensearch.reports.editReportDefinition.save', {
- defaultMessage: 'Save Changes',
- })}
-
-
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/edit/index.ts b/dashboards-reports/public/components/report_definitions/edit/index.ts
deleted file mode 100644
index bcba3740..00000000
--- a/dashboards-reports/public/components/report_definitions/edit/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { EditReportDefinition } from './edit_report';
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/__snapshots__/report_settings.test.tsx.snap b/dashboards-reports/public/components/report_definitions/report_settings/__tests__/__snapshots__/report_settings.test.tsx.snap
deleted file mode 100644
index d348db59..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/__snapshots__/report_settings.test.tsx.snap
+++ /dev/null
@@ -1,8471 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[` panel dashboard create from in-context 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel display errors on create 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render component 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render edit, dashboard source 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render edit, dashboard source 2`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render edit, saved search source 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render edit, visualization source 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel render edit, visualization source 2`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel saved search create from in-context 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[` panel visualization create from in-context 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Report header and footer
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings.test.tsx b/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings.test.tsx
deleted file mode 100644
index 0f7ead8f..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings.test.tsx
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { render } from '@testing-library/react';
-import { ReportSettings } from '../report_settings';
-import 'babel-polyfill';
-import 'regenerator-runtime';
-import httpClientMock from '../../../../../test/httpMockClient';
-import { configure, mount, shallow } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
-import { act } from 'react-dom/test-utils';
-
-const emptyRequest = {
- report_params: {
- report_name: '',
- report_source: '',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- time_duration: '',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: '',
- trigger_params: {},
- },
- time_created: 0,
- last_updated: 0,
- status: '',
-};
-
-let timeRange = {
- timeFrom: new Date(123456789),
- timeTo: new Date(1234567890),
-};
-
-const dashboardHits = {
- hits: [
- {
- _id: 'dashboard:abcdefghijklmnop12345',
- _source: {
- dashboard: {
- description: 'mock dashboard value',
- hits: 0,
- timeFrom: 'now-24h',
- timeTo: 'now',
- title: 'Mock Dashboard',
- },
- notebook: {
- name: 'mock notebook name'
- }
- },
- },
- ],
-};
-
-const visualizationHits = {
- hits: [
- {
- _id: 'visualization:abcdefghijklmnop12345',
- _source: {
- visualization: {
- description: 'mock visualization value',
- title: 'Mock Visualization',
- },
- notebook: {
- name: 'mock notebook name'
- },
- },
- },
- ],
-};
-
-const savedSearchHits = {
- hits: [
- {
- _id: 'search:abcdefghijklmnop12345',
- _source: {
- search: {
- title: 'Mock saved search value',
- },
- notebook: {
- name: 'mock notebook name'
- },
- },
- },
- ],
-};
-
-describe(' panel', () => {
- jest.spyOn(console, 'log').mockImplementation(() => {});
- configure({ adapter: new Adapter() });
- test('render component', () => {
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- });
-
- test('render edit, dashboard source', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601/dashboard/abcdefghijklmnop12345',
- report_format: 'pdf',
- header: 'header content',
- footer: 'footer content',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: dashboardHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit, visualization source', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Visualization',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601/edit/abcdefghijklmnop12345',
- report_format: 'png',
- header: 'header content',
- footer: 'footer content',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: visualizationHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit, saved search source', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601/discover/abcdefghijklmnop12345',
- report_format: 'csv',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- saved_search_id: 'abcdefghijk',
- limit: 10000,
- excel: true,
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: savedSearchHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit, dashboard source', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'csv',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- saved_search_id: 'abcdefghijk',
- limit: 10000,
- excel: true,
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: dashboardHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit, visualization source', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'csv',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- saved_search_id: 'abcdefghijk',
- limit: 10000,
- excel: true,
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: visualizationHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
-
- test('dashboard create from in-context', async () => {
- window = Object.create(window);
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- href:
- 'http://localhost:5601/app/reports-dashboards#/create?previous=dashboard:abcdefghijklmnop12345?timeFrom=2020-10-26T20:52:56.382Z?timeTo=2020-10-27T20:52:56.384Z',
- },
- });
-
- const promise = Promise.resolve();
-
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: 'http://localhost:5601/dashboard/abcdefghijklmnop12345',
- report_format: 'png',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: dashboardHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('visualization create from in-context', async () => {
- // @ts-ignore
- delete window.location; // reset window.location.href for in-context testing
-
- window = Object.create(window);
- Object.defineProperty(window, 'location', {
- configurable: true,
- value: {
- href:
- 'http://localhost:5601/app/reports-dashboards#/create?previous=visualize:abcdefghijklmnop12345?timeFrom=2020-10-26T20:52:56.382Z?timeTo=2020-10-27T20:52:56.384Z',
- },
- });
-
- const promise = Promise.resolve();
-
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Visualization',
- description: '',
- core_params: {
- base_url: 'http://localhost:5601/edit/abcdefghijklmnop12345',
- report_format: 'pdf',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: visualizationHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('saved search create from in-context', async () => {
- // @ts-ignore
- delete window.location; // reset window.location.href for in-context testing
-
- window = Object.create(window);
- Object.defineProperty(window, 'location', {
- value: {
- href:
- 'http://localhost:5601/app/reports-dashboards#/create?previous=discover:abcdefghijklmnop12345?timeFrom=2020-10-26T20:52:56.382Z?timeTo=2020-10-27T20:52:56.384Z',
- },
- });
-
- const promise = Promise.resolve();
-
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: '',
- core_params: {
- base_url: 'http://localhost:5601/discover/abcdefghijklmnop12345',
- report_format: 'csv',
- header: '',
- footer: '',
- time_duration: 'PT30M',
- saved_search_id: 'abcdefghijk',
- limit: 10000,
- excel: true,
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {},
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: savedSearchHits,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('simulate click on dashboard combo box', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'csv',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- saved_search_id: 'abcdefghijk',
- limit: 10000,
- excel: true,
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: dashboardHits,
- });
-
- const component = shallow(
-
- , {disableLifecycleMethods: true});
- await act(() => promise);
-
- const comboBox = component.find('EuiComboBox').at(0);
- comboBox.simulate('change', [{value: 'test', label: 'test'}]);
-
- await act(() => promise);
- });
-
- test('simulate click on visualization combo box', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Visualization',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'pdf',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: visualizationHits,
- });
-
- const component = mount(
-
- );
- await act(() => promise);
-
- const reportSourceRadio = component.find('EuiRadioGroup').at(0);
- const visualizationRadio = reportSourceRadio.find('EuiRadio').at(1);
-
- visualizationRadio.find('input').simulate('change', 'visualizationReportSource');
- await act(() => promise);
- const comboBox = component.find('EuiComboBox').at(0);
-
- act(() => {
- comboBox.props().onChange([{ value: 'test', label: 'test' }]);
- });
- component.update();
-
- await act(() => promise);
- });
-
- test('simulate click on saved search combo box', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Saved search',
- description: 'test description',
- core_params: {
- base_url: 'http://localhost:5601',
- report_format: 'pdf',
- header: 'test header content',
- footer: 'test footer content',
- time_duration: 'PT30M',
- },
- },
- delivery: {
- configIds: [],
- title: '',
- textDescription: '',
- htmlDescription: ''
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- enabled: false,
- enabled_time: 1234567890,
- schedule: {
- interval: {
- period: 1,
- start_time: 123456789,
- unit: 'Days'
- }
- }
- },
- },
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- hits: savedSearchHits,
- });
-
- const component = mount(
-
- );
- await act(() => promise);
-
- const reportSourceRadio = component.find('EuiRadioGroup').at(0);
- const visualizationRadio = reportSourceRadio.find('EuiRadio').at(2);
-
- visualizationRadio.find('input').simulate('change', 'savedSearchReportSource');
- await act(() => promise);
- const comboBox = component.find('EuiComboBox').at(0);
-
- act(() => {
- comboBox.props().onChange([{ value: 'test', label: 'test' }]);
- })
- component.update();
-
- await act(() => promise);
- });
-
- test('display errors on create', async () => {
- const promise = Promise.resolve();
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-});
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings_helpers.test.tsx b/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings_helpers.test.tsx
deleted file mode 100644
index 9a5b3367..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/__tests__/report_settings_helpers.test.tsx
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import {
- getDashboardBaseUrlCreate,
- getDashboardOptions,
- getSavedSearchBaseUrlCreate,
- getSavedSearchOptions,
- getVisualizationBaseUrlCreate,
- getVisualizationOptions,
- handleDataToVisualReportSourceChange,
- parseInContextUrl,
-} from '../report_settings_helpers';
-
-const TEST_DEFINITION_ID = '12345';
-
-describe('report_settings_helpers tests', () => {
- test('parseInContextUrl', () => {
- const urlString =
- 'http://localhost:5601/app/reports-dashboards#/create?previous=dashboard:7adfa750-4c81-11e8-b3d7-01146121b73d?timeFrom=2020-10-26T20:52:56.382Z?timeTo=2020-10-27T20:52:56.384Z';
-
- const id = parseInContextUrl(urlString, 'id');
- expect(id).toBe('7adfa750-4c81-11e8-b3d7-01146121b73d');
-
- const timeFrom = parseInContextUrl(urlString, 'timeFrom');
- expect(timeFrom).toBe('2020-10-26T20:52:56.382Z');
-
- const timeTo = parseInContextUrl(urlString, 'timeTo');
- expect(timeTo).toBe('2020-10-27T20:52:56.384Z');
-
- const error = parseInContextUrl(urlString, 'invalid');
- expect(error).toBe('error: invalid parameter');
- });
-
- test('getDashboardBaseUrlCreate', () => {
- const baseUrl = getDashboardBaseUrlCreate(true, TEST_DEFINITION_ID, true);
- expect(baseUrl).toBe('/app/dashboards#/view/');
-
- const baseUrlNotFromEdit = getDashboardBaseUrlCreate(
- false,
- TEST_DEFINITION_ID,
- true
- );
- expect(baseUrlNotFromEdit).toBe('/app/dashboards#/view/');
- });
-
- test('getDashboardBaseUrlCreate not from in-context', () => {
- const baseUrl = getDashboardBaseUrlCreate(false, TEST_DEFINITION_ID, false);
- expect(baseUrl).toBe('/');
- })
-
- test('getVisualizationBaseUrlCreate', () => {
- const baseUrl = getVisualizationBaseUrlCreate(
- true,
- TEST_DEFINITION_ID,
- true
- );
- expect(baseUrl).toBe('/app/visualize#/edit/');
-
- const baseUrlNotFromEdit = getVisualizationBaseUrlCreate(
- false,
- TEST_DEFINITION_ID,
- true
- );
- expect(baseUrlNotFromEdit).toBe('/app/visualize#/edit/');
- });
-
- test('getVisualizationBaseUrlCreate not from in-context', () => {
- const baseUrl = getVisualizationBaseUrlCreate(
- false,
- TEST_DEFINITION_ID,
- false
- );
- expect(baseUrl).toBe('/');
- })
-
- test('getSavedSearchBaseUrlCreate', () => {
- const baseUrl = getSavedSearchBaseUrlCreate(true, TEST_DEFINITION_ID, true);
- expect(baseUrl).toBe('/app/discover#/view/');
-
- const baseUrlNotFromEdit = getSavedSearchBaseUrlCreate(
- false,
- TEST_DEFINITION_ID,
- true
- );
- expect(baseUrlNotFromEdit).toBe('/app/discover#/view/');
- });
-
- test('getSavedSearchBaseUrlCreate not from in-context', () => {
- const baseUrl = getSavedSearchBaseUrlCreate(false, TEST_DEFINITION_ID, false);
- expect(baseUrl).toBe('/');
- })
-
- test('getDashboardOptions', () => {
- const mockData = [
- {
- _id: 'dashboard:1234567890abcdefghijk',
- _source: {
- dashboard: {
- title: 'Mock dashboard title',
- },
- },
- },
- ];
-
- const options = getDashboardOptions(mockData);
- expect(options[0].value).toBe('1234567890abcdefghijk');
- expect(options[0].label).toBe('Mock dashboard title');
- });
-
- test('getVisualizationOptions', () => {
- const mockData = [
- {
- _id: 'visualization:1234567890abcdefghijk',
- _source: {
- visualization: {
- title: 'Mock visualization title',
- },
- },
- },
- ];
-
- const options = getVisualizationOptions(mockData);
- expect(options[0].value).toBe('1234567890abcdefghijk');
- expect(options[0].label).toBe('Mock visualization title');
- });
-
- test('getSavedSearchOptions', () => {
- const mockData = [
- {
- _id: 'search:1234567890abcdefghijk',
- _source: {
- search: {
- title: 'Mock saved search title',
- },
- },
- },
- ];
- const options = getSavedSearchOptions(mockData);
- expect(options[0].value).toBe('1234567890abcdefghijk');
- expect(options[0].label).toBe('Mock saved search title');
- });
-
- test('handleDataToVisualReportSourceChange', () => {
- let reportDefinitionRequest = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- report_format: '',
- saved_search_id: '',
- limit: 10,
- excel: true,
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {},
- },
- };
-
- handleDataToVisualReportSourceChange(reportDefinitionRequest);
- expect(
- reportDefinitionRequest.report_params.core_params.report_format
- ).toBe('pdf');
- expect(reportDefinitionRequest.report_params.core_params).toMatchObject({
- report_format: 'pdf',
- });
- });
-});
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/index.ts b/dashboards-reports/public/components/report_definitions/report_settings/index.ts
deleted file mode 100644
index 2b410f03..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { ReportSettings } from './report_settings';
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/report_settings.tsx b/dashboards-reports/public/components/report_definitions/report_settings/report_settings.tsx
deleted file mode 100644
index 0db86cfd..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/report_settings.tsx
+++ /dev/null
@@ -1,926 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiFieldText,
- EuiFlexGroup,
- EuiFlexItem,
- EuiFormRow,
- EuiPageHeader,
- EuiTitle,
- EuiPageContent,
- EuiPageContentBody,
- EuiHorizontalRule,
- EuiText,
- EuiSpacer,
- EuiRadioGroup,
- EuiSelect,
- EuiTextArea,
- EuiCheckboxGroup,
- EuiComboBox,
-} from '@elastic/eui';
-import {
- REPORT_SOURCE_RADIOS,
- PDF_PNG_FILE_FORMAT_OPTIONS,
- HEADER_FOOTER_CHECKBOX,
- REPORT_SOURCE_TYPES,
-} from './report_settings_constants';
-import Showdown from 'showdown';
-import ReactMde from 'react-mde';
-import 'react-mde/lib/styles/css/react-mde-all.css';
-import {
- reportDefinitionParams,
- timeRangeParams,
-} from '../create/create_report_definition';
-import {
- parseInContextUrl,
- getSavedSearchBaseUrlCreate,
- getVisualizationBaseUrlCreate,
- getSavedSearchOptions,
- getVisualizationOptions,
- getDashboardBaseUrlCreate,
- getDashboardOptions,
- handleDataToVisualReportSourceChange,
- getNotebooksOptions,
- getNotebooksBaseUrlCreate,
- getReportSourceFromURL,
-} from './report_settings_helpers';
-import { TimeRangeSelect } from './time_range';
-import { converter } from '../utils';
-import { ReportDefinitionSchemaType } from 'server/model';
-import { ReportTrigger } from '../report_trigger';
-
-type ReportSettingProps = {
- edit: boolean;
- editDefinitionId: string;
- reportDefinitionRequest: reportDefinitionParams;
- httpClientProps: any;
- timeRange: timeRangeParams;
- showSettingsReportNameError: boolean;
- settingsReportNameErrorMessage: string;
- showSettingsReportSourceError: boolean;
- settingsReportSourceErrorMessage: string;
- showTimeRangeError: boolean;
- showTriggerIntervalNaNError: boolean;
- showCronError: boolean;
-};
-
-export function ReportSettings(props: ReportSettingProps) {
- const {
- edit,
- editDefinitionId,
- reportDefinitionRequest,
- httpClientProps,
- timeRange,
- showSettingsReportNameError,
- settingsReportNameErrorMessage,
- showSettingsReportSourceError,
- settingsReportSourceErrorMessage,
- showTimeRangeError,
- showTriggerIntervalNaNError,
- showCronError
- } = props;
-
- const [reportName, setReportName] = useState('');
- const [reportDescription, setReportDescription] = useState('');
- const [reportSourceId, setReportSourceId] = useState('dashboardReportSource');
-
- const [dashboardSourceSelect, setDashboardSourceSelect] = useState([] as any);
- const [dashboards, setDashboards] = useState([] as any);
-
- const [visualizationSourceSelect, setVisualizationSourceSelect] = useState(
- [] as any
- );
- const [visualizations, setVisualizations] = useState([] as any);
-
- const [savedSearchSourceSelect, setSavedSearchSourceSelect] = useState(
- [] as any
- );
- const [savedSearches, setSavedSearches] = useState([] as any);
-
- const [notebooksSourceSelect, setNotebooksSourceSelect] = useState([] as any);
- const [notebooks, setNotebooks] = useState([] as any);
-
- const [fileFormat, setFileFormat] = useState('pdf');
-
- const handleDashboards = (e) => {
- setDashboards(e);
- };
-
- const handleVisualizations = (e) => {
- setVisualizations(e);
- };
-
- const handleSavedSearches = (e) => {
- setSavedSearches(e);
- };
-
- const handleNotebooks = (e) => {
- setNotebooks(e);
- };
-
- const handleReportName = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setReportName(e.target.value);
- reportDefinitionRequest.report_params.report_name = e.target.value.toString();
- };
-
- const handleReportDescription = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setReportDescription(e.target.value);
- reportDefinitionRequest.report_params.description = e.target.value.toString();
- };
-
- const handleReportSource = (e: React.SetStateAction) => {
- setReportSourceId(e);
- let fromInContext = false;
- if (window.location.href.includes('?')) {
- fromInContext = true;
- }
- if (e === 'dashboardReportSource') {
- reportDefinitionRequest.report_params.report_source = 'Dashboard';
- reportDefinitionRequest.report_params.core_params.base_url =
- getDashboardBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- dashboards[0]?.value;
-
- // set params to visual report params after switch from saved search
- handleDataToVisualReportSourceChange(reportDefinitionRequest);
- setFileFormat('pdf');
- } else if (e === 'visualizationReportSource') {
- reportDefinitionRequest.report_params.report_source = 'Visualization';
- reportDefinitionRequest.report_params.core_params.base_url =
- getVisualizationBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- visualizations[0]?.value;
-
- // set params to visual report params after switch from saved search
- handleDataToVisualReportSourceChange(reportDefinitionRequest);
- setFileFormat('pdf');
- } else if (e === 'savedSearchReportSource') {
- reportDefinitionRequest.report_params.report_source = 'Saved search';
- reportDefinitionRequest.report_params.core_params.base_url =
- getSavedSearchBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- savedSearches[0]?.value;
- reportDefinitionRequest.report_params.core_params.saved_search_id =
- savedSearches[0]?.value;
- reportDefinitionRequest.report_params.core_params.report_format = 'csv';
- reportDefinitionRequest.report_params.core_params.limit = 10000;
- reportDefinitionRequest.report_params.core_params.excel = true;
- } else if (e === 'notebooksReportSource') {
- reportDefinitionRequest.report_params.report_source = 'Notebook';
- reportDefinitionRequest.report_params.core_params.base_url =
- getNotebooksBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- notebooks[0]?.value;
-
- // set params to visual report params after switch from saved search
- handleDataToVisualReportSourceChange(reportDefinitionRequest);
- setFileFormat('pdf');
- }
- };
-
- const handleDashboardSelect = (e: string | any[]) => {
- setDashboardSourceSelect(e);
-
- let fromInContext = false;
- if (window.location.href.includes('?')) {
- fromInContext = true;
- }
-
- if (e.length > 0) {
- reportDefinitionRequest.report_params.core_params.base_url =
- getDashboardBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- e[0].value;
- } else {
- reportDefinitionRequest.report_params.core_params.base_url = '';
- }
- };
-
- const handleVisualizationSelect = (e) => {
- setVisualizationSourceSelect(e);
- let fromInContext = false;
- if (window.location.href.includes('?')) {
- fromInContext = true;
- }
-
- if (e.length > 0) {
- reportDefinitionRequest.report_params.core_params.base_url =
- getVisualizationBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- e[0].value;
- } else {
- reportDefinitionRequest.report_params.core_params.base_url = '';
- }
- };
-
- const handleSavedSearchSelect = (e) => {
- setSavedSearchSourceSelect(e);
- let fromInContext = false;
- if (window.location.href.includes('?')) {
- fromInContext = true;
- }
- if (e.length > 0) {
- reportDefinitionRequest.report_params.core_params.saved_search_id =
- e[0].value;
-
- reportDefinitionRequest.report_params.core_params.base_url =
- getSavedSearchBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- e[0].value;
- } else {
- reportDefinitionRequest.report_params.core_params.base_url = '';
- }
- };
-
- const handleNotebooksSelect = (e) => {
- setNotebooksSourceSelect(e);
- let fromInContext = false;
- if (window.location.href.includes('?')) {
- fromInContext = true;
- }
- if (e.length > 0) {
- reportDefinitionRequest.report_params.core_params.base_url =
- getNotebooksBaseUrlCreate(edit, editDefinitionId, fromInContext) +
- e[0].value;
- } else {
- reportDefinitionRequest.report_params.core_params.base_url = '';
- }
- };
-
- const handleFileFormat = (e: React.SetStateAction) => {
- setFileFormat(e);
- reportDefinitionRequest.report_params.core_params.report_format = e.toString();
- };
-
- const PDFandPNGFileFormats = () => {
- return (
-
-
-
-
-
- );
- };
-
- const SettingsMarkdown = () => {
- const [
- checkboxIdSelectHeaderFooter,
- setCheckboxIdSelectHeaderFooter,
- ] = useState({ ['header']: false, ['footer']: false });
-
- const [footer, setFooter] = useState('');
- const [selectedTabFooter, setSelectedTabFooter] = React.useState<
- 'write' | 'preview'
- >('write');
-
- const [header, setHeader] = useState('');
- const [selectedTabHeader, setSelectedTabHeader] = React.useState<
- 'write' | 'preview'
- >('write');
-
- const handleHeader = (e) => {
- setHeader(e);
- reportDefinitionRequest.report_params.core_params.header = e;
- };
-
- const handleFooter = (e) => {
- setFooter(e);
- reportDefinitionRequest.report_params.core_params.footer = e;
- };
-
- const handleCheckboxHeaderFooter = (optionId) => {
- const newCheckboxIdToSelectedMap = {
- ...checkboxIdSelectHeaderFooter,
- ...{
- [optionId]: !checkboxIdSelectHeaderFooter[optionId],
- },
- };
- setCheckboxIdSelectHeaderFooter(newCheckboxIdToSelectedMap);
- };
-
- const showFooter = checkboxIdSelectHeaderFooter.footer ? (
-
-
- Promise.resolve(converter.makeHtml(markdown))
- }
- />
-
- ) : null;
-
- const showHeader = checkboxIdSelectHeaderFooter.header ? (
-
-
- Promise.resolve(converter.makeHtml(markdown))
- }
- />
-
- ) : null;
-
- useEffect(() => {
- let unmounted = false;
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response: {}) => {
- const reportDefinition: ReportDefinitionSchemaType =
- response.report_definition;
- const {
- report_params: {
- core_params: { header, footer },
- },
- } = reportDefinition;
- // set header/footer default
- if (header) {
- checkboxIdSelectHeaderFooter.header = true;
- if (!unmounted) {
- setHeader(header);
- }
- }
- if (footer) {
- checkboxIdSelectHeaderFooter.footer = true;
- if (!unmounted) {
- setFooter(footer);
- }
- }
- })
- .catch((error: any) => {
- console.error(
- 'error in fetching report definition details:',
- error
- );
- });
- } else {
- // keeps header/footer from re-rendering empty when other fields in Report Settings are changed
- checkboxIdSelectHeaderFooter.header =
- 'header' in reportDefinitionRequest.report_params.core_params;
- checkboxIdSelectHeaderFooter.footer =
- 'footer' in reportDefinitionRequest.report_params.core_params;
- if (checkboxIdSelectHeaderFooter.header) {
- setHeader(reportDefinitionRequest.report_params.core_params.header);
- }
- if (checkboxIdSelectHeaderFooter.footer) {
- setFooter(reportDefinitionRequest.report_params.core_params.footer);
- }
- }
- return () => {
- unmounted = true;
- };
- }, []);
-
- return (
-
-
-
- {showHeader}
- {showFooter}
-
- );
- };
-
- const VisualReportFormatAndMarkdown = () => {
- return (
-
- );
- };
-
- const setReportSourceDropdownOption = (options, reportSource, url) => {
- let index = 0;
- if (reportSource === REPORT_SOURCE_TYPES.dashboard) {
- for (index = 0; index < options.dashboard.length; ++index) {
- if (url.includes(options.dashboard[index].value)) {
- setDashboardSourceSelect([options.dashboard[index]]);
- }
- }
- } else if (reportSource === REPORT_SOURCE_TYPES.visualization) {
- for (index = 0; index < options.visualizations.length; ++index) {
- if (url.includes(options.visualizations[index].value)) {
- setVisualizationSourceSelect([options.visualizations[index]]);
- }
- }
- } else if (reportSource === REPORT_SOURCE_TYPES.savedSearch) {
- for (index = 0; index < options.savedSearch.length; ++index) {
- if (url.includes(options.savedSearch[index].value)) {
- setSavedSearchSourceSelect([options.savedSearch[index]]);
- }
- }
- }
- };
-
- const setDefaultFileFormat = (fileFormat) => {
- let index = 0;
- for (index = 0; index < PDF_PNG_FILE_FORMAT_OPTIONS.length; ++index) {
- if (
- fileFormat.toUpperCase() === PDF_PNG_FILE_FORMAT_OPTIONS[index].label
- ) {
- setFileFormat(PDF_PNG_FILE_FORMAT_OPTIONS[index].id);
- }
- }
- };
-
- const setDashboardFromInContextMenu = (response, id) => {
- let index;
- for (index = 0; index < response.dashboard.length; ++index) {
- if (id === response.dashboard[index].value) {
- setDashboardSourceSelect([response.dashboard[index]]);
- }
- }
- };
-
- const setVisualizationFromInContextMenu = (response, id) => {
- let index;
- for (index = 0; index < response.visualizations.length; ++index) {
- if (id === response.visualizations[index].value) {
- setVisualizationSourceSelect([response.visualizations[index]]);
- }
- }
- };
-
- const setSavedSearchFromInContextMenu = (response, id) => {
- let index;
- for (index = 0; index < response.savedSearch.length; ++index) {
- if (id === response.savedSearch[index].value) {
- setSavedSearchSourceSelect([response.savedSearch[index]]);
- }
- }
- };
-
- const setNotebookFromInContextMenu = (response, id) => {
- for (let index = 0; index < response.notebooks.length; ++index) {
- if (id === response.notebooks[index].value) {
- setNotebooksSourceSelect([response.notebooks[index]]);
- }
- }
- };
-
- const setInContextDefaultConfiguration = (response) => {
- const url = window.location.href;
- const source = getReportSourceFromURL(url);
- const id = parseInContextUrl(url, 'id');
- if (source === 'dashboard') {
- setReportSourceId('dashboardReportSource');
- reportDefinitionRequest.report_params.report_source =
- REPORT_SOURCE_RADIOS[0].label;
-
- setDashboardFromInContextMenu(response, id);
- reportDefinitionRequest.report_params.core_params.base_url =
- getDashboardBaseUrlCreate(edit, id, true) + id;
- } else if (source === 'visualize') {
- setReportSourceId('visualizationReportSource');
- reportDefinitionRequest.report_params.report_source =
- REPORT_SOURCE_RADIOS[1].label;
-
- setVisualizationFromInContextMenu(response, id);
- reportDefinitionRequest.report_params.core_params.base_url =
- getVisualizationBaseUrlCreate(edit, editDefinitionId, true) + id;
- } else if (source === 'discover') {
- setReportSourceId('savedSearchReportSource');
- reportDefinitionRequest.report_params.core_params.report_format = 'csv';
- reportDefinitionRequest.report_params.core_params.saved_search_id = id;
- reportDefinitionRequest.report_params.report_source =
- REPORT_SOURCE_RADIOS[2].label;
-
- setSavedSearchFromInContextMenu(response, id);
- reportDefinitionRequest.report_params.core_params.base_url =
- getSavedSearchBaseUrlCreate(edit, editDefinitionId, true) + id;
- } else if (source === 'notebook') {
- setReportSourceId('notebooksReportSource');
- reportDefinitionRequest.report_params.report_source =
- REPORT_SOURCE_RADIOS[3].label;
-
- setNotebookFromInContextMenu(response, id);
- reportDefinitionRequest.report_params.core_params.base_url =
- getNotebooksBaseUrlCreate(edit, id, true) + id;
- // set placeholder time range since notebooks doesn't use it
- reportDefinitionRequest.report_params.core_params.time_duration = 'PT30M';
- }
- };
-
- const setDefaultEditValues = async (response, reportSourceOptions) => {
- setReportName(response.report_definition.report_params.report_name);
- setReportDescription(response.report_definition.report_params.description);
- reportDefinitionRequest.report_params.report_name =
- response.report_definition.report_params.report_name;
- reportDefinitionRequest.report_params.description =
- response.report_definition.report_params.description;
- reportDefinitionRequest.report_params =
- response.report_definition.report_params;
- const reportSource = response.report_definition.report_params.report_source;
- REPORT_SOURCE_RADIOS.map((radio) => {
- if (radio.label === reportSource) {
- setReportSourceId(radio.id);
- reportDefinitionRequest.report_params.report_source = reportSource;
- }
- });
- setDefaultFileFormat(
- response.report_definition.report_params.core_params.report_format
- );
- setReportSourceDropdownOption(
- reportSourceOptions,
- reportSource,
- response.report_definition.report_params.core_params.base_url
- );
- };
-
- const defaultConfigurationEdit = async (httpClientProps) => {
- let editData = {};
- await httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response: {}) => {
- editData = response;
- })
- .catch((error: any) => {
- console.error('error in fetching report definition details:', error);
- });
- return editData;
- };
-
- const defaultConfigurationCreate = async (httpClientProps) => {
- let reportSourceOptions = {
- dashboard: [],
- visualizations: [],
- savedSearch: [],
- notebooks: [],
- };
- reportDefinitionRequest.report_params.core_params.report_format = fileFormat;
- await httpClientProps
- .get('../api/reporting/getReportSource/dashboard')
- .then(async (response) => {
- let dashboardOptions = getDashboardOptions(response['hits']['hits']);
- reportSourceOptions.dashboard = dashboardOptions;
- handleDashboards(dashboardOptions);
- if (!edit) {
- reportDefinitionRequest.report_params.report_source = 'Dashboard';
- }
- })
- .catch((error) => {
- console.log('error when fetching dashboards:', error);
- });
-
- await httpClientProps
- .get('../api/reporting/getReportSource/visualization')
- .then(async (response) => {
- let visualizationOptions = getVisualizationOptions(
- response['hits']['hits']
- );
- reportSourceOptions.visualizations = visualizationOptions;
- await handleVisualizations(visualizationOptions);
- })
- .catch((error) => {
- console.log('error when fetching visualizations:', error);
- });
-
- await httpClientProps
- .get('../api/reporting/getReportSource/search')
- .then(async (response) => {
- let savedSearchOptions = getSavedSearchOptions(
- response['hits']['hits']
- );
- reportSourceOptions.savedSearch = savedSearchOptions;
- await handleSavedSearches(savedSearchOptions);
- })
- .catch((error) => {
- console.log('error when fetching saved searches:', error);
- });
-
- await httpClientProps
- .get('../api/observability/notebooks/')
- .catch((error: any) => {
- console.error('error fetching notebooks, retrying with legacy api', error)
- return httpClientProps.get('../api/notebooks/')
- })
- .then(async (response: any) => {
- let notebooksOptions = getNotebooksOptions(response.data);
- reportSourceOptions.notebooks = notebooksOptions;
- await handleNotebooks(notebooksOptions);
- })
- .catch((error) => {
- console.log('error when fetching notebooks:', error);
- });
- return reportSourceOptions;
- };
-
- useEffect(() => {
- let reportSourceOptions = {};
- let editData = {};
- if (edit) {
- defaultConfigurationEdit(httpClientProps).then(async (response) => {
- editData = response;
- });
- }
- defaultConfigurationCreate(httpClientProps).then(async (response) => {
- reportSourceOptions = response;
- // if coming from in-context menu
- if (window.location.href.indexOf('?') > -1) {
- setInContextDefaultConfiguration(response);
- }
- if (edit) {
- setDefaultEditValues(editData, reportSourceOptions);
- }
- });
- }, []);
-
- const displayDashboardSelect =
- reportSourceId === 'dashboardReportSource' ? (
-
-
-
-
-
-
- ) : null;
-
- const displayVisualizationSelect =
- reportSourceId === 'visualizationReportSource' ? (
-
-
-
-
-
-
- ) : null;
-
- const displaySavedSearchSelect =
- reportSourceId === 'savedSearchReportSource' ? (
-
-
-
-
-
-
- ) : null;
-
- const displayVisualReportsFormatAndMarkdown =
- reportSourceId != 'savedSearchReportSource' ? (
-
-
-
-
- ) : (
-
- );
-
- const displayNotebooksSelect =
- reportSourceId === 'notebooksReportSource' ? (
-
-
-
-
-
-
- ) : null;
-
- const displayTimeRangeSelect =
- reportSourceId != 'notebooksReportSource' ? (
-
-
-
-
- ) : null;
-
- return (
-
-
-
-
- {i18n.translate(
- 'opensearch.reports.reportSettingProps.form.reportSettings',
- { defaultMessage: 'Report settings' }
- )}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {displayDashboardSelect}
- {displayVisualizationSelect}
- {displaySavedSearchSelect}
- {/*
- */}
- {displayNotebooksSelect}
- {displayTimeRangeSelect}
- {displayVisualReportsFormatAndMarkdown}
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/report_settings_constants.tsx b/dashboards-reports/public/components/report_definitions/report_settings/report_settings_constants.tsx
deleted file mode 100644
index 824892f1..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/report_settings_constants.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { i18n } from '@osd/i18n';
-
-export const REPORT_SOURCE_RADIOS = [
- {
- id: 'dashboardReportSource',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.reportSourceRadios.dashboard',
- { defaultMessage: 'Dashboard' }
- ),
- },
- {
- id: 'visualizationReportSource',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.reportSourceRadios.visualization',
- { defaultMessage: 'Visualization' }
- ),
- },
- {
- id: 'savedSearchReportSource',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.reportSourceRadios.savedSearch',
- { defaultMessage: 'Saved search' }
- ),
- },
- {
- id: 'notebooksReportSource',
- label: 'Notebook',
- },
-];
-
-export const PDF_PNG_FILE_FORMAT_OPTIONS = [
- {
- id: 'pdf',
- label: 'PDF',
- },
- {
- id: 'png',
- label: 'PNG',
- },
-];
-
-export const SAVED_SEARCH_FORMAT_OPTIONS = [
- {
- id: 'csvFormat',
- label: 'CSV',
- },
- {
- id: 'xlsFormat',
- label: 'XLS',
- },
-];
-
-export const HEADER_FOOTER_CHECKBOX = [
- {
- id: 'header',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.headerFooterCheckbox.addHeader',
- { defaultMessage: 'Add header' }
- ),
- },
- {
- id: 'footer',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.headerFooterCheckbox.addFooter',
- { defaultMessage: 'Add footer' }
- ),
- },
-];
-export const REPORT_SOURCE_TYPES = {
- dashboard: 'Dashboard',
- visualization: 'Visualization',
- savedSearch: 'Saved search',
- notebook: 'Notebook',
-};
-
-export const commonTimeRanges = [
- {
- start: 'now/d',
- end: 'now',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.commonTimeRanges.todaySoFar',
- { defaultMessage: 'Today so far' }
- ),
- },
- {
- start: 'now/w',
- end: 'now',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.commonTimeRanges.weekToDate',
- { defaultMessage: 'Week to date' }
- ),
- },
- {
- start: 'now/M',
- end: 'now',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.commonTimeRanges.monthToDate',
- { defaultMessage: 'Month to date' }
- ),
- },
- {
- start: 'now/y',
- end: 'now',
- label: i18n.translate(
- 'opensearch.reports.settings.constants.commonTimeRanges.yearToDate',
- { defaultMessage: 'Year to date' }
- ),
- },
-];
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/report_settings_helpers.tsx b/dashboards-reports/public/components/report_definitions/report_settings/report_settings_helpers.tsx
deleted file mode 100644
index cc4ef232..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/report_settings_helpers.tsx
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export const parseInContextUrl = (url: string, parameter: string) => {
- const info = url.split('?');
- if (parameter === 'id') {
- return info[1].substring(info[1].indexOf(':') + 1, info[1].length);
- } else if (parameter === 'timeFrom') {
- return info[2].substring(info[2].indexOf('=') + 1, info[2].length);
- } else if (parameter === 'timeTo') {
- return info[3].substring(info[3].indexOf('=') + 1, info[3].length);
- }
- return 'error: invalid parameter';
-};
-
-export const getDashboardBaseUrlCreate = (
- edit: boolean,
- editDefinitionId: string,
- fromInContext: boolean
-) => {
- let baseUrl;
- if (!fromInContext) {
- baseUrl = location.pathname + location.hash;
- } else {
- baseUrl = '/app/dashboards#/view/';
- }
- if (edit) {
- return baseUrl.replace(
- `reports-dashboards#/edit/${editDefinitionId}`,
- 'dashboards#/view/'
- );
- } else if (fromInContext) {
- return baseUrl;
- }
- return baseUrl.replace(
- 'reports-dashboards#/create',
- 'dashboards#/view/'
- );
-};
-
-export const getVisualizationBaseUrlCreate = (
- edit: boolean,
- editDefinitionId: string,
- fromInContext: boolean
-) => {
- let baseUrl;
- if (!fromInContext) {
- baseUrl = location.pathname + location.hash;
- } else {
- baseUrl = '/app/visualize#/edit/';
- }
- if (edit) {
- return baseUrl.replace(
- `reports-dashboards#/edit/${editDefinitionId}`,
- 'visualize#/edit/'
- );
- } else if (fromInContext) {
- return baseUrl;
- }
- return baseUrl.replace(
- 'reports-dashboards#/create',
- 'visualize#/edit/'
- );
-};
-
-export const getSavedSearchBaseUrlCreate = (
- edit: boolean,
- editDefinitionId: string,
- fromInContext: boolean
-) => {
- let baseUrl;
- if (!fromInContext) {
- baseUrl = location.pathname + location.hash;
- } else {
- baseUrl = '/app/discover#/view/';
- }
- if (edit) {
- return baseUrl.replace(
- `reports-dashboards#/edit/${editDefinitionId}`,
- 'discover#/view/'
- );
- } else if (fromInContext) {
- return baseUrl;
- }
- return baseUrl.replace(
- 'reports-dashboards#/create',
- 'discover#/view/'
- );
-};
-
-export const getNotebooksBaseUrlCreate = (
- edit: boolean,
- editDefinitionId: string,
- fromInContext: boolean
-) => {
- let baseUrl;
- if (!fromInContext) {
- baseUrl = location.pathname + location.hash;
- } else {
- baseUrl = '/app/notebooks-dashboards?view=output_only#/';
- }
- if (edit) {
- return baseUrl.replace(
- `reports-dashboards#/edit/${editDefinitionId}`,
- 'notebooks-dashboards?view=output_only#/'
- );
- } else if (fromInContext) {
- return baseUrl;
- }
- return baseUrl.replace(
- 'reports-dashboards#/create',
- 'notebooks-dashboards?view=output_only#/'
- );
-}
-
-export const getDashboardOptions = (data: string | any[]) => {
- let index;
- let dashboard_options = [];
- for (index = 0; index < data.length; ++index) {
- let entry = {
- value: data[index]['_id'].substring(10),
- label: data[index]['_source']['dashboard']['title'],
- };
- dashboard_options.push(entry);
- }
- return dashboard_options;
-};
-
-export const getVisualizationOptions = (data: string | any[]) => {
- let index;
- let options = [];
- for (index = 0; index < data.length; ++index) {
- let entry = {
- value: data[index]['_id'].substring(14),
- label: data[index]['_source']['visualization']['title'],
- };
- options.push(entry);
- }
- return options;
-};
-
-export const getSavedSearchOptions = (data: string | any[]) => {
- let index;
- let options = [];
- for (index = 0; index < data.length; ++index) {
- let entry = {
- value: data[index]['_id'].substring(7),
- label: data[index]['_source']['search']['title'],
- };
- options.push(entry);
- }
- return options;
-};
-
-export const getNotebooksOptions = (data: any) => {
- let index;
- let options = [];
- for (index = 0; index < data.length; ++index) {
- let entry = {
- value: data[index]['id'],
- label: data[index]['path']
- }
- options.push(entry);
- }
- return options;
-}
-
-export const handleDataToVisualReportSourceChange = (
- reportDefinitionRequest
-) => {
- delete reportDefinitionRequest.report_params.core_params.saved_search_id;
- delete reportDefinitionRequest.report_params.core_params.limit;
- delete reportDefinitionRequest.report_params.core_params.excel;
- reportDefinitionRequest.report_params.core_params.report_format = 'pdf';
-};
-
-export const getReportSourceFromURL = (url: string) => {
- const source = url.split('?')[1].match(/previous=(.*):/);
- return source![1];
-}
\ No newline at end of file
diff --git a/dashboards-reports/public/components/report_definitions/report_settings/time_range.tsx b/dashboards-reports/public/components/report_definitions/report_settings/time_range.tsx
deleted file mode 100644
index f27630c6..00000000
--- a/dashboards-reports/public/components/report_definitions/report_settings/time_range.tsx
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import moment from 'moment';
-import React, { useState, useEffect } from 'react';
-import { i18n } from '@osd/i18n';
-import { parseInContextUrl } from './report_settings_helpers';
-import dateMath from '@elastic/datemath';
-import {
- EuiFormRow,
- EuiGlobalToastList,
- EuiSuperDatePicker,
-} from '@elastic/eui';
-import { commonTimeRanges } from './report_settings_constants';
-
-export function TimeRangeSelect(props) {
- const {
- reportDefinitionRequest,
- timeRange,
- edit,
- id,
- httpClientProps,
- showTimeRangeError,
- } = props;
-
- const [recentlyUsedRanges, setRecentlyUsedRanges] = useState([]);
- const [isLoading, setIsLoading] = useState(false);
- const [start, setStart] = useState('now-30m');
- const [end, setEnd] = useState('now');
-
- const [toasts, setToasts] = useState([]);
-
- const addInvalidTimeRangeToastHandler = () => {
- const errorToast = {
- title: i18n.translate('opensearch.reports.timeRange.invalidTimeRange', {
- defaultMessage: 'Invalid time range selected.',
- }),
- color: 'danger',
- iconType: 'alert',
- id: 'timeRangeErrorToast',
- };
- setToasts(toasts.concat(errorToast));
- };
-
- const handleInvalidTimeRangeToast = () => {
- addInvalidTimeRangeToastHandler();
- };
-
- const removeToast = (removedToast) => {
- setToasts(toasts.filter((toast) => toast.id !== removedToast.id));
- };
-
- const isValidTimeRange = (
- timeRangeMoment: number | moment.Moment,
- limit: string,
- handleInvalidTimeRangeToast: any
- ) => {
- if (limit === 'start') {
- if (!timeRangeMoment || !timeRangeMoment.isValid()) {
- handleInvalidTimeRangeToast();
- }
- } else if (limit === 'end') {
- if (
- !timeRangeMoment ||
- !timeRangeMoment.isValid() ||
- timeRangeMoment > moment.now()
- ) {
- handleInvalidTimeRangeToast();
- }
- }
- };
-
- const setDefaultEditTimeRange = (duration, unmounted) => {
- let time_difference = moment.now() - duration;
- const fromDate = new Date(time_difference);
- parseTimeRange(fromDate, end, reportDefinitionRequest);
- if (!unmounted) {
- setStart(fromDate.toISOString());
- setEnd(end);
- }
- };
-
- // valid time range check for absolute time end date
- const checkValidAbsoluteEndDate = (end) => {
- let endDate = new Date(end);
- let nowDate = new Date(moment.now());
- let valid = true;
- if (endDate.getTime() > nowDate.getTime()) {
- end = 'now';
- valid = false;
- }
- return valid;
- };
-
- useEffect(() => {
- let unmounted = false;
- // if we are coming from the in-context menu
- if (window.location.href.indexOf('?') > -1) {
- const url = window.location.href;
- const timeFrom = parseInContextUrl(url, 'timeFrom');
- const timeTo = parseInContextUrl(url, 'timeTo');
- parseTimeRange(timeFrom, timeTo, reportDefinitionRequest);
- if (!unmounted) {
- setStart(timeFrom);
- setEnd(timeTo);
- }
- } else {
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${id}`)
- .then(async (response: {}) => {
- let duration =
- response.report_definition.report_params.core_params
- .time_duration;
- duration = moment.duration(duration);
- setDefaultEditTimeRange(duration, unmounted);
- })
- .catch((error) => {
- console.error(
- 'error in fetching report definition details:',
- error
- );
- });
- } else {
- parseTimeRange(start, end, reportDefinitionRequest);
- }
- }
- return () => {
- unmounted = true;
- };
- }, []);
-
- const onTimeChange = ({ start, end }) => {
- isValidTimeRange(
- dateMath.parse(start),
- 'start',
- handleInvalidTimeRangeToast
- );
- isValidTimeRange(
- dateMath.parse(end, { roundUp: true }),
- 'end',
- handleInvalidTimeRangeToast
- );
-
- const recentlyUsedRange = recentlyUsedRanges.filter((recentlyUsedRange) => {
- const isDuplicate =
- recentlyUsedRange.start === start && recentlyUsedRange.end === end;
- return !isDuplicate;
- });
- const validEndDate = checkValidAbsoluteEndDate(end);
- if (!validEndDate) {
- handleInvalidTimeRangeToast();
- return;
- }
-
- recentlyUsedRange.unshift({ start, end });
- setStart(start);
- setEnd(end);
- setRecentlyUsedRanges(
- recentlyUsedRange.length > 10
- ? recentlyUsedRange.slice(0, 9)
- : recentlyUsedRange
- );
- setIsLoading(true);
- startLoading();
- parseTimeRange(start, end, reportDefinitionRequest);
- };
-
- const parseTimeRange = (start, end, reportDefinitionRequest) => {
- timeRange.timeFrom = dateMath.parse(start);
- timeRange.timeTo = dateMath.parse(end);
- const timeDuration = moment.duration(
- dateMath.parse(end).diff(dateMath.parse(start))
- );
- reportDefinitionRequest.report_params.core_params.time_duration = timeDuration.toISOString();
- };
-
- const startLoading = () => {
- setTimeout(stopLoading, 1000);
- };
-
- const stopLoading = () => {
- setIsLoading(false);
- };
-
- return (
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/__snapshots__/report_trigger.test.tsx.snap b/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/__snapshots__/report_trigger.test.tsx.snap
deleted file mode 100644
index c0973df4..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/__snapshots__/report_trigger.test.tsx.snap
+++ /dev/null
@@ -1,421 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[` panel Render edit on-demand component 1`] = `
-
-`;
-
-exports[` panel render create component 1`] = `
-
-`;
-
-exports[` panel render edit Cron schedule component 1`] = `
-
-`;
-
-exports[` panel render edit recurring 5 hours schedule component 1`] = `
-
-`;
-
-exports[` panel render edit recurring 10 minutes schedule component 1`] = `
-
-`;
-
-exports[` panel render edit recurring daily schedule component 1`] = `
-
-`;
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/report_trigger.test.tsx b/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/report_trigger.test.tsx
deleted file mode 100644
index b8c2f5d3..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/__tests__/report_trigger.test.tsx
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import {
- render,
- waitFor,
- waitForElement,
- waitForElementToBeRemoved,
-} from '@testing-library/react';
-import { ReportTrigger } from '../report_trigger';
-import 'babel-polyfill';
-import 'regenerator-runtime';
-import httpClientMock from '../../../../../test/httpMockClient';
-import { act } from 'react-dom/test-utils';
-import moment from 'moment-timezone';
-
-const names = jest.fn();
-
-const emptyRequest = {
- report_params: {
- report_name: '',
- report_source: '',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: '',
- trigger_params: {},
- },
- time_created: 0,
- last_updated: 0,
- status: '',
-};
-
-describe(' panel', () => {
- beforeEach(() => {
- jest.clearAllMocks();
- });
- test('render create component', () => {
- let createReportDefinitionRequest = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {},
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- });
-
- // edit test
- test('render edit recurring 5 hours schedule component', async () => {
- const promise = Promise.resolve();
- let report_definition = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 5,
- unit: 'HOURS',
- timezone: 'PST8PDT',
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit recurring daily schedule component', async () => {
- const promise = Promise.resolve();
- let editReportDefinitionRequest = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 1,
- unit: 'DAYS',
- start_time: 1114939203,
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition: editReportDefinitionRequest,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit Cron schedule component', async () => {
- const promise = Promise.resolve();
- let cronReportDefinitionRequest = {
- report_params: {
- report_name: 'edit cron schedule component',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Cron based',
- schedule: {
- cron: {
- expression: '30 1 * * *',
- timezone: 'PDT',
- },
- },
- enabled_time: 1234567890,
- enabled: true,
- },
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition: cronReportDefinitionRequest,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('render edit recurring 10 minutes schedule component', async () => {
- const promise = Promise.resolve();
- let editReportDefinitionRequest = {
- report_params: {
- report_name: 'test create report definition trigger',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'Schedule',
- trigger_params: {
- schedule_type: 'Recurring',
- schedule: {
- interval: {
- period: 10,
- unit: 'MINUTES',
- start_time: 1114939203,
- },
- },
- enabled_time: 1114939203,
- enabled: true,
- },
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition: editReportDefinitionRequest,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-
- test('Render edit on-demand component', async () => {
- const promise = Promise.resolve();
- let editReportDefinitionRequest = {
- report_params: {
- report_name: 'edit cron schedule component',
- report_source: 'Dashboard',
- description: '',
- core_params: {
- base_url: '',
- report_format: '',
- header: '',
- footer: '',
- time_duration: '',
- },
- },
- delivery: {
- delivery_type: '',
- delivery_params: {},
- },
- trigger: {
- trigger_type: 'On demand',
- },
- };
-
- let timeRange = {
- timeFrom: new Date(),
- timeTo: new Date(),
- };
-
- httpClientMock.get = jest.fn().mockResolvedValue({
- report_definition: editReportDefinitionRequest,
- });
-
- const { container } = render(
-
- );
-
- expect(container.firstChild).toMatchSnapshot();
- await act(() => promise);
- });
-});
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/index.ts b/dashboards-reports/public/components/report_definitions/report_trigger/index.ts
deleted file mode 100644
index 99c31037..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export { ReportTrigger } from './report_trigger';
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger.tsx b/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger.tsx
deleted file mode 100644
index 1ab67ebc..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger.tsx
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { useEffect, useState } from 'react';
-import { i18n } from '@osd/i18n';
-import {
- EuiFormRow,
- EuiRadioGroup,
- EuiDatePicker,
- EuiSelect,
- EuiSpacer,
- EuiFlexGroup,
- EuiFlexItem,
- EuiText,
- EuiFieldText,
- EuiCheckboxGroup,
- EuiTextArea,
- EuiLink,
- EuiFieldNumber,
-} from '@elastic/eui';
-import moment, { Moment } from 'moment';
-import { reportDefinitionParams } from '../create/create_report_definition';
-import {
- SCHEDULE_RECURRING_OPTIONS,
- INTERVAL_TIME_PERIODS,
- WEEKLY_CHECKBOX_OPTIONS,
- MONTHLY_ON_THE_OPTIONS,
- TRIGGER_TYPE_OPTIONS,
- SCHEDULE_TYPE_OPTIONS,
- TIMEZONE_OPTIONS,
-} from './report_trigger_constants';
-import { TimezoneSelect } from './timezone';
-
-type ReportTriggerProps = {
- edit: boolean;
- editDefinitionId: string;
- reportDefinitionRequest: reportDefinitionParams;
- httpClientProps: any;
- showTriggerIntervalNaNError: boolean;
- showCronError: boolean;
-};
-
-export function ReportTrigger(props: ReportTriggerProps) {
- const {
- edit,
- editDefinitionId,
- reportDefinitionRequest,
- httpClientProps,
- showTriggerIntervalNaNError,
- showCronError,
- } = props;
-
- const [reportTriggerType, setReportTriggerType] = useState(
- TRIGGER_TYPE_OPTIONS[0].id
- );
-
- const [scheduleType, setScheduleType] = useState(
- SCHEDULE_TYPE_OPTIONS[0].label
- );
- //TODO: should read local timezone and display
- const [scheduleRecurringFrequency, setScheduleRecurringFrequency] = useState(
- 'daily'
- );
- const [recurring, setRecurringTime] = useState(moment());
-
- const [weeklyCheckbox, setWeeklyCheckbox] = useState({
- ['monCheckbox']: true,
- });
- const [monthlySelect, setMonthlySelect] = useState(
- MONTHLY_ON_THE_OPTIONS[0].value
- );
-
- const handleReportTriggerType = (e: string) => {
- setReportTriggerType(e);
- reportDefinitionRequest.trigger.trigger_type = e;
- if (e === 'On demand') {
- delete reportDefinitionRequest.trigger.trigger_params;
- }
- };
-
- const handleScheduleType = (e: React.SetStateAction) => {
- setScheduleType(e);
- if (e === SCHEDULE_TYPE_OPTIONS[1].label) {
- delete reportDefinitionRequest.trigger.trigger_params.schedule.interval;
- } else if (e === SCHEDULE_TYPE_OPTIONS[0].label) {
- delete reportDefinitionRequest.trigger.trigger_params.schedule.cron;
- }
- };
-
- const handleScheduleRecurringFrequency = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setScheduleRecurringFrequency(e.target.value);
- reportDefinitionRequest.trigger.trigger_params.schedule_type =
- e.target.value;
- };
-
- const handleRecurringTime = (e: React.SetStateAction) => {
- setRecurringTime(e);
- };
-
- const handleWeeklyCheckbox = (e) => {
- const newCheckboxIdToSelectedMap = {
- ...weeklyCheckbox,
- ...{
- [e]: !weeklyCheckbox[e],
- },
- };
- setWeeklyCheckbox(newCheckboxIdToSelectedMap);
- };
-
- const handleMonthlySelect = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setMonthlySelect(e.target.value);
- };
-
- const RequestTime = () => {
- useEffect(() => {
- let recurringDaily = {
- interval: {
- period: 1,
- unit: 'DAYS',
- start_time: recurring.valueOf(),
- },
- };
- reportDefinitionRequest.trigger.trigger_params = {
- ...reportDefinitionRequest.trigger.trigger_params,
- enabled_time: recurring.valueOf(),
- schedule: recurringDaily,
- };
- }, []);
-
- return (
-
-
-
-
-
-
- );
- };
-
- const RecurringDaily = () => {
- const [recurringDailyTime, setRecurringDailyTime] = useState(moment());
-
- const handleRecurringDailyTime = (e) => {
- setRecurringDailyTime(e);
- reportDefinitionRequest.trigger.trigger_params.schedule.interval.start_time = e.valueOf();
- };
-
- const setDailyParams = () => {
- let recurringDaily = {
- interval: {
- period: 1,
- unit: 'DAYS',
- start_time: recurringDailyTime.valueOf(),
- },
- };
- reportDefinitionRequest.trigger.trigger_params = {
- ...reportDefinitionRequest.trigger.trigger_params,
- enabled_time: recurringDailyTime.valueOf(),
- schedule: recurringDaily,
- };
- };
-
- const isDailySchedule = (response) => {
- return (
- response.report_definition.trigger.trigger_params.schedule_type ===
- SCHEDULE_TYPE_OPTIONS[0].id &&
- response.report_definition.trigger.trigger_params.schedule.interval
- .period === 1 &&
- response.report_definition.trigger.trigger_params.schedule.interval ===
- 'DAYS'
- );
- };
-
- useEffect(() => {
- let unmounted = false;
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response) => {
- // if switching from on demand to schedule
- if (
- response.report_definition.trigger.trigger_type === 'On demand'
- ) {
- setDailyParams();
- } else if (isDailySchedule(response)) {
- const date = moment(
- response.report_definition.trigger.trigger_params.schedule
- .interval.start_time
- );
- if (!unmounted) {
- setRecurringDailyTime(date);
- }
- }
- // if switching from on-demand to schedule
- else if (
- reportDefinitionRequest.trigger.trigger_params.schedule_type ===
- SCHEDULE_TYPE_OPTIONS[0].id
- ) {
- setDailyParams();
- }
- });
- } else {
- setDailyParams();
- }
- return () => {
- unmounted = true;
- };
- }, []);
-
- return (
-
-
-
-
-
-
- );
- };
-
- const RecurringInterval = () => {
- const [intervalText, setIntervalText] = useState('');
- const [intervalTimePeriod, setIntervalTimePeriod] = useState(
- INTERVAL_TIME_PERIODS[0].value
- );
- const [recurringIntervalTime, setRecurringIntervalTime] = useState(
- moment()
- );
-
- const handleRecurringIntervalTime = (e) => {
- setRecurringIntervalTime(e);
- reportDefinitionRequest.trigger.trigger_params.schedule.interval.start_time = e.valueOf();
- };
-
- const handleIntervalText = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setIntervalText(e.target.value);
- };
-
- const handleIntervalTimePeriod = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setIntervalTimePeriod(e.target.value);
- };
-
- useEffect(() => {
- let interval = {
- interval: {
- period: parseInt(intervalText, 10),
- unit: intervalTimePeriod,
- start_time: recurringIntervalTime.valueOf(),
- },
- };
- reportDefinitionRequest.trigger.trigger_params = {
- ...reportDefinitionRequest.trigger.trigger_params,
- enabled_time: recurringIntervalTime.valueOf(),
- schedule: interval,
- };
- }, [intervalTimePeriod, intervalText]);
-
- // second useEffect() only to be triggered before render when on Edit
- useEffect(() => {
- let unmounted = false;
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response) => {
- if (
- response.report_definition.trigger.trigger_params
- .schedule_type === SCHEDULE_TYPE_OPTIONS[0].id
- ) {
- const date = moment(
- response.report_definition.trigger.trigger_params.schedule
- .interval.start_time
- );
- if (!unmounted) {
- setRecurringIntervalTime(date);
- setIntervalText(
- response.report_definition.trigger.trigger_params.schedule.interval.period.toString()
- );
- setIntervalTimePeriod(
- response.report_definition.trigger.trigger_params.schedule
- .interval.unit
- );
- }
- }
- });
- }
- return () => {
- unmounted = true;
- };
- }, []);
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- };
-
- const RecurringWeekly = () => {
- return (
-
-
-
-
-
-
-
- );
- };
-
- const RecurringMonthly = () => {
- const [monthlyDayNumber, setMonthlyDayNumber] = useState('');
-
- const handleMonthlyDayNumber = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setMonthlyDayNumber(e.target.value);
- };
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- };
-
- const CronExpression = () => {
- const [cronExpression, setCronExpression] = useState('');
-
- const handleCronExpression = (e: {
- target: { value: React.SetStateAction };
- }) => {
- setCronExpression(e.target.value);
- reportDefinitionRequest.trigger.trigger_params.schedule.cron.expression =
- e.target.value;
- };
-
- const setCronParams = () => {
- let cron = {
- cron: {
- expression: '',
- timezone: TIMEZONE_OPTIONS[0].value,
- },
- };
- reportDefinitionRequest.trigger.trigger_params = {
- ...reportDefinitionRequest.trigger.trigger_params,
- enabled_time: Date.now().valueOf(),
- schedule: cron,
- };
- };
-
- useEffect(() => {
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response) => {
- // if switching from on demand to schedule
- if (
- response.report_definition.trigger.trigger_type === 'On demand'
- ) {
- setCronParams();
- } else if (
- response.report_definition.trigger.trigger_params
- .schedule_type === SCHEDULE_TYPE_OPTIONS[1].id
- ) {
- setCronExpression(
- response.report_definition.trigger.trigger_params.schedule.cron
- .expression
- );
- } else {
- setCronParams();
- }
- });
- } else {
- setCronParams();
- }
- }, []);
-
- return (
-
-
-
- Cron help
-
-
- }
- >
-
-
-
-
- );
- };
-
- const ScheduleTriggerRecurring = () => {
- const display_daily =
- scheduleRecurringFrequency === 'daily' ? : null;
-
- const display_interval =
- scheduleRecurringFrequency === 'byInterval' ? (
-
- ) : null;
-
- const display_weekly =
- scheduleRecurringFrequency === 'weekly' ? : null;
-
- const display_monthly =
- scheduleRecurringFrequency === 'monthly' ? : null;
-
- return (
-
-
-
-
-
- {display_daily}
- {display_interval}
- {display_weekly}
- {display_monthly}
-
- );
- };
-
- const ScheduleTrigger = () => {
- const display_recurring =
- scheduleType === SCHEDULE_TYPE_OPTIONS[0].id ? (
-
- ) : null;
-
- const display_cron =
- scheduleType === SCHEDULE_TYPE_OPTIONS[1].id ? (
-
-
-
-
- ) : null;
-
- useEffect(() => {
- // Set default trigger_type
- SCHEDULE_TYPE_OPTIONS.map((item) => {
- if (item.id === scheduleType) {
- reportDefinitionRequest.trigger.trigger_params = {
- ...reportDefinitionRequest.trigger.trigger_params,
- schedule_type: item.id,
- //TODO: need better handle
- };
- if (!edit) {
- reportDefinitionRequest.trigger.trigger_params.enabled = true;
- }
- if (!('enabled' in reportDefinitionRequest.trigger.trigger_params)) {
- reportDefinitionRequest.trigger.trigger_params.enabled = true;
- }
- }
- });
- }, [scheduleType]);
-
- return (
-
-
-
-
-
- {display_recurring}
- {display_cron}
-
- );
- };
-
- const schedule =
- reportTriggerType === 'Schedule' ? : null;
-
- const defaultEditTriggerType = (trigger_type) => {
- let index = 0;
- for (index; index < TRIGGER_TYPE_OPTIONS.length; ++index) {
- if (TRIGGER_TYPE_OPTIONS[index].id === trigger_type) {
- setReportTriggerType(TRIGGER_TYPE_OPTIONS[index].id);
- }
- }
- };
-
- const defaultEditRequestType = (trigger) => {
- let index = 0;
- for (index; index < SCHEDULE_TYPE_OPTIONS.length; ++index) {
- if (
- SCHEDULE_TYPE_OPTIONS[index].id === trigger.trigger_params.schedule_type
- ) {
- setScheduleType(SCHEDULE_TYPE_OPTIONS[index].id);
- }
- }
- };
-
- const defaultEditScheduleFrequency = (trigger_params) => {
- if (trigger_params.schedule_type === SCHEDULE_TYPE_OPTIONS[0].id) {
- if (
- trigger_params.schedule.interval.unit === 'Days' &&
- trigger_params.schedule.interval.period === 1
- ) {
- setScheduleRecurringFrequency('daily');
- } else {
- setScheduleRecurringFrequency('byInterval');
- }
- }
- };
-
- const defaultConfigurationEdit = (trigger) => {
- defaultEditTriggerType(trigger.trigger_type);
- if (trigger.trigger_type === 'Schedule') {
- defaultEditScheduleFrequency(trigger.trigger_params);
- defaultEditRequestType(trigger);
- } else if (trigger.trigger_type == 'On demand') {
- setReportTriggerType('On demand');
- reportDefinitionRequest.trigger.trigger_type = 'On demand';
- }
- };
-
- useEffect(() => {
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response) => {
- defaultConfigurationEdit(response.report_definition.trigger);
- reportDefinitionRequest.trigger = response.report_definition.trigger;
- });
- }
- // Set default trigger_type for create new report definition
- else {
- TRIGGER_TYPE_OPTIONS.map((item) => {
- if (item.id === reportTriggerType) {
- reportDefinitionRequest.trigger.trigger_type = item.id;
- }
- });
- }
- }, []);
-
- return (
-
-
-
-
-
- {schedule}
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger_constants.tsx b/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger_constants.tsx
deleted file mode 100644
index 71905384..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/report_trigger_constants.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import moment from 'moment-timezone';
-import { i18n } from '@osd/i18n';
-
-export const TRIGGER_TYPE_OPTIONS = [
- {
- id: 'On demand',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.triggerTypeOptions.onDemand',
- { defaultMessage: 'On demand' }
- ),
- },
- {
- id: 'Schedule',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.triggerTypeOptions.schedule',
- { defaultMessage: 'Schedule' }
- ),
- },
-];
-
-export const SCHEDULE_TYPE_OPTIONS = [
- {
- id: 'Recurring',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.scheduleTypeOptions.recurring',
- { defaultMessage: 'Recurring' }
- ),
- },
- {
- id: 'Cron based',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.scheduleTypeOptions.cronBased',
- { defaultMessage: 'Cron based' }
- ),
- },
-];
-
-export const SCHEDULE_RECURRING_OPTIONS = [
- {
- value: 'daily',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.scheduleRecurringOptions.daily',
- { defaultMessage: 'Daily' }
- ),
- },
- {
- value: 'byInterval',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.scheduleRecurringOptions.byInterval',
- { defaultMessage: 'By interval' }
- ),
- },
- // TODO: disable on UI. Add them back once we support
- // {
- // value: 'weekly',
- // text: 'Weekly',
- // },
- // {
- // value: 'monthly',
- // text: 'Monthly',
- // },
-];
-
-export const INTERVAL_TIME_PERIODS = [
- {
- value: 'MINUTES',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.intervalTimePeriods.minutes',
- { defaultMessage: 'Minutes' }
- ),
- },
- {
- value: 'HOURS',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.intervalTimePeriods.hours',
- { defaultMessage: 'Hours' }
- ),
- },
- {
- value: 'DAYS',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.intervalTimePeriods.days',
- { defaultMessage: 'Days' }
- ),
- },
-];
-
-export const WEEKLY_CHECKBOX_OPTIONS = [
- {
- id: 'monCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.mon',
- { defaultMessage: 'Mon' }
- ),
- },
- {
- id: 'tueCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.tue',
- { defaultMessage: 'Tue' }
- ),
- },
- {
- id: 'wedCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.wed',
- { defaultMessage: 'Wed' }
- ),
- },
- {
- id: 'thuCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.thu',
- { defaultMessage: 'Thu' }
- ),
- },
- {
- id: 'friCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.fri',
- { defaultMessage: 'Fri' }
- ),
- },
- {
- id: 'satCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.sat',
- { defaultMessage: 'Sat' }
- ),
- },
- {
- id: 'sunCheckbox',
- label: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.weeklyCheckboxOptions.sun',
- { defaultMessage: 'Sun' }
- ),
- },
-];
-
-export const MONTHLY_ON_THE_OPTIONS = [
- {
- value: 'day',
- text: i18n.translate(
- 'opensearch.reports.reportTriggerConstants.monthlyOnTheOptions.day',
- { defaultMessage: 'Day' }
- ),
- },
-];
-
-export const TIMEZONE_OPTIONS = moment.tz
- .names()
- .map((tz) => ({ value: tz, text: tz }));
diff --git a/dashboards-reports/public/components/report_definitions/report_trigger/timezone.tsx b/dashboards-reports/public/components/report_definitions/report_trigger/timezone.tsx
deleted file mode 100644
index aee4ceca..00000000
--- a/dashboards-reports/public/components/report_definitions/report_trigger/timezone.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { EuiFormRow, EuiSelect } from '@elastic/eui';
-import React, { useState, useEffect } from 'react';
-import { i18n } from '@osd/i18n';
-import { TIMEZONE_OPTIONS } from './report_trigger_constants';
-
-export function TimezoneSelect(props: { reportDefinitionRequest: any; httpClientProps: any; edit: any; editDefinitionId: any; }) {
- const {
- reportDefinitionRequest,
- httpClientProps,
- edit,
- editDefinitionId,
- } = props;
- const [timezone, setTimezone] = useState(TIMEZONE_OPTIONS[0].value);
-
- const handleTimezone = (e: { target: { value: React.SetStateAction; }; }) => {
- setTimezone(e.target.value);
- if (
- reportDefinitionRequest.trigger.trigger_params.schedule_type ===
- 'Cron based'
- ) {
- reportDefinitionRequest.trigger.trigger_params.schedule.cron.timezone =
- e.target.value;
- }
- };
-
- useEffect(() => {
- let unmounted = false;
- if (edit) {
- httpClientProps
- .get(`../api/reporting/reportDefinitions/${editDefinitionId}`)
- .then(async (response) => {
- if (
- !unmounted &&
- reportDefinitionRequest.trigger.trigger_params.schedule_type ===
- 'Cron based'
- ) {
- setTimezone(
- response.report_definition.trigger.trigger_params.schedule.cron
- .timezone
- );
- }
- });
- }
- return () => {
- unmounted = true;
- };
- }, []);
-
- return (
-
-
-
-
-
- );
-}
diff --git a/dashboards-reports/public/components/report_definitions/utils/index.ts b/dashboards-reports/public/components/report_definitions/utils/index.ts
deleted file mode 100644
index f5e69b95..00000000
--- a/dashboards-reports/public/components/report_definitions/utils/index.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import Showdown from 'showdown';
-
-export const converter = new Showdown.Converter({
- tables: true,
- simplifiedAutoLink: true,
- strikethrough: true,
- tasklists: true,
- noHeaderId: true,
-});
diff --git a/dashboards-reports/public/components/report_definitions/utils/utils.tsx b/dashboards-reports/public/components/report_definitions/utils/utils.tsx
deleted file mode 100644
index cf10f061..00000000
--- a/dashboards-reports/public/components/report_definitions/utils/utils.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { isValidCron } from 'cron-validator';
-import { i18n } from '@osd/i18n';
-import moment from 'moment';
-import { includeDelivery } from '../delivery/delivery';
-
-export const definitionInputValidation = async (
- metadata,
- error,
- setShowSettingsReportNameError,
- setSettingsReportNameErrorMessage,
- setShowSettingsReportSourceError,
- setSettingsReportSourceErrorMessage,
- setShowTriggerIntervalNaNError,
- timeRange,
- setShowTimeRangeError,
- setShowCronError
-) => {
- // check report name
- // allow a-z, A-Z, 0-9, (), [], ',' - and _ and spaces
- let regexp = /^[\w\-\s\(\)\[\]\,\_\-+]+$/;
- if (metadata.report_params.report_name.search(regexp) === -1) {
- setShowSettingsReportNameError(true);
- if (metadata.report_params.report_name === '') {
- setSettingsReportNameErrorMessage('Name must not be empty.');
- } else {
- setSettingsReportNameErrorMessage('Invalid characters in report name.');
- }
- error = true;
- }
-
- // if recurring by interval and input is not a number
- if (
- metadata.trigger.trigger_type === 'Schedule' &&
- metadata.trigger.trigger_params.schedule_type === 'Recurring'
- ) {
- let interval = parseInt(
- metadata.trigger.trigger_params.schedule.interval.period
- );
- if (isNaN(interval)) {
- setShowTriggerIntervalNaNError(true);
- error = true;
- }
- }
-
- // if report source is blank
- if (metadata.report_params.core_params.base_url === '') {
- setShowSettingsReportSourceError(true);
- setSettingsReportSourceErrorMessage(
- i18n.translate('opensearch.reports.error.reportSourceMustNotBeEmpty', {
- defaultMessage: 'Report source must not be empty.',
- })
- );
- error = true;
- }
-
- // if time range is invalid
- const nowDate = new Date(moment.now());
- if (timeRange.timeFrom > timeRange.timeTo || timeRange.timeTo > nowDate) {
- setShowTimeRangeError(true);
- error = true;
- }
-
- // if cron based and cron input is invalid
- if (
- metadata.trigger.trigger_type === 'Schedule' &&
- metadata.trigger.trigger_params.schedule_type === 'Cron based'
- ) {
- if (
- !isValidCron(metadata.trigger.trigger_params.schedule.cron.expression)
- ) {
- setShowCronError(true);
- error = true;
- }
- }
- return error;
-};
diff --git a/dashboards-reports/public/components/utils/settings_service.ts b/dashboards-reports/public/components/utils/settings_service.ts
deleted file mode 100644
index 4a15e831..00000000
--- a/dashboards-reports/public/components/utils/settings_service.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { HttpStart, IUiSettingsClient } from '../../../../../src/core/public';
-
-let uiSettings: IUiSettingsClient;
-let http: HttpStart;
-
-export const uiSettingsService = {
- init: (uiSettingsClient: IUiSettingsClient, httpClient: HttpStart) => {
- uiSettings = uiSettingsClient;
- http = httpClient;
- },
- get: (key: string, defaultOverride?: any) => {
- return uiSettings?.get(key, defaultOverride) || '';
- },
- getSearchParams: function () {
- const rawTimeZone = this.get('dateFormat:tz');
- const timezone =
- !rawTimeZone || rawTimeZone === 'Browser'
- ? Intl.DateTimeFormat().resolvedOptions().timeZone
- : rawTimeZone;
- const dateFormat = this.get('dateFormat');
- const csvSeparator = this.get('csv:separator');
- const allowLeadingWildcards = this.get('query:allowLeadingWildcards');
- return {
- timezone,
- dateFormat,
- csvSeparator,
- allowLeadingWildcards,
- };
- },
- getHttpClient: () => http,
-};
diff --git a/dashboards-reports/public/components/utils/utils.tsx b/dashboards-reports/public/components/utils/utils.tsx
deleted file mode 100644
index 2638c993..00000000
--- a/dashboards-reports/public/components/utils/utils.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-
-export const permissionsMissingToast = (action: string) => {
- return {
- title: 'Error ' + action,
- color: 'danger',
- iconType: 'alert',
- id: 'permissionsMissingErrorToast' + action.replace(' ', ''),
- text: (
- Insufficient permissions. Reach out to your OpenSearch Dashboards administrator.
- ),
- };
-};
-
-export const permissionsMissingActions = {
- CHANGE_SCHEDULE_STATUS: 'changing schedule status.',
- DELETE_REPORT_DEFINITION: 'deleting report definition.',
- GENERATING_REPORT: 'generating report.',
- LOADING_REPORTS_TABLE: 'loading reports table.',
- LOADING_DEFINITIONS_TABLE: 'loading report definitions table.',
- VIEWING_EDIT_PAGE: 'viewing edit page.',
- UPDATING_DEFINITION: 'updating report definition',
- CREATING_REPORT_DEFINITION: 'creating new report definition.',
-};
-
-export const timeRangeMatcher = /time:\(from:(.+?),to:(.+?)\)/;
diff --git a/dashboards-reports/public/components/visual_report/assets/report_styles.ts b/dashboards-reports/public/components/visual_report/assets/report_styles.ts
deleted file mode 100644
index a78ee8a8..00000000
--- a/dashboards-reports/public/components/visual_report/assets/report_styles.ts
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-export const reportingStyle = `
-html,
-body {
- margin: 0;
- padding: 0;
-}
-
-iframe, embed, object {
- display: none !important;
-}
-
-/* nice padding + matches Kibana default UI colors you could also set this to inherit if
- the wrapper gets inserted inside a kibana section. I might also remove the manual text color here as well, potentially */
-.reportWrapper {
- padding: 8px;
- background-color: #fafbfd;
-}
-
-/* Notice that I'm using an ID of #reportingHeader, and #reportingFooter, instead of a classname (.reportingHeader, .reportingFooter). This is
- in order to force specificity here higher in case any other styles would conflict */
-#reportingHeader,
-#reportingFooter {
- font-family: 'Inter UI', -apple-system, BlinkMacSystemFont, 'Segoe UI',
- Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
- 'Segoe UI Symbol';
- background-color: #fff;
- border: 1px solid #d3dae6;
- box-shadow: 0 2px 2px -1px rgba(152, 162, 179, 0.3),
- 0 1px 5px -2px rgba(152, 162, 179, 0.3);
- border-radius: 4px;
- padding: 1em;
- margin-bottom: 1em;
-}
-
-#reportingFooter {
- margin-top: 1em;
-}
-
-#reportingHeader p,
-#reportingFooter p {
- max-width: 960px;
-}
-
-/* Adjust the margin when the header is the first item */
-#reportingHeader h1:first-child,
-#reportingFooter h1:first-child,
-#reportingHeader h2:first-child,
-#reportingFooter h2:first-child,
-#reportingHeader h3:first-child,
-#reportingFooter h3:first-child,
-#reportingHeader h4:first-child,
-#reportingFooter h4:first-child,
-#reportingHeader h5:first-child,
-#reportingFooter h5:first-child,
-#reportingHeader h6:first-child,
-#reportingFooter h6:first-child {
- margin-top: 0.25em;
-}
-
-/* nicer list styles */
-#reportingHeader ul,
-#reportingFooter ul,
-#reportingHeader ol,
-#reportingFooter ol {
- max-width: 70rem;
- margin-bottom: 1em;
-}
-
-#reportingHeader ul li,
-#reportingFooter ul li,
-#reportingHeader ol li,
-#reportingFooter ol li {
- margin-bottom: 0.25em;
- margin-left: -0.5em;
- padding-left: 0.25em;
-}
-
-#reportingHeader ul,
-#reportingFooter ul {
- list-style-type: disc;
-}
-
-/* here we explicitly set nested paragraphs inside lists to inherit their styles from the list, in case markdown does funky things */
-#reportingHeader ul p,
-#reportingFooter ul p,
-#reportingHeader ol p,
-#reportingFooter ol p {
- font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
- /* We only inherit vertical spacing, not horizontal */
- margin-top: inherit;
- margin-bottom: inherit;
-}
-
- [eCommerce] Revenue Dashboard - OpenSearch
-
-
- Sample eCommerce Data
-
This dashboard contains sample data for you to play with. You can view it, search it, and interact with the visualizations. For more information about OpenSearch Dashboards, check our docs .
-
Apply changes
Cancel changes
Clear form
FEMALE (52.89%) MALE (47.11%)
$74.62 average spend per order average spend
2.124 average items per order average items
Sum of total_quantity 0 20 40 60 80 100
2021-06-17 12:00 2021-06-18 12:00 2021-06-19 12:00 2021-06-20 12:00 2021-06-21 12:00 2021-06-22 12:00 2021-06-23 12:00 order_date per 3 hours
Revenue Trousers
Revenue Watches
Revenue Bags
Revenue Cocktail Dresses
Lace-up boots - black Ankle boots - black Boots - black Print T-shirt - black Jumper - black Lace-up boots - resin coffee Dress with Defined Waist
products.product_name.keyword: Descending - Count
-
-
-
-
-
-
-
-
-
-
-
- Jun 23, 2021 @ 23:56:10.000 Women's Accessories, Women's Clothing
ZO0301903019, ZO0049800498
$43.98
2
-
-
-
-
- Jun 23, 2021 @ 23:41:46.000 Men's Clothing
ZO0128701287, ZO0577005770
$49.98
2
-
-
-
-
- Jun 23, 2021 @ 23:37:26.000 Men's Clothing
ZO0558005580, ZO0276502765
$18.98
2
-
-
-
-
- Jun 23, 2021 @ 23:33:07.000 Women's Accessories, Women's Clothing
ZO0358803588, ZO0179601796
$91.98
2
-
-
-
-
- Jun 23, 2021 @ 23:21:36.000 Men's Clothing
ZO0543605436, ZO0425604256
$89.98
2
-
-
-
-
- Jun 23, 2021 @ 23:21:36.000 Men's Clothing
ZO0629306293, ZO0578405784
$37.98
2
-
-
-
-
- Jun 23, 2021 @ 22:51:22.000 Men's Clothing
ZO0291602916, ZO0292302923
$221.98
2
-
-
-
-
- Jun 23, 2021 @ 22:48:29.000 Women's Clothing, Women's Accessories
ZO0262902629, ZO0358703587
$83.98
2
-
-
-
-
- Jun 23, 2021 @ 22:29:46.000 Men's Clothing
ZO0474604746, ZO0111701117
$36.98
2
-
-
-
-
- Jun 23, 2021 @ 22:12:29.000 Men's Accessories, Men's Shoes
ZO0598005980, ZO0681706817
$75.98
2
-
-
-
-
- Jun 23, 2021 @ 22:11:02.000 Women's Clothing, Women's Shoes
ZO0221402214, ZO0677006770
$103.98
2
-
-
-
-
- Jun 23, 2021 @ 21:59:31.000 Men's Clothing, Men's Shoes
ZO0579905799, ZO0386403864
$55.98
2
-
-
-
-
- Jun 23, 2021 @ 21:55:12.000 Men's Clothing
ZO0474204742, ZO0574005740
$31.98
2
-
-
-
-
- Jun 23, 2021 @ 21:48:00.000 Men's Clothing, Men's Shoes
ZO0580905809, ZO0507105071
$41.98
2
-
-
-
-
- Jun 23, 2021 @ 21:23:31.000 Women's Clothing
ZO0217002170, ZO0164201642
$27.98
2
-
-
-
-
- Jun 23, 2021 @ 21:17:46.000 Women's Shoes, Women's Clothing
ZO0368003680, ZO0173001730
$63.98
2
-
-
-
-
- Jun 23, 2021 @ 21:12:00.000 Men's Clothing
ZO0437404374, ZO0293102931
$24.98
2
-
-
-
-
- Jun 23, 2021 @ 21:09:07.000 Women's Accessories, Women's Shoes
ZO0085300853, ZO0678506785
$95.98
2
-
-
-
-
- Jun 23, 2021 @ 20:56:10.000 Women's Clothing, Women's Shoes
ZO0638706387, ZO0677206772
$92.98
2
-
-
-
-
- Jun 23, 2021 @ 20:41:46.000 Women's Shoes, Women's Clothing
ZO0678406784, ZO0712707127
$99.98
2
-
-
-
-
- Jun 23, 2021 @ 20:37:26.000 Women's Clothing
ZO0708107081, ZO0500905009
$42.98
2
-
-
-
-
- Jun 23, 2021 @ 20:33:07.000 Women's Shoes
ZO0250002500, ZO0675406754
$159.98
2
-
-
-
-
- Jun 23, 2021 @ 20:24:29.000 Women's Accessories
ZO0205602056, ZO0356903569
$46.98
2
-
-
-
-
- Jun 23, 2021 @ 20:00:00.000 Men's Clothing
ZO0441304413, ZO0561205612
$22.98
2
-
-
-
-
- Jun 23, 2021 @ 19:55:41.000 Men's Shoes, Men's Clothing
ZO0691306913, ZO0275502755
$139.98
2
-
-
-
-
- Jun 23, 2021 @ 19:32:38.000 Men's Clothing
ZO0295102951, ZO0453304533, ZO0588305883, ZO0411304113
$82.96
4
-
-
-
-
- Jun 23, 2021 @ 19:19:41.000 Men's Clothing, Men's Accessories
ZO0296402964, ZO0316203162
$42.98
2
-
-
-
-
- Jun 23, 2021 @ 19:18:14.000 Men's Clothing, Men's Shoes
ZO0588005880, ZO0571805718, ZO0403504035, ZO0457504575
$108.96
4
-
-
-
-
- Jun 23, 2021 @ 19:15:22.000 Women's Clothing
ZO0051800518, ZO0333303333
$92.98
2
-
-
-
-
- Jun 23, 2021 @ 19:06:43.000 Men's Clothing, Men's Shoes
ZO0431904319, ZO0683606836
$149.98
2
-
-
-
-
- Jun 23, 2021 @ 19:05:17.000 Women's Clothing, Women's Accessories
ZO0181701817, ZO0095300953
$45.98
2
-
-
-
-
- Jun 23, 2021 @ 18:58:05.000 Men's Clothing
ZO0620606206, ZO0454204542
$70.98
2
-
-
-
-
- Jun 23, 2021 @ 18:40:48.000 Women's Shoes, Women's Accessories
ZO0670906709, ZO0211302113
$128.98
2
-
-
-
-
- Jun 23, 2021 @ 18:30:43.000 Women's Clothing
ZO0263002630, ZO0497904979
$93.98
2
-
-
-
-
- Jun 23, 2021 @ 18:27:50.000 Men's Clothing, Men's Shoes
ZO0300603006, ZO0123501235, ZO0399803998, ZO0624206242
$160.96
4
-
-
-
-
- Jun 23, 2021 @ 18:13:26.000 Women's Accessories, Women's Shoes
ZO0696806968, ZO0020700207
$66.98
2
-
-
-
-
- Jun 23, 2021 @ 18:03:22.000 Women's Clothing, Women's Accessories
ZO0271302713, ZO0703207032
$74.98
2
-
-
-
-
- Jun 23, 2021 @ 18:00:29.000 Men's Shoes, Men's Accessories
ZO0403504035, ZO0608606086
$91.98
2
-
-
-
-
- Jun 23, 2021 @ 17:46:05.000 Men's Shoes, Men's Clothing
ZO0521405214, ZO0585905859
$64.98
2
-
-
-
-
- Jun 23, 2021 @ 17:31:41.000 Women's Clothing
ZO0171101711, ZO0048400484
$74.98
2
-
-
-
-
- Jun 23, 2021 @ 17:28:48.000 Women's Accessories
ZO0209302093, ZO0087400874
$47.98
2
-
-
-
-
- Jun 23, 2021 @ 17:27:22.000 Women's Accessories
ZO0096100961, ZO0091000910
$53.98
2
-
-
-
-
- Jun 23, 2021 @ 17:04:19.000 Men's Clothing
ZO0284802848, ZO0581605816
$49.98
2
-
-
-
-
- Jun 23, 2021 @ 17:02:53.000 Men's Shoes
ZO0401004010, ZO0257802578
$119.98
2
-
-
-
-
- Jun 23, 2021 @ 16:51:22.000 Men's Shoes, Men's Accessories
ZO0520705207, ZO0397603976, ZO0395003950, ZO0702307023
$207.96
4
-
-
-
-
- Jun 23, 2021 @ 16:49:55.000 Women's Shoes, Women's Clothing
ZO0364403644, ZO0150401504
$116.98
2
-
-
-
-
- Jun 23, 2021 @ 16:31:12.000 Men's Clothing, Women's Accessories
ZO0554505545, ZO0703407034
$96.98
2
-
-
-
-
- Jun 23, 2021 @ 16:25:26.000 Women's Clothing
ZO0263002630
$51.99
1
-
-
-
-
- Jun 23, 2021 @ 16:02:24.000 Women's Shoes
ZO0365203652, ZO0383303833
$126.98
2
-
-
-
-
- Jun 23, 2021 @ 16:00:58.000 Women's Clothing
ZO0179701797, ZO0496004960
$42.98
2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-