From 64f648b4854b40cb59a7e8be0dc95194bee46d7f Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Thu, 3 Nov 2022 17:53:40 +0100 Subject: [PATCH 1/2] Increase PDF header footer textarea max row length --- CHANGELOG.md | 2 +- common/constants.ts | 4 ++-- common/plugin-settings.test.ts | 4 ++-- server/lib/reporting/printer.ts | 6 ++++-- server/routes/wazuh-utils/wazuh-utils.test.ts | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ba106bbc..4c2b01616a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Redesign the SCA table from agent's dashboard [#4512](https://github.com/wazuh/wazuh-kibana-app/pull/4512) - Enhanced the plugin setting description displayed in the UI and the configuration file. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501) - Added validation to the plugin settings in the form of `Settings/Configuration` and the endpoint to update the plugin configuration [#4503](https://github.com/wazuh/wazuh-kibana-app/pull/4503)[#4785](https://github.com/wazuh/wazuh-kibana-app/pull/4785) -- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505) +- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505)[#4798](https://github.com/wazuh/wazuh-kibana-app/pull/4798) - Add a new plugin setting to enable or disable the customization [#4507](https://github.com/wazuh/wazuh-kibana-app/pull/4507) ### Changed diff --git a/common/constants.ts b/common/constants.ts index f8c2ea46e8..296a102cbd 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -1117,7 +1117,7 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = { defaultValueIfNotSet: REPORTS_PAGE_FOOTER_TEXT, isConfigurableFromFile: true, isConfigurableFromUI: true, - options: { maxRows: 2, maxLength: 30 }, + options: { maxRows: 2, maxLength: 50 }, validate: function (value) { return SettingsValidator.multipleLinesString({ maxRows: this.options?.maxRows, @@ -1137,7 +1137,7 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = { defaultValueIfNotSet: REPORTS_PAGE_HEADER_TEXT, isConfigurableFromFile: true, isConfigurableFromUI: true, - options: { maxRows: 3, maxLength: 20 }, + options: { maxRows: 3, maxLength: 40 }, validate: function (value) { return SettingsValidator.multipleLinesString({ maxRows: this.options?.maxRows, diff --git a/common/plugin-settings.test.ts b/common/plugin-settings.test.ts index 62afbe5444..2e06257c87 100644 --- a/common/plugin-settings.test.ts +++ b/common/plugin-settings.test.ts @@ -122,12 +122,12 @@ describe('[settings] Input validation', () => { ${'customization.reports.footer'} | ${'Test\nTest'} | ${undefined} ${'customization.reports.footer'} | ${'Test\nTest\nTest\nTest\nTest'} | ${'The string should have less or equal to 2 line/s.'} ${'customization.reports.footer'} | ${'Line with 30 characters \nTest'} | ${undefined} - ${'customization.reports.footer'} | ${'Line with 31 characters \nTest'} | ${"The maximum length of a line is 30 characters."} + ${'customization.reports.footer'} | ${'Testing maximum length of a line of more than 50 characters\nTest'} | ${"The maximum length of a line is 50 characters."} ${'customization.reports.header'} | ${'Test'} | ${undefined} ${'customization.reports.header'} | ${'Test\nTest'} | ${undefined} ${'customization.reports.header'} | ${'Test\nTest\nTest\nTest\nTest'} | ${'The string should have less or equal to 3 line/s.'} ${'customization.reports.header'} | ${'Line with 20 charact\nTest'} | ${undefined} - ${'customization.reports.header'} | ${'Line with 23 characters\nTest'} | ${"The maximum length of a line is 20 characters."} + ${'customization.reports.header'} | ${'Testing maximum length of a line of 40 characters\nTest'} | ${"The maximum length of a line is 40 characters."} ${'disabled_roles'} | ${['test']} | ${undefined} ${'disabled_roles'} | ${['']} | ${'Value can not be empty.'} ${'disabled_roles'} | ${['test space']} | ${"No whitespaces allowed."} diff --git a/server/lib/reporting/printer.ts b/server/lib/reporting/printer.ts index 12784aeef5..f31f2ea374 100644 --- a/server/lib/reporting/printer.ts +++ b/server/lib/reporting/printer.ts @@ -62,7 +62,8 @@ const pageConfiguration = ({ pathToLogo, pageHeader, pageFooter }) => ({ text: pageHeader, alignment: 'right', margin: [0, 0, 40, 0], - color: COLORS.PRIMARY + color: COLORS.PRIMARY, + width: 'auto' } ] }, @@ -79,7 +80,8 @@ const pageConfiguration = ({ pathToLogo, pageHeader, pageFooter }) => ({ text: 'Page ' + currentPage.toString() + ' of ' + pageCount, alignment: 'right', margin: [0, 40, 40, 0], - color: COLORS.PRIMARY + color: COLORS.PRIMARY, + width: 'auto' } ] }; diff --git a/server/routes/wazuh-utils/wazuh-utils.test.ts b/server/routes/wazuh-utils/wazuh-utils.test.ts index fb3cf6e51a..6039f60ea1 100644 --- a/server/routes/wazuh-utils/wazuh-utils.test.ts +++ b/server/routes/wazuh-utils/wazuh-utils.test.ts @@ -304,13 +304,13 @@ hosts: ${'customization.reports.footer'} | ${'Test\nTest'} | ${200} | ${null} ${'customization.reports.footer'} | ${'Test\nTest\nTest\nTest\nTest'} | ${400} | ${"[request body.customization.reports.footer]: The string should have less or equal to 2 line/s."} ${'customization.reports.footer'} | ${'Line with 30 characters \nTest'} | ${200} | ${undefined} - ${'customization.reports.footer'} | ${'Line with 31 characters \nTest'} | ${400} | ${"[request body.customization.reports.footer]: The maximum length of a line is 30 characters."} + ${'customization.reports.footer'} | ${'Testing the maximum length of a line of 50 characters\nTest'}| ${400} | ${"[request body.customization.reports.footer]: The maximum length of a line is 50 characters."} ${'customization.reports.footer'} | ${true} | ${400} | ${'[request body.customization.reports.footer]: expected value of type [string] but got [boolean]'} ${'customization.reports.header'} | ${'Test'} | ${200} | ${null} ${'customization.reports.header'} | ${'Test\nTest'} | ${200} | ${null} ${'customization.reports.header'} | ${'Test\nTest\nTest\nTest\nTest'} | ${400} | ${"[request body.customization.reports.header]: The string should have less or equal to 3 line/s."} ${'customization.reports.header'} | ${'Line with 20 charact\nTest'} | ${200} | ${undefined} - ${'customization.reports.header'} | ${'Line with 23 characters\nTest'} | ${400} | ${"[request body.customization.reports.header]: The maximum length of a line is 20 characters."} + ${'customization.reports.header'} | ${'Testing maximum length of a line of 40 characters\nTest'} | ${400} | ${"[request body.customization.reports.header]: The maximum length of a line is 40 characters."} ${'customization.reports.header'} | ${true} | ${400} | ${'[request body.customization.reports.header]: expected value of type [string] but got [boolean]'} ${'disabled_roles'} | ${['test']} | ${200} | ${null} ${'disabled_roles'} | ${['']} | ${400} | ${'[request body.disabled_roles.0]: Value can not be empty.'} From b155f2545f7d28dad5b160d202964e4d1c8782d8 Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Thu, 3 Nov 2022 18:02:10 +0100 Subject: [PATCH 2/2] Added changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c2b01616a..7c6e11f2bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Redesign the SCA table from agent's dashboard [#4512](https://github.com/wazuh/wazuh-kibana-app/pull/4512) - Enhanced the plugin setting description displayed in the UI and the configuration file. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501) - Added validation to the plugin settings in the form of `Settings/Configuration` and the endpoint to update the plugin configuration [#4503](https://github.com/wazuh/wazuh-kibana-app/pull/4503)[#4785](https://github.com/wazuh/wazuh-kibana-app/pull/4785) -- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505)[#4798](https://github.com/wazuh/wazuh-kibana-app/pull/4798) +- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505)[#4798](https://github.com/wazuh/wazuh-kibana-app/pull/4798)[#4805](https://github.com/wazuh/wazuh-kibana-app/pull/4805) - Add a new plugin setting to enable or disable the customization [#4507](https://github.com/wazuh/wazuh-kibana-app/pull/4507) ### Changed