Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI for Notifications Integration #126

Merged
merged 16 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions dashboards-reports/.cypress/integration/02-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ describe('Cypress', () => {
cy.get('#reportSettingsDescription').type(' update description');

cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});

it('Visit edit page, change report source and trigger', () => {
it('Visit edit page, change report trigger', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
Expand All @@ -71,13 +76,18 @@ describe('Cypress', () => {
cy.url().should('include', 'edit');

cy.wait(1000);
cy.get('#visualizationReportSource').check({ force: true });
cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ force: true });

cy.get('#Schedule').check({ force: true });
cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});

it('Visit edit page, change report source back', () => {
it('Visit edit page, change report trigger back', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
Expand All @@ -96,8 +106,13 @@ describe('Cypress', () => {

cy.wait(1000);

cy.get('#dashboardReportSource').check({ force: true });
cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ force: true });

cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});
});
29 changes: 23 additions & 6 deletions dashboards-reports/public/components/main/main_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,31 @@
import 'babel-polyfill';
import { i18n } from '@osd/i18n';
import { HttpFetchOptions, HttpSetup } from '../../../../../src/core/public';
import { placeholderChannels } from '../report_definitions/delivery/delivery_constants';

export const fileFormatsUpper = {
export const displayDeliveryChannels = (configIds: Array<string>) => {
let displayChannels = [];
for (let i = 0; i < configIds.length; ++i) {
for (let j = 0; j < placeholderChannels.length; ++j) {
if (configIds[i] === placeholderChannels[j].id) {
displayChannels.push(placeholderChannels[i].label);
}
}
}
return displayChannels.toString();
}

type fileFormatsOptions = {
[key: string]: string
}

export const fileFormatsUpper: fileFormatsOptions = {
csv: 'CSV',
pdf: 'PDF',
png: 'PNG',
};

export const humanReadableDate = (date) => {
export const humanReadableDate = (date: string | number | Date) => {
let readableDate = new Date(date);
return (
readableDate.toDateString() + ' @ ' + readableDate.toLocaleTimeString()
Expand All @@ -55,7 +72,7 @@ export const getFileFormatPrefix = (fileFormat: string) => {
return fileFormatPrefix;
};

export const addReportsTableContent = (data) => {
export const addReportsTableContent = (data: string | any[]) => {
let reportsTableItems = [];
for (let index = 0; index < data.length; ++index) {
let item = data[index];
Expand Down Expand Up @@ -110,7 +127,7 @@ export const addReportDefinitionsTableContent = (data: any) => {
return reportDefinitionsTableItems;
};

export const removeDuplicatePdfFileFormat = (filename) => {
export const removeDuplicatePdfFileFormat = (filename: string) => {
return filename.substring(0, filename.length - 4);
};

Expand Down Expand Up @@ -153,7 +170,7 @@ export const readStreamToFile = async (
};

export const generateReportFromDefinitionId = async (
reportDefinitionId,
reportDefinitionId: string,
httpClient: HttpSetup
) => {
let status = false;
Expand Down Expand Up @@ -188,7 +205,7 @@ export const generateReportFromDefinitionId = async (
};

export const generateReportById = async (
reportId,
reportId: string,
httpClient: HttpSetup,
handleSuccessToast,
handleErrorToast,
Expand Down
Loading