Skip to content

Commit

Permalink
Add ability to disable the edition of configuration through API endpo…
Browse files Browse the repository at this point in the history
…ints and UI (#6607)

* feat(configuration): add ability to disable the edition of configuration from API endpoints

- Add ability to disable the edition of configuration from API endpoints
 - Add plugin setting to manage this ability
 - Add route controlle decorator
 - Protect the related API route controllers to updating the configuration
- Changed the sign of routeDecoratorProtectedAdministrator
 - Adapted its usage on the API endpoints
- Create compose utility to compose functions
- Add test related to API controllers decorators
- Add test about PUT /utils/configuration related to API endpoint
  protection

* fix(typo): plugin setting

* fix: remove repeated message on updating configuration from UI

* changelog: add entry

* remove: unused code on settings component

* fix(settings): refactor some unused code

* feat(configuration): configuration tab accessibility depends on plugin setting

* fix(configuration: typo

* fix: replace branding reference

* feat(configuration): hide the button to save the enrollment.dns plugin setting from the Deploy new agent guide

* feat(configuration): hide Settings button on Statistics application depending on if the configuration can be editable through UI
  • Loading branch information
Desvelao authored May 3, 2024
1 parent b8bfd00 commit 179f05b
Show file tree
Hide file tree
Showing 15 changed files with 749 additions and 545 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added propagation of updates from the table to dashboard visualizations in Endpoints summary [#6460](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6460)
- Handle index pattern selector on new discover [#6499](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6499)
- Added macOS log collector tab [#6545](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6545)
- Add ability to disable the edition of configuration through API endpoints and UI [#6557](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6557)
- Added journald log collector tab [#6572](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6572)

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../group-input/group-input.scss';
import { WzRequest } from '../../../../../react-services';
import { ErrorHandler } from '../../../../../react-services/error-management/error-handler/error-handler';
import { WzButtonPermissions } from '../../../../common/permissions/button';
import { useAppConfig } from '../../../../common/hooks';

interface ServerAddressInputProps {
formField: EnhancedFieldConfiguration;
Expand Down Expand Up @@ -50,6 +51,7 @@ const ServerAddressInput = (props: ServerAddressInputProps) => {
const [defaultServerAddress, setDefaultServerAddress] = useState(
formField?.initialValue ? formField?.initialValue : '',
);
const appConfig = useAppConfig();

const handleToggleRememberAddress = async event => {
setRememberServerAddress(event.target.checked);
Expand Down Expand Up @@ -146,18 +148,20 @@ const ServerAddressInput = (props: ServerAddressInputProps) => {
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup wrap>
<EuiFlexItem grow={false}>
<WzButtonPermissions
buttonType='switch'
administrator
disabled={rememberToggleIsDisabled()}
label='Remember server address'
checked={rememberServerAddress}
onChange={e => handleToggleRememberAddress(e)}
/>
</EuiFlexItem>
</EuiFlexGroup>
{appConfig?.data?.['configuration.ui_api_editable'] && (
<EuiFlexGroup wrap>
<EuiFlexItem grow={false}>
<WzButtonPermissions
buttonType='switch'
administrator
disabled={rememberToggleIsDisabled()}
label='Remember server address'
checked={rememberServerAddress}
onChange={e => handleToggleRememberAddress(e)}
/>
</EuiFlexItem>
</EuiFlexGroup>
)}
</Fragment>
);
};
Expand Down
6 changes: 3 additions & 3 deletions plugins/main/public/components/settings/about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import React from 'react';
import { EuiPage, EuiPageBody, EuiSpacer } from '@elastic/eui';
import { SettingsAboutAppInfo } from './appInfo';
import { SettingsAboutGeneralInfo } from './generalInfo';
import { PLUGIN_APP_NAME } from '../../../../common/constants';

interface SettingsAboutProps {
appInfo?: {
'app-version': string;
revision: string;
};
pluginAppName: string;
}

export const SettingsAbout = (props: SettingsAboutProps) => {
const { appInfo, pluginAppName } = props;
const { appInfo } = props;

return (
<EuiPage paddingSize='m'>
<EuiPageBody>
<SettingsAboutAppInfo appInfo={appInfo} />
<EuiSpacer size='l' />
<SettingsAboutGeneralInfo pluginAppName={pluginAppName} />
<SettingsAboutGeneralInfo pluginAppName={PLUGIN_APP_NAME} />
</EuiPageBody>
</EuiPage>
);
Expand Down
4 changes: 2 additions & 2 deletions plugins/main/public/components/settings/api/api-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const ApiTable = compose(
? error
: (error || {}).message ||
((error || {}).data || {}).message ||
'Wazuh is not reachable';
'API is not reachable';
const status = code === 3099 ? 'down' : 'unknown';
APIconnection.status = { status, downReason };
if (APIconnection.id === this.state.selectedAPIConnection) {
Expand Down Expand Up @@ -296,7 +296,7 @@ export const ApiTable = compose(
? error
: (error || {}).message ||
((error || {}).data || {}).message ||
'Wazuh is not reachable';
'API is not reachable';
const status = code === 3099 ? 'down' : 'unknown';
entries[idx].status = { status, downReason };
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ const WzConfigurationSettingsProvider = props => {
error: {
error: error,
message: error.message || error,
title: `Error saving the configuration: ${error.message || error}`,
title: 'Error saving the configuration',
},
};

Expand Down
Loading

0 comments on commit 179f05b

Please sign in to comment.