Skip to content

Commit

Permalink
fix removed types being shown in the management list
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Mar 22, 2024
1 parent e922cd3 commit c7ff960
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
9 changes: 5 additions & 4 deletions packages/kbn-reporting/server/check_license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { ILicense } from '@kbn/licensing-plugin/server';
import type { ExportType } from '.';
import { REMOVED_JOB_TYPES } from './constants';
import { ExportTypesRegistry } from './export_types_registry';

export interface LicenseCheckResult {
Expand Down Expand Up @@ -46,14 +47,14 @@ const makeManagementFeature = (exportTypes: ExportType[]) => {
};
}

const validJobTypes = exportTypes
const currentJobTypes = exportTypes
.filter((exportType) => exportType.validLicenses.includes(license.type!))
.map((exportType) => exportType.jobType);

return {
showLinks: validJobTypes.length > 0,
enableLinks: validJobTypes.length > 0,
jobTypes: validJobTypes,
showLinks: currentJobTypes.length > 0,
enableLinks: currentJobTypes.length > 0,
jobTypes: [...currentJobTypes, ...REMOVED_JOB_TYPES],
};
},
};
Expand Down
8 changes: 8 additions & 0 deletions packages/kbn-reporting/server/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ export const REPORTING_TRANSACTION_TYPE = PLUGIN_ID;
// automation that have no version value in the job params, we assume the
// intended version is 7.14.0
export const UNVERSIONED_VERSION = '7.14.0';

// Job types that have been deprecated and then removed from the export type registry.
// Support only exists for download
export const REMOVED_JOB_TYPES = [
'csv', // replaced with 'csv_searchsource'
'PNG', // replaced with 'PNGV2'
'printable_pdf', // replaced with 'printable_pdf_v2'
];
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { PDF_JOB_TYPE_V2, PDF_REPORT_TYPE_V2 } from '@kbn/reporting-export-types
import { PNG_JOB_TYPE_V2, PNG_REPORT_TYPE_V2 } from '@kbn/reporting-export-types-png-common';

// Export Type Sets
export const reportTypes = [
export const ALL_REPORT_TYPES = [
CSV_REPORT_TYPE,
CSV_REPORT_TYPE_V2,
PDF_REPORT_TYPE_V2,
PNG_REPORT_TYPE_V2,
];

export const jobTypes = [CSV_JOB_TYPE, CSV_JOB_TYPE_V2, PDF_JOB_TYPE_V2, PNG_JOB_TYPE_V2];
export const ALL_JOB_TYPES = [CSV_JOB_TYPE, CSV_JOB_TYPE_V2, PDF_JOB_TYPE_V2, PNG_JOB_TYPE_V2];

export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE_V2, PNG_JOB_TYPE_V2];
6 changes: 3 additions & 3 deletions x-pack/plugins/reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

import { jobTypes, reportTypes } from './constants';
import { ALL_JOB_TYPES, ALL_REPORT_TYPES } from './constants';

type ReportTypeDeclaration = typeof reportTypes;
type ReportTypeDeclaration = typeof ALL_REPORT_TYPES;
export type ReportTypes = ReportTypeDeclaration[keyof ReportTypeDeclaration];

type JobTypeDeclaration = typeof jobTypes;
type JobTypeDeclaration = typeof ALL_JOB_TYPES;
export type JobTypes = JobTypeDeclaration[keyof JobTypeDeclaration];
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/public/lib/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/

import { jobTypes } from '../../common/constants';
import { ALL_JOB_TYPES } from '../../common/constants';
import { mockJobs } from '../../common/test';
import { Job } from '@kbn/reporting-public/job';

describe('Job', () => {
it('should provide a pretty name for all known job types', () => {
for (const jobType of Object.values(jobTypes)) {
for (const jobType of Object.values(ALL_JOB_TYPES)) {
const job = new Job({ ...mockJobs[0], jobtype: jobType });
expect(job.prettyJobTypeName).toEqual(expect.any(String));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const list = await pageObjects.reporting.getManagementList();
expectSnapshot(list).toMatchInline(`
Array [
Object {
"actions": "",
"createdAt": "2021-07-19 @ 10:29 PM",
"report": "Automated report",
"status": "Done, warnings detected",
},
Object {
"actions": "",
"createdAt": "2021-07-19 @ 06:47 PM",
Expand Down Expand Up @@ -128,7 +134,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
"actions": "",
"createdAt": "2021-07-19 @ 06:38 PM",
"report": "[Flights] Global Flight Dashboard",
"status": "Done",
"status": "Done, warnings detected",
},
Object {
"actions": "",
Expand All @@ -138,14 +144,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
},
Object {
"actions": "",
"createdAt": "2021-07-19 @ 02:41 PM",
"createdAt": "2021-07-19 @ 06:38 PM",
"report": "[Flights] Global Flight Dashboard",
"status": "Failed",
},
Object {
"actions": "",
"createdAt": "2020-04-21 @ 07:01 PM",
"report": "[Logs] File Type Scatter Plot",
"status": "Done",
},
]
Expand Down

0 comments on commit c7ff960

Please sign in to comment.