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

Add switch to toggle the use of custom branding #4507

Merged
merged 138 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 137 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
918418f
feat(settings): centralize the plugin settings
Desvelao Sep 13, 2022
de48a49
feat(settings): add setting services and replaced the references to c…
Desvelao Sep 13, 2022
c25a1a0
feat(settings): refactor the content of the default configuration file
Desvelao Sep 13, 2022
ffdb2d7
feat(inputs): create new inputs components
Desvelao Sep 13, 2022
e7cd9b0
feat(configuration): refactor the form of Settings/Configuration
Desvelao Sep 13, 2022
5999419
feat(settings): support updating multiple setting at the same time
Desvelao Sep 13, 2022
9a2b9ba
feat: add validation to the plugin settings
Desvelao Sep 13, 2022
f530d7a
feat(validation): add validation to the `PUT /utils/configuration`
Desvelao Sep 13, 2022
b6a7220
feat(validation): add validation to the configuration form in
Desvelao Sep 13, 2022
134ffd8
feat(validatio): remove no used import
Desvelao Sep 13, 2022
9b977e6
clean: remove not used code
Desvelao Sep 13, 2022
a984a7c
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 13, 2022
f3fc8c8
Add report header-footer configuration
asteriscos Sep 13, 2022
17ad2e8
fix: fixed category name in `Settings/Configuration`
Desvelao Sep 13, 2022
ce4652e
fix(settings): Fix accessing to `validate` of undefined error
Desvelao Sep 13, 2022
23b925d
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 13, 2022
a454dd8
fix(settings): fixed error due to missing service
Desvelao Sep 13, 2022
a56e9d1
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 13, 2022
9bd9835
Add custom branding enabled switch
asteriscos Sep 13, 2022
c3daf43
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Sep 14, 2022
969aa79
Merge branch 'feat/header-footer-report-customization-4426' into feat…
asteriscos Sep 14, 2022
acb8bf0
Fix custom logo ratio in PDF sheet
asteriscos Sep 14, 2022
5d68615
fix(settings): refactor the form and inputs of `Settings/Configuratio…
Desvelao Sep 16, 2022
ef8d6ad
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 16, 2022
1c076be
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Sep 16, 2022
8459f45
Merge branch 'feat/header-footer-report-customization-4426' into feat…
asteriscos Sep 16, 2022
cf15ef8
fix: add value transformation for the form inputs and output of field…
Desvelao Sep 19, 2022
2597cf6
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 19, 2022
951812e
fix: Fixed some settings validation
Desvelao Sep 19, 2022
e0a057e
fix(settings): fixed validation of literals
Desvelao Sep 19, 2022
9699336
fix(settings): removed unused import
Desvelao Sep 19, 2022
0a1ee1d
fix(settings): renamed properties related to transform the value of t…
Desvelao Sep 19, 2022
0109910
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 19, 2022
b4ef2cd
feat(settings): add description to the plugin setting definition prop…
Desvelao Sep 19, 2022
fac95d5
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 19, 2022
34c8de2
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 19, 2022
138db83
fix(settings): fix getConfiguration service when the configuration fi…
Desvelao Sep 20, 2022
710800d
fix(settings): Fixed error when do changes of the `useForm` hook an r…
Desvelao Sep 20, 2022
7d7decc
tests(settings): add test related to the plugin settings and its conf…
Desvelao Sep 20, 2022
5f4d0bd
feat(settings): rename plugin setting options of type select to match…
Desvelao Sep 21, 2022
0cb6be5
feat(settings): add plugin settings services and enhance the descript…
Desvelao Sep 21, 2022
34ddc38
tests(input-form): update tests of InputForm component
Desvelao Sep 21, 2022
f74553b
test(configuration-file): add tests of the default configuration file
Desvelao Sep 21, 2022
4bc1972
feat(settings): remove `extensions.mitre` plugin setting
Desvelao Sep 21, 2022
c4b4c3e
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 21, 2022
28c2266
test(settings): add test to validate the plugin setting when updating…
Desvelao Sep 22, 2022
3d2ca47
feat(settings): add documentation to some setting services and test s…
Desvelao Sep 22, 2022
ef631ff
fix: fixed documentation of setting service
Desvelao Sep 22, 2022
1851f9e
doc(settings): move the documentation of the plugin setting properties
Desvelao Sep 22, 2022
d2a8773
fix(settings): rename some plugin setting properties because of reque…
Desvelao Sep 23, 2022
1d34f6c
tests: fix tests of InputForm component
Desvelao Sep 23, 2022
ac3ebc2
fix: response properties when saving the configuration
Desvelao Sep 23, 2022
70e408d
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 23, 2022
1356c5b
fix(settings): fix validation plugin settings value in the UI
Desvelao Sep 23, 2022
797c9c6
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
92510c4
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Sep 23, 2022
b0e5864
fix(settings): fix `customization.reports.header` and `customization.…
Desvelao Sep 23, 2022
061b99b
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Sep 23, 2022
6e8b657
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
fdb6bfc
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
27c5ab4
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Sep 23, 2022
b0881c6
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
7f96098
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
7be2be3
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
7855a3f
test(settings): Add tests related to validation for the `useForm` hoo…
Desvelao Sep 26, 2022
e7fd477
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 26, 2022
f916356
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Sep 26, 2022
716a582
fix(settings): fix displaying toast to run the healthcheck when savin…
Desvelao Sep 26, 2022
8ae5067
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 26, 2022
b5c4229
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 26, 2022
ec48ad4
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 26, 2022
6b3cdd3
test(settings): add tests for the `customization.reports.footer` and …
Desvelao Sep 27, 2022
41aeb41
test(settings): Add tests for the `customization.enabled` setting
Desvelao Sep 27, 2022
88f0012
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Sep 27, 2022
93157e3
Added category sorting + description + docs link
asteriscos Sep 28, 2022
a007e01
Added settings sorting within their category
asteriscos Sep 28, 2022
0549cb6
Fixed constant types definition
asteriscos Sep 28, 2022
26fa66c
Checks if localCompare exists validation
asteriscos Sep 28, 2022
1f4c01a
fix(settings): fixed plugin setting description doesn't display the m…
Desvelao Oct 3, 2022
33bc999
fix(settings): fix setting type of `wazuh.monitoring.replicas` and li…
Desvelao Oct 3, 2022
ffb1eb9
feat(settins): add plugin settings category description
Desvelao Oct 3, 2022
a935861
fix(settings): fix a problem comparing the initial and current value …
Desvelao Oct 3, 2022
3847992
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 3, 2022
62d1aab
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 3, 2022
0b32a5b
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 3, 2022
a962188
fix(settings): fix wrong conflict resolution
Desvelao Oct 3, 2022
b551b00
fix(settings): fix typo in setting description
Desvelao Oct 3, 2022
8adf7b4
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 3, 2022
0e5e8c9
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 3, 2022
2137bdc
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 3, 2022
f5bf16f
Add set custom header footer unit test
asteriscos Oct 3, 2022
a4e202e
feat(settings): enhance the validation of plugin settings related to …
Desvelao Oct 4, 2022
08792c9
feat(settings): add validation of setting values in the inputs
Desvelao Oct 4, 2022
51f96cb
Added unit test to verify the PDF report integrity
asteriscos Oct 4, 2022
624a8f4
fix(tests): format tables of the tests
Desvelao Oct 5, 2022
d6a22a7
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 5, 2022
2e0d6c3
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 5, 2022
9456bcf
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 5, 2022
95b9020
fix: remove unnecessary import
Desvelao Oct 5, 2022
034bd34
test(endpoints): add test to GET /reports endpoint
Desvelao Oct 5, 2022
ff57714
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 5, 2022
75ed4f0
test(settings): add test for `customization.enabled` setting in the f…
Desvelao Oct 5, 2022
91e6749
Improved report unit test with more cases
asteriscos Oct 5, 2022
282b7e9
Fix small typo
asteriscos Oct 5, 2022
12fe59c
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 6, 2022
22f2e70
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 6, 2022
ffbdd35
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 6, 2022
04f7457
fix(settings): fix a typo in a toast related to modify the plugin set…
Desvelao Oct 6, 2022
066002e
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 6, 2022
caf1c98
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 6, 2022
cf2c243
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 6, 2022
312461c
Changed Custom Branding documentation link
asteriscos Oct 11, 2022
6d5afcd
Merge centralize plugin settings PR
asteriscos Oct 11, 2022
cb793d6
Fix white-labeling documentation link
asteriscos Oct 11, 2022
950688e
Fix white-labeling documentation link
asteriscos Oct 11, 2022
d4c18b1
Code format
asteriscos Oct 20, 2022
19c7cac
Delete unused imports
asteriscos Oct 20, 2022
84472df
Merge branch 'feat/centralize-plugin-settings' into feat/settings-val…
AlexRuiz7 Oct 20, 2022
e6da4c3
fix(settings): fix a problem with the useForm hook
Desvelao Oct 21, 2022
dffeb09
fix(settings): refactor the settings validation function to a class a…
Desvelao Oct 21, 2022
e5a28ea
feat(settings): add check for integer numbers and adapt the affected …
Desvelao Oct 21, 2022
a4e0a86
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Oct 24, 2022
6e13173
Merge branch 'feat/header-footer-report-customization-4426' into feat…
asteriscos Oct 24, 2022
38ca355
Merge branch '4.4-7.10' of https://github.com/wazuh/wazuh-kibana-app …
Desvelao Oct 31, 2022
363b622
changelog: Add PR entry
Desvelao Oct 31, 2022
8d86689
fix(settings): fix the customization settings do not apply when the `…
Desvelao Oct 31, 2022
f62dca9
fix(settings): the `customization.logo.sidebar` is updated without re…
Desvelao Oct 31, 2022
6ffbdb6
Fix customization.enable on GET api/logos endpoint
asteriscos Oct 31, 2022
b7ee36b
Merge branch 'feat/add-custom-branding-enabled-configuration-4506' of…
asteriscos Oct 31, 2022
f07964b
fix: revert unused change
Desvelao Nov 2, 2022
c137ccc
fix: revert the updating of the `customization.logo.sidebar` when the…
Desvelao Nov 2, 2022
17e4363
Merge branch '4.4-7.10' into feat/add-custom-branding-enabled-configu…
AlexRuiz7 Nov 2, 2022
ce65312
fix: removed unused code and removed space
Desvelao Nov 2, 2022
f946f86
Merge branch 'feat/add-custom-branding-enabled-configuration-4506' of…
Desvelao Nov 2, 2022
58e7be7
fix: undone unwanted changes
Desvelao Nov 2, 2022
e36d4df
fix: resolve setting when it is an empty string
Desvelao Nov 2, 2022
7ad0476
fix: request changes and rename function
Desvelao Nov 2, 2022
95297d2
fix: fix settings tests
Desvelao Nov 2, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- 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)
- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505)
- Add a new plugin setting to enable or disable the customization [#4507](https://github.com/wazuh/wazuh-kibana-app/pull/4507)

### Changed

Expand Down
29 changes: 27 additions & 2 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,31 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
return schema.boolean();
},
},
"customization.enabled": {
title: "Status",
description: "Enable or disable the customization.",
category: SettingCategory.CUSTOMIZATION,
type: EpluginSettingType.switch,
defaultValue: true,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
requiresReloadingBrowserTab: true,
options: {
switch: {
values: {
disabled: {label: 'false', value: false},
enabled: {label: 'true', value: true},
}
}
},
uiFormTransformChangedInputValue: function(value: boolean | string): boolean{
return Boolean(value);
},
validate: SettingsValidator.isBoolean,
validateBackend: function(schema){
return schema.boolean();
},
},
"customization.logo.app": {
title: "App main logo",
description: `This logo is used in the app main menu, at the top left corner.`,
Expand Down Expand Up @@ -1088,7 +1113,7 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
category: SettingCategory.CUSTOMIZATION,
type: EpluginSettingType.textarea,
defaultValue: "",
defaultValueIfNotSet: REPORTS_PAGE_FOOTER_TEXT,
defaultValueIfNotSet: REPORTS_PAGE_FOOTER_TEXT,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: { rowsSize: 2, maxLength: 30 },
Expand Down Expand Up @@ -1119,7 +1144,7 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
})(value)
},
validateBackend: function(schema){
return schema.string({validate: this.validate?.bind(this)});
return schema.string({validate: this.validate.bind(this)});
},
},
"disabled_roles": {
Expand Down
1 change: 1 addition & 0 deletions common/plugin-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('[settings] Input validation', () => {
${'cron.statistics.interval'} | ${true} | ${"Interval is not valid."}
${'cron.statistics.status'} | ${true} | ${undefined}
${'cron.statistics.status'} | ${0} | ${'It should be a boolean. Allowed values: true or false.'}
${'customization.enabled'} | ${true} | ${undefined}
${'customization.logo.app'} | ${{size: 124000, name: 'image.jpg'}} | ${undefined}
${'customization.logo.app'} | ${{size: 124000, name: 'image.jpeg'}} | ${undefined}
${'customization.logo.app'} | ${{size: 124000, name: 'image.png'}} | ${undefined}
Expand Down
28 changes: 27 additions & 1 deletion common/services/settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
formatLabelValuePair,
formatSettingValueToFile
formatSettingValueToFile,
getCustomizationSetting
} from "./settings";

describe('[settings] Methods', () => {
Expand Down Expand Up @@ -31,4 +32,29 @@ describe('[settings] Methods', () => {
expect(formatSettingValueToFile(input)).toBe(expected);
});
});

describe('getCustomizationSetting: Get the value for the "customization." settings depending on the "customization.enabled" setting', () => {
it.only.each`
customizationEnabled | settingKey | configValue | expected
${true} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${'custom-image-app.png'}
${true} | ${'customization.logo.app'} | ${''} | ${''}
${false} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${''}
${false} | ${'customization.logo.app'} | ${''} | ${''}
${true} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Custom footer'}
${true} | ${'customization.reports.footer'} | ${''} | ${''}
${false} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Copyright © 2022 Wazuh, Inc.'}
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2022 Wazuh, Inc.'}
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2022 Wazuh, Inc.'}
${true} | ${'customization.reports.header'} | ${'Custom header'} | ${'Custom header'}
${true} | ${'customization.reports.header'} | ${''} | ${''}
${false} | ${'customization.reports.header'} | ${'Custom header'} | ${'[email protected]\nhttps://wazuh.com'}
${false} | ${'customization.reports.header'} | ${''} | ${'[email protected]\nhttps://wazuh.com'}
`(`customizationEnabled: $customizationEnabled | settingKey: $settingKey | configValue: $configValue | expected: $expected`, ({ configValue, customizationEnabled, expected, settingKey }) => {
const configuration = {
'customization.enabled': customizationEnabled,
[settingKey]: configValue
};
expect(getCustomizationSetting(configuration, settingKey)).toBe(expected);
});
});
});
31 changes: 31 additions & 0 deletions common/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,34 @@ export function formatLabelValuePair(label, value){
? `${value} (${label})`
: `${value}`
};

/**
* Get the configuration value if the customization is enabled.
* @param configuration JSON object from `wazuh.yml`
* @param settingKey key of the setting
* @returns
*/
export function getCustomizationSetting(configuration: {[key: string]: any }, settingKey: string): any {
const isCustomizationEnabled = typeof configuration['customization.enabled'] === 'undefined'
? getSettingDefaultValue('customization.enabled')
: configuration['customization.enabled'];
const defaultValue = getSettingDefaultValue(settingKey);

if ( isCustomizationEnabled && settingKey.startsWith('customization') && settingKey !== 'customization.enabled'){
return (typeof configuration[settingKey] !== 'undefined' ? resolveEmptySetting(settingKey, configuration[settingKey]) : defaultValue);
}else{
return defaultValue;
};
};

/**
* Returns the default value if not set when the setting is an empty string
* @param settingKey plugin setting
* @param value value of the plugin setting
* @returns
*/
function resolveEmptySetting(settingKey: string, value : unknown){
return typeof value === 'string' && value.length === 0 && PLUGIN_SETTINGS[settingKey].defaultValueIfNotSet
? getSettingDefaultValue(settingKey)
: value;
};
2 changes: 1 addition & 1 deletion public/components/common/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const InputForm = ({
const Input = {
switch: InputFormSwitch,
editor: InputFormEditor,
filepicker: InputFormFilePicker,
number: InputFormNumber,
select: InputFormSelect,
text: InputFormText,
textarea: InputFormTextArea,
filepicker: InputFormFilePicker
};
4 changes: 2 additions & 2 deletions public/components/common/hocs/withUserLogged.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { getHttp } from '../../../kibana-services';
import { getAssetURL, getThemeAssetURL } from "../../../utils/assets";

export const withUserLogged = (WrappedComponent) => (props) => {
const withUserLogged = useSelector((state)=> state.appStateReducers.withUserLogged);
const customAppLogo = useSelector((state)=> state?.appConfig?.data?.['customization.logo.app']);
const withUserLogged = useSelector((state) => state.appStateReducers.withUserLogged);
const customAppLogo = useSelector((state) => state?.appConfig?.data?.['customization.enabled'] && state?.appConfig?.data?.['customization.logo.app']);

return withUserLogged ? <WrappedComponent {...props}/> : (
<div className="withUserLogged">
Expand Down
47 changes: 27 additions & 20 deletions public/components/health-check/container/health-check.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { compose } from 'redux';
import { getThemeAssetURL, getAssetURL } from '../../../utils/assets';

const checks = {
api: {
api: {
title: 'Check Wazuh API connection',
label: 'API connection',
validator: checkApiService,
Expand Down Expand Up @@ -107,18 +107,21 @@ const checks = {
timeFilter: {
title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`,
label: `${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`,
validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER, JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER), (checkLogger: CheckLogger, options: {defaultAppValue: any}) => {
getDataPlugin().query.timefilter.timefilter.setTime(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER)
&& checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`);
}),
validator: checkPluginPlatformSettings(
PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER,
JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER),
(checkLogger: CheckLogger, options: { defaultAppValue: any }) => {
getDataPlugin().query.timefilter.timefilter.setTime(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER)
&& checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`);
}),
awaitFor: [],
canRetry: true,
}
};

