diff --git a/dashboards-reports/public/components/main/main_utils.tsx b/dashboards-reports/public/components/main/main_utils.tsx index 8ab80da3..c32a8791 100644 --- a/dashboards-reports/public/components/main/main_utils.tsx +++ b/dashboards-reports/public/components/main/main_utils.tsx @@ -29,19 +29,6 @@ import { i18n } from '@osd/i18n'; import { HttpFetchOptions, HttpSetup } from '../../../../../src/core/public'; import { uiSettingsService } from '../utils/settings_service'; -export const displayDeliveryChannels = (configIds: Array, channels: Array<{label: string, id: string}>) => { - let displayChannels = []; - for (let i = 0; i < configIds.length; ++i) { - for (let j = 0; j < channels.length; ++j) { - if (configIds[i] === channels[j].id) { - displayChannels.push(channels[j].label); - break; - } - } - } - return displayChannels.toString(); -} - export const getAvailableNotificationsChannels = (configList: any) => { let availableChannels = []; for (let i = 0; i < configList.length; ++i) { 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 index ec53a581..f5cbdec9 100644 --- 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 @@ -382,85 +382,6 @@ exports[` panel render 5 hours recurring definition d -
-

- Notification settings -

-
-
-
-
-
- Config IDs -
-
-
-
-
-
-
- Title -
-
-
-
-
-
-
- Text description -
-
-
-
-
-
-
- Html description -
-
-
-
-
panel render disabled daily definition, cli
-
-

- Notification settings -

-
-
-
-
-
- Config IDs -
-
-
-
-
-
-
- Title -
-
-
-
-
-
-
- Text description -
-
-
-
-
-
-
- Html description -
-
-
-
-
panel render on demand definition details 1
-
-

- Notification settings -

-
-
-
-
-
- Config IDs -
-
-
-
-
-
-
- Title -
-
-
-
-
-
-
- Text description -
-
-
-
-
-
-
- Html description -
-
-
-
-
| string; - title: string; - textDescription: string; - htmlDescription: string; baseUrl: string; } @@ -101,10 +94,6 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a reportFooter: '', triggerType: '', scheduleDetails: '', - configIds: [], - title: '', - textDescription: '', - htmlDescription: '', baseUrl: '' }); const [ @@ -114,7 +103,6 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a const [toasts, setToasts] = useState([]); const [showDeleteModal, setShowDeleteModal] = useState(false); const [showLoading, setShowLoading] = useState(false); - const [channels, setChannels] = useState>([]); const reportDefinitionId = props.match['params']['reportDefinitionId']; const handleLoading = (e: boolean | ((prevState: boolean) => boolean)) => { @@ -413,8 +401,7 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a }; const getReportDefinitionDetailsMetadata = ( - data: ReportDefinitionSchemaType, - availableChannels: Array<{ label: string; id: string; }> + data: ReportDefinitionSchemaType ) : ReportDefinitionDetails => { const reportDefinition: ReportDefinitionSchemaType = data; const { @@ -428,12 +415,6 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a trigger_type: triggerType, trigger_params: triggerParams, } = trigger; - const { - configIds: configIds, - title: title, - textDescription: textDescription, - htmlDescription: htmlDescription - } = delivery; const { core_params: { base_url: baseUrl, @@ -478,10 +459,6 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a ? humanReadableScheduleDetails(data.trigger) : `\u2014`, status: reportDefinition.status, - configIds: (configIds.length > 0) ? displayDeliveryChannels(configIds, availableChannels) : `\u2014`, - title: (title !== '') ? title : `\u2014`, - textDescription: (textDescription !== '') ? textDescription : `\u2014`, - htmlDescription: (htmlDescription !== '') ? htmlDescription : `\u2014` }; return reportDefinitionDetails; }; @@ -489,58 +466,44 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a useEffect(() => { const { httpClient } = props; httpClient - .get('../api/reporting_notifications/get_configs', { - query: getChannelsQueryObject - }) - .then(async (response: any) => { - let availableChannels = getAvailableNotificationsChannels(response.config_list); - setChannels(availableChannels); - return availableChannels; - }) - .catch((error: any) => { - console.log('error when retrieving notification configs:', error); - }) - .then((availableChannels: any) => { - httpClient - .get(`../api/reporting/reportDefinitions/${reportDefinitionId}`) - .then((response: {report_definition: ReportDefinitionSchemaType}) => { - handleReportDefinitionRawResponse(response); - handleReportDefinitionDetails(getReportDefinitionDetailsMetadata(response.report_definition, availableChannels)); - 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', + .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: - 'error when getting report definition details: {error}', - values: { error: error }, + defaultMessage: 'Report definition details: {name}', + values: { + name: response.report_definition.report_params.report_name, + }, } - ) - ); - handleDetailsErrorToast(); - }); + ), + }, + ]); }) + .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 () => { @@ -591,7 +554,7 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a updatedRawResponse.report_definition = updatedReportDefinition; handleReportDefinitionRawResponse(updatedRawResponse); setReportDefinitionDetails( - getReportDefinitionDetailsMetadata(updatedReportDefinition, channels) + getReportDefinitionDetailsMetadata(updatedReportDefinition) ); if (statusChange === 'Enable') { handleSuccessChangingScheduleStatusToast('enable'); @@ -879,37 +842,6 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a {triggerSection} - - -

Notification settings

-
- - - - - - - panel render 5 hours recurring component 1`] = `
-
-

- Notification settings -

-
-
-
-
-
- Config IDs -
-
- — -
-
-
-
-
-
- Title -
-
- — -
-
-
-
-
-
- Text description -
-
- — -
-
-
-
-
-
- Html description -
-
-

- — -

-
-
-
-
panel render on-demand component 1`] = `
-
-

- Notification settings -

-
-
-
-
-
- Config IDs -
-
- — -
-
-
-
-
-
- Title -
-
- — -
-
-
-
-
-
- Text description -
-
- — -
-
-
-
-
-
- Html description -
-
-

- — -

-
-
-
-
| string; - title: string; - textDescription: string; - htmlDescription: string; queryUrl: string; } @@ -122,10 +117,6 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl triggerType: '', scheduleType: '', scheduleDetails: '', - configIds: [], - title: '', - textDescription: '', - htmlDescription: '', queryUrl: '' }); const [toasts, setToasts] = useState([]); @@ -229,26 +220,19 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl }; const getReportDetailsData = ( - report: ReportSchemaType, - availableChannels: Array<{ label: string; id: string; }> - ) : ReportDetails => { + report: ReportSchemaType + ) : ReportDetails => { const { report_definition: reportDefinition, last_updated: lastUpdated, state, query_url: queryUrl, } = report; - const { report_params: reportParams, trigger, delivery } = reportDefinition; + const { report_params: reportParams, trigger } = reportDefinition; const { trigger_type: triggerType, trigger_params: triggerParams, } = trigger; - const { - configIds: configIds, - title: title, - textDescription: textDescription, - htmlDescription: htmlDescription - } = delivery; const coreParams = reportParams.core_params; // covert timestamp to local date-time string let reportDetails = { @@ -276,10 +260,6 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl triggerType: triggerType, scheduleType: triggerParams ? triggerParams.schedule_type : `\u2014`, scheduleDetails: `\u2014`, - configIds: (configIds.length > 0) ? displayDeliveryChannels(configIds, availableChannels) : `\u2014`, - title: (title !== '') ? title : `\u2014`, - textDescription: (textDescription !== '') ? textDescription : `\u2014`, - htmlDescription: (htmlDescription !== '') ? htmlDescription : `\u2014`, queryUrl: queryUrl, }; return reportDetails; @@ -288,47 +268,34 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl useEffect(() => { const { httpClient } = props; httpClient - .get('../api/reporting_notifications/get_configs', { - query: getChannelsQueryObject - }) - .then(async (response: any) => { - let availableChannels = getAvailableNotificationsChannels(response.config_list); - return availableChannels; + .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 retrieving notification configs:', error); - }) - .then((availableChannels: any) => { - httpClient - .get('../api/reporting/reports/' + reportId) - .then((response: ReportSchemaType) => { - handleReportDetails(getReportDetailsData(response, availableChannels)); - 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(); - }); - }) + console.log('Error when fetching report details: ', error); + handleErrorToast(); + }); }, []); const downloadIconDownload = async () => { @@ -529,33 +496,6 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl {triggerSection} - - -

Notification settings

-
- - - - - - -