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

Upload file for customization.logo.* settings #4504

Merged
merged 139 commits into from
Oct 28, 2022
Merged
Changes from 3 commits
Commits
Show all changes
139 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
c2cb112
feat(settings): upload file for `customization.logo` settigs
Desvelao Sep 13, 2022
f3a7b71
feat(settings): Add validation for extensions of files for `customiza…
Desvelao 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
c39e70e
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 13, 2022
ea8ae9b
fix(settings): fixed problems setting a custom logo.
Desvelao Sep 13, 2022
1c9aee0
Made upload file mkdir recursive
asteriscos Sep 14, 2022
20ac021
Fixed configuration image preview ratios
asteriscos Sep 14, 2022
7002585
Fixed logo aspect ratio in wz-menu
asteriscos Sep 15, 2022
cfe5c72
Fix file input Remove button error
asteriscos Sep 15, 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
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
e5d7622
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 19, 2022
4c8678a
feat(settings): clean file picker inputs when there is a selected fil…
Desvelao Sep 19, 2022
79af3b8
fix(settings): get plugin setting description to display in Settings/…
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
1ac7a5e
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
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
c300fc2
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
5ce3672
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
5afb146
feat(settings): add validation of selected file size
Desvelao Sep 23, 2022
6e8b657
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
12e8a90
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
b0881c6
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
36ccbc0
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 23, 2022
6796284
fix(settings): fix an issue when removing a file from a file picker t…
Desvelao Sep 23, 2022
e42f9ae
fix(settings): fix error when deleting a custom image
Desvelao Sep 23, 2022
2bb0ce1
feat(settings): format bytes to meaningful unit.
Desvelao Sep 26, 2022
7855a3f
test(settings): Add tests related to validation for the `useForm` hoo…
Desvelao Sep 26, 2022
5105f24
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Sep 26, 2022
b7869d6
test(settings): add test to upload and delete customization files
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
494a8d0
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Sep 26, 2022
97f9318
feat(settings): add file size to the settings description
Desvelao Sep 27, 2022
0a97d9d
fix(settings): remove the selected files in the file pickers when cli…
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
fbc1c5c
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 3, 2022
03f5550
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
a3c56f6
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao 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
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
14f0709
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 5, 2022
38278c5
test(settings): add tests related to the `customization.logo.*` in th…
Desvelao Oct 5, 2022
282b7e9
Fix small typo
asteriscos Oct 5, 2022
dc7f80b
fix(settings): fix response when uploading custom files for `customiz…
Desvelao Oct 6, 2022
0f08dc1
feat(upload-file): get the file extension from file buffer.
Desvelao Oct 6, 2022
12fe59c
Merge branch 'feat/centralize-plugin-settings' of https://github.com/…
Desvelao Oct 6, 2022
7b29b6e
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
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
d6f6171
Merge branch 'feat/settings-validation' of https://github.com/wazuh/w…
Desvelao Oct 6, 2022
312461c
Changed Custom Branding documentation link
asteriscos Oct 11, 2022
6d5afcd
Merge centralize plugin settings PR
asteriscos Oct 11, 2022
938bacc
Fix white-labeling documentation url
asteriscos Oct 11, 2022
e3c31f3
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
25024e9
Merge branch 'feat/settings-validation' into feat/settings-upload-file
asteriscos Oct 24, 2022
254a718
Merge branch '4.4-7.10' into feat/settings-validation
AlexRuiz7 Oct 24, 2022
d4870d7
Fix semi-colon error
asteriscos Oct 25, 2022
368d171
Merge branch '4.4-7.10' into feat/settings-validation
AlexRuiz7 Oct 25, 2022
92a0109
Merge branch 'feat/settings-validation' into feat/settings-upload-file
AlexRuiz7 Oct 25, 2022
308f146
changelog: add entries to changelog
Desvelao Oct 25, 2022
af6f915
Merge branch 'feat/settings-validation' into feat/settings-upload-file
AlexRuiz7 Oct 25, 2022
beb02b5
Merge branch '4.4-7.10' into feat/settings-validation
AlexRuiz7 Oct 25, 2022
021e5a3
Merge branch 'feat/settings-validation' into feat/settings-upload-file
AlexRuiz7 Oct 25, 2022
9a2c0b8
Merge branch '4.4-7.10' into feat/settings-upload-file
AlexRuiz7 Oct 26, 2022
34ee9a3
fix(settings): fix some request changes
Desvelao Oct 26, 2022
fc46f92
fix(settings): fix an unsupported attribute for the number inputs
Desvelao Oct 26, 2022
1c96707
fix(settings): fix a problem when removing the `customization.logo.re…
Desvelao Oct 26, 2022
8535261
fix(settings): remove unused import
Desvelao Oct 26, 2022
b2794fa
Change validation error for inputs that don't allow whitespaces
AlexRuiz7 Oct 26, 2022
b7c2492
Update file-extension.ts
AlexRuiz7 Oct 26, 2022
723d105
feat(settings): change the layout of the filepicker input plus logo a…
Desvelao Oct 26, 2022
5195abf
test: update snapshots
Desvelao Oct 27, 2022
f831037
test: fix tests and update snapshots
Desvelao Oct 27, 2022
cafec69
changelog: add PR entry
Desvelao Oct 27, 2022
de863d1
changelog:fix PR entries
Desvelao Oct 27, 2022
9ddf35e
Merge branch '4.4-7.10' of https://github.com/wazuh/wazuh-kibana-app …
Desvelao Oct 27, 2022
9edc9da
fix(settings): fix a problem with SVG images that are not displayed w…
Desvelao Oct 28, 2022
88822ca
fix: remove comment
Desvelao Oct 28, 2022
ccd57ca
Fix logo image cache on upload
asteriscos Oct 28, 2022
60f9d79
Added a comment describing image versioning
asteriscos Oct 28, 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
15 changes: 7 additions & 8 deletions common/services/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
EpluginSettingType,
PLUGIN_SETTINGS,
PLUGIN_SETTINGS_CATEGORIES,
TPluginSetting,
@@ -78,8 +77,8 @@ const formatSettingValueToFileType = {

/**
* Group the settings by category
* @param settings
* @returns
* @param settings
* @returns
*/
export function groupSettingsByCategory(settings: TPluginSettingWithKey[]){
const settingsSortedByCategories = settings
@@ -99,8 +98,8 @@ export function groupSettingsByCategory(settings: TPluginSettingWithKey[]){

/**
* Get the plugin setting description composed.
* @param options
* @returns
* @param options
* @returns
*/
export function getPluginSettingDescription({description, options}: TPluginSetting): string{
return [
@@ -114,9 +113,9 @@ export function groupSettingsByCategory(settings: TPluginSettingWithKey[]){

/**
* Format the pair value-label to display the pair. If label and the string of value are equals, only displays the value, if not, displays both.
* @param value
* @param label
* @returns
* @param value
* @param label
* @returns
*/
export function formatLabelValuePair(label, value){
return label !== `${value}`
6 changes: 3 additions & 3 deletions public/components/common/form/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import _ from 'lodash';
import { isEqual } from 'lodash';
import { EpluginSettingType } from '../../../../common/constants';

function getValueFromEvent(event, type){
@@ -28,8 +28,8 @@ export const useForm = (fields) => {
...restFieldState,
type: fields[fieldKey].type,
value,
changed: !_.isEqual(restFieldState.initialValue, value),
error: fields[fieldKey]?.validate?.(value),
changed: !isEqual(restFieldState.initialValue, value),
error: fields[fieldKey]?.validate?.(restFieldState.currentValue),
onChange: (event) => {
const inputValue = getValueFromEvent(event, fields[fieldKey].type);
const currentValue = fields[fieldKey]?.transformChangedInputValue?.(inputValue) ?? inputValue;
10 changes: 3 additions & 7 deletions public/components/common/form/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import React from 'react';
import { IInputForm } from './types';
import { InputFormEditor } from './input_editor';
import { InputFormNumber } from './input_number';
import { InputFormText } from './input_text';
import { InputFormSwitch } from './input_switch';
import { InputFormSelect } from './input_select';

import {
EuiFormRow,
} from '@elastic/eui';
import { EuiFormRow } from '@elastic/eui';

export const InputForm = ({ type, value, onChange, error, label, preInput, postInput, ...rest}) => {

@@ -38,9 +34,9 @@ export const InputForm = ({ type, value, onChange, error, label, preInput, postI
{typeof postInput === 'function' ? postInput({value, error}) : postInput}
</>
</EuiFormRow>)
: input;
: input;

};
};

const Input = {
switch: InputFormSwitch,
4 changes: 1 addition & 3 deletions public/components/common/form/input_editor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
EuiCodeEditor,
} from '@elastic/eui';
import { EuiCodeEditor } from '@elastic/eui';
import { IInputFormType } from './types';

export const InputFormEditor = ({options, value, onChange}: IInputFormType) => {
4 changes: 1 addition & 3 deletions public/components/common/form/input_number.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
EuiFieldNumber,
} from '@elastic/eui';
import { EuiFieldNumber } from '@elastic/eui';
import { IInputFormType } from './types';

export const InputFormNumber = ({ options, value, onChange }: IInputFormType) => {
4 changes: 1 addition & 3 deletions public/components/common/form/input_select.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
EuiSelect,
} from '@elastic/eui';
import { EuiSelect } from '@elastic/eui';
import { IInputFormType } from './types';

export const InputFormSelect = ({ options, value, onChange }: IInputFormType) => {
4 changes: 1 addition & 3 deletions public/components/common/form/input_switch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
EuiSwitch,
} from '@elastic/eui';
import { EuiSwitch } from '@elastic/eui';
import { IInputFormType } from './types';

export const InputFormSwitch = ({ options, value, onChange }: IInputFormType) => {
4 changes: 1 addition & 3 deletions public/components/common/form/input_text.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
EuiFieldText,
} from '@elastic/eui';
import { EuiFieldText } from '@elastic/eui';
import { IInputFormType } from "./types";

export const InputFormText = ({ value, isInvalid, onChange }: IInputFormType) => {
7 changes: 3 additions & 4 deletions public/components/settings/configuration/configuration.tsx
Original file line number Diff line number Diff line change
@@ -29,10 +29,9 @@ import {
import store from '../../../redux/store'
import { updateSelectedSettingsSection } from '../../../redux/actions/appStateActions';
import { withUserAuthorizationPrompt, withErrorBoundary, withReduxProvider } from '../../common/hocs';
import { EpluginSettingType, PLUGIN_PLATFORM_NAME, PLUGIN_SETTINGS, PLUGIN_SETTINGS_CATEGORIES, UI_LOGGER_LEVELS, WAZUH_ROLE_ADMINISTRATOR_NAME } from '../../../../common/constants';
import { PLUGIN_PLATFORM_NAME, PLUGIN_SETTINGS, PLUGIN_SETTINGS_CATEGORIES, UI_LOGGER_LEVELS, WAZUH_ROLE_ADMINISTRATOR_NAME } from '../../../../common/constants';
import { compose } from 'redux';
import { getSettingsDefaultList, groupSettingsByCategory, getCategorySettingByTitle } from '../../../../common/services/settings';
import _ from 'lodash';
import { Category } from './components/categories/components';
import { WzRequest } from '../../../react-services';
import { UIErrorLog, UIErrorSeverity, UILogLevel, UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
@@ -69,7 +68,7 @@ const trasnsfromPluginSettingsToFormFields = configuration => Object.fromEntries
uiFormTransformInputValueToConfigurationValue,
...rest
}) => ([
key,
key,
{
type,
validate: validate?.bind?.(rest),
@@ -138,7 +137,7 @@ const WzConfigurationSettingsProvider = (props) => {
settingsToUpdate.saveOnConfigurationFile
));
};
const responses = await Promise.all(requests);
const responses = await Promise.all(requests);

// Show the toasts if necessary
responses.some(({data: { data: {requiresRunningHealthCheck}}}) => requiresRunningHealthCheck) && toastRequiresRunningHealthcheck();