function HealthCheckComponent() {
const [checkErrors, setCheckErrors] = useState<{[key:string]: []}>({});
const [checksReady, setChecksReady] = useState<{[key: string]: boolean}>({});
const [checkErrors, setCheckErrors] = useState<{ [key: string]: [] }>({});
const [checksReady, setChecksReady] = useState<{ [key: string]: boolean }>({});
const [isDebugMode, setIsDebugMode] = useState<boolean>(false);
const appConfig = useAppConfig();
const checksInitiated = useRef(false);
Expand All @@ -142,35 +145,39 @@ function HealthCheckComponent() {
// Redirect to app when all checks are ready
Object.keys(checks)
.every(check => checksReady[check])
&& !isDebugMode && (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME)
&& !isDebugMode && (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME)
)()
}, [checksReady]);

useEffect(() => {
// Check if Health should not redirect automatically (Debug mode)
setIsDebugMode(window.location.href.includes('debug'));
},[]);
}, []);

const handleErrors = (checkID, errors, parsed) => {
const newErrors = parsed
? errors.map((error) =>
ErrorHandler.handle(error, 'Health Check', { warning: false, silent: true })
)
ErrorHandler.handle(error, 'Health Check', { warning: false, silent: true })
)
: errors;
setCheckErrors((prev) => ({...prev, [checkID]: newErrors}));
setCheckErrors((prev) => ({ ...prev, [checkID]: newErrors }));
};

