diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53e1d07319..c486730508 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ All notable changes to the Wazuh app project will be documented in this file.
### Added
- Support for Wazuh 4.8.0
-- Added the ability to check if there are available updates from the UI. [#6093](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6093) [#6256](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6256)
+- Added the ability to check if there are available updates from the UI. [#6093](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6093) [#6256](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6256) [#6328](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6328)
- Added remember server address check [#5791](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5791)
- Added the ssl_agent_ca configuration to the SSL Settings form [#6083](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6083)
- Added global vulnerabilities dashboards [#5896](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5896) [#6179](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6179) [#6173](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6173) [#6147](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6147) [#6231](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6231) [#6246](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6246) [#6321](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6321) [#6338] (https://github.com/wazuh/wazuh-dashboard-plugins/pull/6338)
diff --git a/plugins/main/opensearch_dashboards.json b/plugins/main/opensearch_dashboards.json
index c51068870a..57736d8726 100644
--- a/plugins/main/opensearch_dashboards.json
+++ b/plugins/main/opensearch_dashboards.json
@@ -19,7 +19,8 @@
"opensearchDashboardsReact",
"opensearchDashboardsUtils",
"opensearchDashboardsLegacy",
- "wazuhCheckUpdates"
+ "wazuhCheckUpdates",
+ "wazuhCore"
],
"optionalPlugins": [
"security",
@@ -29,4 +30,4 @@
],
"server": true,
"ui": true
-}
\ No newline at end of file
+}
diff --git a/plugins/main/public/components/settings/api/api-table.js b/plugins/main/public/components/settings/api/api-table.js
index 89bed290c1..8511b4cc93 100644
--- a/plugins/main/public/components/settings/api/api-table.js
+++ b/plugins/main/public/components/settings/api/api-table.js
@@ -35,9 +35,11 @@ import { compose } from 'redux';
import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
import { UI_LOGGER_LEVELS } from '../../../../common/constants';
import { getErrorOrchestrator } from '../../../react-services/common-services';
-import { getWazuhCheckUpdatesPlugin } from '../../../kibana-services';
+import {
+ getWazuhCheckUpdatesPlugin,
+ getWazuhCorePlugin,
+} from '../../../kibana-services';
import { AvailableUpdatesFlyout } from './available-updates-flyout';
-import { formatUIDate } from '../../../react-services/time-service';
export const ApiTable = compose(
withErrorBoundary,
@@ -47,13 +49,10 @@ export const ApiTable = compose(
constructor(props) {
super(props);
- const { getAvailableUpdates } = getWazuhCheckUpdatesPlugin();
-
this.state = {
apiEntries: [],
refreshingEntries: false,
availableUpdates: {},
- getAvailableUpdates,
refreshingAvailableUpdates: true,
apiAvailableUpdateDetails: undefined,
};
@@ -62,9 +61,8 @@ export const ApiTable = compose(
async getApisAvailableUpdates(forceUpdate = false) {
try {
this.setState({ refreshingAvailableUpdates: true });
- const availableUpdates = await this.state.getAvailableUpdates(
- forceUpdate,
- );
+ const availableUpdates =
+ await getWazuhCheckUpdatesPlugin().getAvailableUpdates(forceUpdate);
this.setState({ availableUpdates });
} catch (error) {
const options = {
@@ -553,10 +551,8 @@ export const ApiTable = compose(
title='Last check'
content={
this.state.availableUpdates?.last_check_date
- ? formatUIDate(
- new Date(
- this.state.availableUpdates.last_check_date,
- ),
+ ? getWazuhCorePlugin().utils.formatUIDate(
+ this.state.availableUpdates.last_check_date,
)
: '-'
}
diff --git a/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.test.tsx b/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.test.tsx
index 3065bee989..0ff3b36489 100644
--- a/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.test.tsx
+++ b/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.test.tsx
@@ -7,22 +7,29 @@ jest.mock(
'../../../../../../../node_modules/@elastic/eui/lib/services/accessibility/html_id_generator',
() => ({
htmlIdGenerator: () => () => 'htmlId',
- })
+ }),
);
-jest.mock('../../../../react-services/time-service', () => ({
- formatUIDate: jest.fn().mockReturnValue('Sep 25, 2023 @ 14:03:40.816'),
+jest.mock('../../../../kibana-services', () => ({
+ getWazuhCorePlugin: jest.fn().mockReturnValue({
+ utils: {
+ formatUIDate: jest.fn().mockReturnValue('Sep 25, 2023 @ 14:03:40.816'),
+ },
+ }),
}));
-jest.mock('../../../../../../../src/plugins/opensearch_dashboards_react/public', () => ({
- Markdown: jest.fn().mockReturnValue(
Description
),
-}));
+jest.mock(
+ '../../../../../../../src/plugins/opensearch_dashboards_react/public',
+ () => ({
+ Markdown: jest.fn().mockReturnValue(Description
),
+ }),
+);
describe('UpdateDetail component', () => {
test('should return the UpdateDetail component', async () => {
const { container, getByText, getByRole } = render(
{
tag: 'v4.8.0',
title: 'Wazuh v4.8.0',
}}
- />
+ />,
);
expect(container).toMatchSnapshot();
diff --git a/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.tsx b/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.tsx
index 24e04b142b..a678076905 100644
--- a/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.tsx
+++ b/plugins/main/public/components/settings/api/available-updates-flyout/update-detail.tsx
@@ -1,6 +1,5 @@
import React from 'react';
import { Update } from '../../../../../../wazuh-check-updates/common/types';
-import { formatUIDate } from '../../../../react-services/time-service';
import { Markdown } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
import {
EuiAccordion,
@@ -12,6 +11,7 @@ import {
EuiBadge,
EuiTitle,
} from '@elastic/eui';
+import { getWazuhCorePlugin } from '../../../../kibana-services';
interface UpdateDetailProps {
update: Partial;
@@ -25,7 +25,9 @@ export const UpdateDetail = ({ update, type }: UpdateDetailProps) => {
semver?.major &&
(semver?.minor || semver?.minor === 0) &&
(semver?.patch || semver?.patch === 0);
- const minorVersion = hasVersions ? `${semver.major}.${semver.minor}` : undefined;
+ const minorVersion = hasVersions
+ ? `${semver.major}.${semver.minor}`
+ : undefined;
const releaseNotesUrl = hasVersions
? `https://documentation.wazuh.com/current/release-notes/release-${semver.major}-${semver.minor}-${semver.patch}.html`
: undefined;
@@ -36,21 +38,21 @@ export const UpdateDetail = ({ update, type }: UpdateDetailProps) => {
return title && tag ? (
+
-
+
{title}
- {type}
+ {type}
}
- paddingSize="l"
+ paddingSize='l'
>
{published_date ? (
<>
@@ -58,7 +60,8 @@ export const UpdateDetail = ({ update, type }: UpdateDetailProps) => {
listItems={[
{
title: 'Published',
- description: formatUIDate(new Date(published_date)),
+ description:
+ getWazuhCorePlugin().utils.formatUIDate(published_date),
},
]}
/>
@@ -69,12 +72,12 @@ export const UpdateDetail = ({ update, type }: UpdateDetailProps) => {
<>
-
+
Release notes
-
+
Upgrade guide
@@ -82,7 +85,9 @@ export const UpdateDetail = ({ update, type }: UpdateDetailProps) => {
>
) : null}
- {description ? : null}
+ {description ? (
+
+ ) : null}
) : null;
};
diff --git a/plugins/main/public/kibana-services.ts b/plugins/main/public/kibana-services.ts
index 1257f238ed..1c536dc5e1 100644
--- a/plugins/main/public/kibana-services.ts
+++ b/plugins/main/public/kibana-services.ts
@@ -45,6 +45,8 @@ export const [getWzCurrentAppID, setWzCurrentAppID] =
createGetterSetter('WzCurrentAppID');
export const [getWazuhCheckUpdatesPlugin, setWazuhCheckUpdatesPlugin] =
createGetterSetter('WazuhCheckUpdatesPlugin');
+export const [getWazuhCorePlugin, setWazuhCorePlugin] =
+ createGetterSetter('WazuhCorePlugin');
export const [getHeaderActionMenuMounter, setHeaderActionMenuMounter] =
createGetterSetter(
'headerActionMenuMounter',
diff --git a/plugins/main/public/plugin.ts b/plugins/main/public/plugin.ts
index a86adb9989..8126e4acc5 100644
--- a/plugins/main/public/plugin.ts
+++ b/plugins/main/public/plugin.ts
@@ -24,6 +24,7 @@ import {
setWzCurrentAppID,
setWazuhCheckUpdatesPlugin,
setHeaderActionMenuMounter,
+ setWazuhCorePlugin,
} from './kibana-services';
import {
AppPluginStartDependencies,
@@ -225,6 +226,7 @@ export class WazuhPlugin
setOverlays(core.overlays);
setErrorOrchestrator(ErrorOrchestratorService);
setWazuhCheckUpdatesPlugin(plugins.wazuhCheckUpdates);
+ setWazuhCorePlugin(plugins.wazuhCore);
return {};
}
}
diff --git a/plugins/wazuh-check-updates/public/components/updates-notification.scss b/plugins/wazuh-check-updates/public/components/updates-notification.scss
index fa19126902..21eb2494b3 100644
--- a/plugins/wazuh-check-updates/public/components/updates-notification.scss
+++ b/plugins/wazuh-check-updates/public/components/updates-notification.scss
@@ -1,11 +1,3 @@
-.euiBody--hasFlyout {
- .wz-check-updates-bottom-bar {
- margin-left: 320px;
- }
-
- &.euiBody-hasOverlayMask {
- .wz-check-updates-bottom-bar {
- margin-left: 0px;
- }
- }
- }
\ No newline at end of file
+.wz-check-updates-bottom-bar {
+ margin-left: 320px;
+}
diff --git a/plugins/wazuh-check-updates/public/components/updates-notification.test.tsx b/plugins/wazuh-check-updates/public/components/updates-notification.test.tsx
index 222db29f1d..20d1ab1683 100644
--- a/plugins/wazuh-check-updates/public/components/updates-notification.test.tsx
+++ b/plugins/wazuh-check-updates/public/components/updates-notification.test.tsx
@@ -27,6 +27,11 @@ jest.mock('../plugin-services', () => ({
},
},
}),
+ getWazuhCore: jest.fn().mockReturnValue({
+ hooks: {
+ useDockedSideNav: () => false,
+ },
+ }),
}));
jest.mock('react-use/lib/useObservable', () => () => {});
diff --git a/plugins/wazuh-check-updates/public/components/updates-notification.tsx b/plugins/wazuh-check-updates/public/components/updates-notification.tsx
index 7c3828302a..e0d2d0e433 100644
--- a/plugins/wazuh-check-updates/public/components/updates-notification.tsx
+++ b/plugins/wazuh-check-updates/public/components/updates-notification.tsx
@@ -11,7 +11,7 @@ import React, { useEffect, useState } from 'react';
import { FormattedMessage, I18nProvider } from '@osd/i18n/react';
import { useUserPreferences } from '../hooks';
import { areThereNewUpdates } from '../utils';
-import { getCore } from '../plugin-services';
+import { getCore, getWazuhCore } from '../plugin-services';
import { AvailableUpdates } from '../../../wazuh-check-updates/common/types';
import { getAvailableUpdates } from '../services';
import { RedirectAppLinks } from '../../../../src/plugins/opensearch_dashboards_react/public';
@@ -22,6 +22,8 @@ export const UpdatesNotification = () => {
const [isDismissed, setIsDismissed] = useState(false);
const [dismissFutureUpdates, setDismissFutureUpdates] = useState(false);
+ const sideNavDocked = getWazuhCore().hooks.useDockedSideNav();
+
const {
userPreferences,
error: userPreferencesError,
@@ -57,7 +59,7 @@ export const UpdatesNotification = () => {
const mustNotifyUser = areThereNewUpdates(
availableUpdates?.apis_available_updates,
- userPreferences.last_dismissed_updates
+ userPreferences.last_dismissed_updates,
);
const handleOnChangeDismiss = (checked: boolean) => {
@@ -67,7 +69,7 @@ export const UpdatesNotification = () => {
const handleOnClose = () => {
updateUserPreferences({
last_dismissed_updates: availableUpdates?.apis_available_updates?.map(
- (apiAvailableUpdates) => {
+ apiAvailableUpdates => {
const {
api_id,
last_available_major,
@@ -80,7 +82,7 @@ export const UpdatesNotification = () => {
last_minor: last_available_minor?.tag,
last_patch: last_available_patch?.tag,
};
- }
+ },
),
...(dismissFutureUpdates ? { hide_update_notifications: true } : {}),
});
@@ -89,29 +91,35 @@ export const UpdatesNotification = () => {
return mustNotifyUser ? (
-
-
+
+
-
+
@@ -119,25 +127,30 @@ export const UpdatesNotification = () => {
-
+
}
checked={dismissFutureUpdates}
- onChange={(e) => handleOnChangeDismiss(e.target.checked)}
+ onChange={e => handleOnChangeDismiss(e.target.checked)}
/>
- handleOnClose()}>
+ handleOnClose()}
+ >
diff --git a/plugins/wazuh-core/public/hooks/index.ts b/plugins/wazuh-core/public/hooks/index.ts
new file mode 100644
index 0000000000..d06d93425c
--- /dev/null
+++ b/plugins/wazuh-core/public/hooks/index.ts
@@ -0,0 +1 @@
+export { useDockedSideNav } from './use-docked-side-nav';
diff --git a/plugins/wazuh-core/public/hooks/use-docked-side-nav.tsx b/plugins/wazuh-core/public/hooks/use-docked-side-nav.tsx
new file mode 100644
index 0000000000..a3c59f08ce
--- /dev/null
+++ b/plugins/wazuh-core/public/hooks/use-docked-side-nav.tsx
@@ -0,0 +1,20 @@
+import { useEffect, useState } from 'react';
+import { getChrome } from '../plugin-services';
+
+export const useDockedSideNav = () => {
+ const [sideNavDocked, setSideNavDocked] = useState(false);
+
+ useEffect(() => {
+ const isNavDrawerSubscription = getChrome()
+ .getIsNavDrawerLocked$()
+ .subscribe((value: boolean) => {
+ setSideNavDocked(value);
+ });
+
+ return () => {
+ isNavDrawerSubscription.unsubscribe();
+ };
+ }, []);
+
+ return sideNavDocked;
+};
diff --git a/plugins/wazuh-core/public/plugin-services.ts b/plugins/wazuh-core/public/plugin-services.ts
index de618c9e18..626d2fbba1 100644
--- a/plugins/wazuh-core/public/plugin-services.ts
+++ b/plugins/wazuh-core/public/plugin-services.ts
@@ -1,5 +1,11 @@
-import { CoreStart, IUiSettingsClient } from 'opensearch-dashboards/public';
+import {
+ ChromeStart,
+ CoreStart,
+ IUiSettingsClient,
+} from 'opensearch-dashboards/public';
import { createGetterSetter } from '../../../src/plugins/opensearch_dashboards_utils/common';
+export const [getChrome, setChrome] = createGetterSetter('Chrome');
export const [getCore, setCore] = createGetterSetter('Core');
-export const [getUiSettings, setUiSettings] = createGetterSetter('UiSettings');
+export const [getUiSettings, setUiSettings] =
+ createGetterSetter('UiSettings');
diff --git a/plugins/wazuh-core/public/plugin.ts b/plugins/wazuh-core/public/plugin.ts
index 8b3078adba..f25ff297fe 100644
--- a/plugins/wazuh-core/public/plugin.ts
+++ b/plugins/wazuh-core/public/plugin.ts
@@ -1,7 +1,8 @@
import { CoreSetup, CoreStart, Plugin } from 'opensearch-dashboards/public';
import { WazuhCorePluginSetup, WazuhCorePluginStart } from './types';
-import { setCore, setUiSettings } from './plugin-services';
+import { setChrome, setCore, setUiSettings } from './plugin-services';
import * as utils from './utils';
+import * as hooks from './hooks';
export class WazuhCorePlugin
implements Plugin
@@ -11,11 +12,13 @@ export class WazuhCorePlugin
}
public start(core: CoreStart): WazuhCorePluginStart {
+ setChrome(core.chrome);
setCore(core);
setUiSettings(core.uiSettings);
return {
utils,
+ hooks,
};
}
diff --git a/plugins/wazuh-core/public/types.ts b/plugins/wazuh-core/public/types.ts
index 28803ab6df..d1865d30ee 100644
--- a/plugins/wazuh-core/public/types.ts
+++ b/plugins/wazuh-core/public/types.ts
@@ -1,6 +1,7 @@
export interface WazuhCorePluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface WazuhCorePluginStart {
+ hooks: { useDockedSideNav: () => boolean };
utils: { formatUIDate: (date: Date) => string };
}