44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7+ import { schema } from '@kbn/config-schema' ;
8+ import { i18n } from '@kbn/i18n' ;
79import { CoreSetup , CoreStart , Plugin , PluginInitializerContext } from 'src/core/server' ;
10+ import { PLUGIN_ID , UI_SETTINGS_CUSTOM_PDF_LOGO } from '../common/constants' ;
811import { ReportingCore } from './' ;
912import { initializeBrowserDriverFactory } from './browsers' ;
1013import { buildConfig , ReportingConfigType } from './config' ;
@@ -20,6 +23,8 @@ import { setFieldFormats } from './services';
2023import { ReportingSetup , ReportingSetupDeps , ReportingStart , ReportingStartDeps } from './types' ;
2124import { registerReportingUsageCollector } from './usage' ;
2225
26+ const kbToBase64Length = ( kb : number ) => Math . floor ( ( kb * 1024 * 8 ) / 6 ) ;
27+
2328declare module 'src/core/server' {
2429 interface RequestHandlerContext {
2530 reporting ?: ReportingStart | null ;
@@ -40,14 +45,36 @@ export class ReportingPlugin
4045
4146 public setup ( core : CoreSetup , plugins : ReportingSetupDeps ) {
4247 // prevent throwing errors in route handlers about async deps not being initialized
43- core . http . registerRouteHandlerContext ( 'reporting' , ( ) => {
48+ core . http . registerRouteHandlerContext ( PLUGIN_ID , ( ) => {
4449 if ( this . reportingCore . pluginIsStarted ( ) ) {
4550 return { } ; // ReportingStart contract
4651 } else {
4752 return null ;
4853 }
4954 } ) ;
5055
56+ core . uiSettings . register ( {
57+ [ UI_SETTINGS_CUSTOM_PDF_LOGO ] : {
58+ name : i18n . translate ( 'xpack.reporting.pdfFooterImageLabel' , {
59+ defaultMessage : 'PDF footer image' ,
60+ } ) ,
61+ value : null ,
62+ description : i18n . translate ( 'xpack.reporting.pdfFooterImageDescription' , {
63+ defaultMessage : `Custom image to use in the PDF's footer` ,
64+ } ) ,
65+ type : 'image' ,
66+ schema : schema . nullable ( schema . byteSize ( { max : '200kb' } ) ) ,
67+ category : [ PLUGIN_ID ] ,
68+ // Used client-side for size validation
69+ validation : {
70+ maxSize : {
71+ length : kbToBase64Length ( 200 ) ,
72+ description : '200 kB' ,
73+ } ,
74+ } ,
75+ } ,
76+ } ) ;
77+
5178 const { elasticsearch, http } = core ;
5279 const { licensing, security } = plugins ;
5380 const { initializerContext : initContext , reportingCore } = this ;
0 commit comments