const cleanErrors = (checkID: string) => {
delete checkErrors[checkID];
setCheckErrors({...checkErrors});
setCheckErrors({ ...checkErrors });
}

const handleCheckReady = (checkID, isReady) => {
setChecksReady(prev => ({...prev, [checkID]: isReady}));
const handleCheckReady = (checkID, isReady) => {
setChecksReady(prev => ({ ...prev, [checkID]: isReady }));
}


const logoUrl = getHttp().basePath.prepend(appConfig.data['customization.logo.healthcheck'] ? getAssetURL(appConfig.data['customization.logo.healthcheck']) : getThemeAssetURL('logo.svg'));
const logoUrl = getHttp().basePath.prepend(
appConfig.data['customization.enabled'] && appConfig.data['customization.logo.healthcheck'] ?
getAssetURL(appConfig.data['customization.logo.healthcheck']) :
getThemeAssetURL('logo.svg')
);
const thereAreErrors = Object.keys(checkErrors).length > 0;

const renderChecks = () => {
Expand All @@ -188,7 +195,7 @@ function HealthCheckComponent() {
handleErrors={handleErrors}
cleanErrors={cleanErrors}
isLoading={appConfig.isLoading}
handleCheckReady= {handleCheckReady}
handleCheckReady={handleCheckReady}
checksReady={checksReady}
canRetry={checks[check].canRetry}
/>
Expand Down Expand Up @@ -220,7 +227,7 @@ function HealthCheckComponent() {
};

const renderErrors = () => {
return Object.keys(checkErrors).map((checkID) =>
return Object.keys(checkErrors).map((checkID) =>
checkErrors[checkID].map((error, index) => (
<Fragment key={index}>
<EuiCallOut
Expand All @@ -233,7 +240,7 @@ function HealthCheckComponent() {
<EuiSpacer size="xs" />
</Fragment>
))
)
)
};

return (
Expand Down Expand Up @@ -277,7 +284,7 @@ function HealthCheckComponent() {
);
}

export const HealthCheck = compose (withErrorBoundary,withReduxProvider) (HealthCheckComponent);
export const HealthCheck = compose(withErrorBoundary, withReduxProvider)(HealthCheckComponent);

export const HealthCheckTest = HealthCheckComponent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const InputFormFilePickerPreInput = ({image, field}: {image: string, field: any}
try{
const response = await WzRequest.genericReq('DELETE', `/utils/configuration/files/${field.key}`);
dispatch(updateAppConfig(response.data.data.updatedConfiguration));

// Show the toasts if necessary
const { requiresRunningHealthCheck, requiresReloadingBrowserTab, requiresRestartingPluginPlatform } = response.data.data;
requiresRunningHealthCheck && toastRequiresRunningHealthcheck();
Expand Down
6 changes: 3 additions & 3 deletions public/components/settings/configuration/configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { Category } from './components/categories/components';
import { WzRequest } from '../../../react-services';
import { UIErrorLog, UIErrorSeverity, UILogLevel, UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
import { getErrorOrchestrator } from '../../../react-services/common-services';
import { getToasts } from '../../../kibana-services';
import { updateAppConfig } from '../../../redux/actions/appConfigActions';
import path from 'path';
import { toastRequiresReloadingBrowserTab, toastRequiresRestartingPluginPlatform, toastRequiresRunningHealthcheck, toastSuccessUpdateConfiguration } from './components/categories/components/show-toasts';
Expand Down Expand Up @@ -172,14 +171,15 @@ const WzConfigurationSettingsProvider = (props) => {
responses.some(({data: { data: {requiresRestartingPluginPlatform}}}) => requiresRestartingPluginPlatform) && toastRequiresRestartingPluginPlatform();

// Update the app configuration frontend-cached setting in memory with the new values
dispatch(updateAppConfig({
const updatedConfiguration = {
...responses.reduce((accum, {data: {data}}) => {
return {
...accum,
...(data.updatedConfiguration ? {...data.updatedConfiguration} : {}),
}
},{})
}));
};
dispatch(updateAppConfig(updatedConfiguration));

// Remove the selected files on the file picker inputs
if(Object.keys(settingsToUpdate.fileUpload).length){
Expand Down
4 changes: 1 addition & 3 deletions public/components/wz-menu/wz-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import {
EuiPopover,
EuiIcon,
EuiButtonEmpty,
EuiText,
EuiCallOut,
EuiPageHeader,
EuiToolTip,
EuiLoadingSpinner,
EuiFormRow,
Expand Down Expand Up @@ -904,7 +902,7 @@ export const WzMenu = withWindowSize(class WzMenu extends Component {
);


const logotypeURL = getHttp().basePath.prepend(this.wazuhConfig.getConfig()['customization.logo.app'] ? getAssetURL(this.wazuhConfig.getConfig()['customization.logo.app']) : getThemeAssetURL('logo.svg'));
const logotypeURL = getHttp().basePath.prepend(this.wazuhConfig.getConfig()['customization.enabled'] && this.wazuhConfig.getConfig()['customization.logo.app'] ? getAssetURL(this.wazuhConfig.getConfig()['customization.logo.app']) : getThemeAssetURL('logo.svg'));
const mainButton = (
<button data-test-subj='menuWazuhButton' className="eui" onClick={() => this.switchMenuOpened()}>
<EuiFlexGroup
Expand Down
4 changes: 2 additions & 2 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class WazuhPlugin implements Plugin<WazuhSetup, WazuhStart, WazuhSetupPlu
private hideTelemetryBanner?: () => void;
public async setup(core: CoreSetup, plugins: WazuhSetupPlugins): WazuhSetup {
const UI_THEME = core.uiSettings.get('theme:darkMode') ? 'dark' : 'light';

// Get custom logos configuration to start up the app with the correct logos
let logosInitialState={};
try{
Expand Down Expand Up @@ -166,4 +166,4 @@ export class WazuhPlugin implements Plugin<WazuhSetup, WazuhStart, WazuhSetupPlu
setErrorOrchestrator(ErrorOrchestratorService);
return {};
}
}
}
15 changes: 8 additions & 7 deletions server/controllers/wazuh-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { KeyEquivalence } from '../../common/csv-key-equivalence';
import { ApiErrorEquivalence } from '../lib/api-errors-equivalence';
import apiRequestList from '../../common/api-info/endpoints';
import { HTTP_STATUS_CODES } from '../../common/constants';
import { getCustomizationSetting } from '../../common/services/settings';
import { addJobToQueue } from '../start/queue';
import fs from 'fs';
import { ManageHosts } from '../lib/manage-hosts';
Expand Down Expand Up @@ -1108,14 +1109,14 @@ export class WazuhApiCtrl {
const APP_LOGO = 'customization.logo.app';
const HEALTHCHECK_LOGO = 'customization.logo.healthcheck';

const logos= {
[SIDEBAR_LOGO]: getCustomizationSetting(configuration, SIDEBAR_LOGO),
[APP_LOGO]: getCustomizationSetting(configuration, APP_LOGO),
[HEALTHCHECK_LOGO]: getCustomizationSetting(configuration, HEALTHCHECK_LOGO),
}

return response.ok({
body: {
logos: {
[SIDEBAR_LOGO]: configuration[SIDEBAR_LOGO],
[APP_LOGO]: configuration[APP_LOGO],
[HEALTHCHECK_LOGO]: configuration[HEALTHCHECK_LOGO],
}
}
body: { logos }
});
} catch (error) {
log('wazuh-api:getAppLogos', error.message || error);
Expand Down
Loading