Skip to content

Commit bffbe2f

Browse files
refactor: update getApps and renderApp to utilize ApplicationService for layout management
1 parent f44aec7 commit bffbe2f

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

plugins/wazuh-analysis/README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Here’s a step-by-step guide on how to **create a new plugin** with **groups an
2626
│ │ │ │── 📄 `constants.ts` _(Defines the group ID, title, and description)_
2727
│ │ │ │── 📄 `index.ts` _(Registers the group and navigation details)_
2828
│ │── 📄 `category.ts` _(Defines categories for grouping apps in UI)_
29-
│ │── 📄 `layout.tsx` _(Handles UI layout and sidebar navigation)_
3029
```
3130

3231
---
@@ -109,8 +108,11 @@ export const NetworkSecurityNavGroup: Group<typeof NETWORK_SECURITY_ID> = {
109108
}));
110109
},
111110

112-
getApps(updater$?: Subject<AppUpdater>): App[] {
113-
return getNetworkSecurityApps(updater$);
111+
getApps(
112+
applicationService: ApplicationService,
113+
updater$: Subject<AppUpdater>,
114+
): App[] {
115+
return getNetworkSecurityApps(applicationService, updater$);
114116
},
115117
};
116118
```
@@ -168,14 +170,12 @@ import { NETWORK_SECURITY_TITLE } from '../../constants';
168170
import { FirewallMonitoringApp } from './firewall-monitoring-app';
169171
import { FIREWALL_MONITORING_ID } from './constants';
170172

171-
export const renderApp = async (params: AppMountParameters) => {
172-
const items = createSideNavItems({
173-
group: NetworkSecurityNavGroup,
174-
selectedAppId: FIREWALL_MONITORING_ID,
175-
});
176-
173+
export const renderApp = async (
174+
params: AppMountParameters,
175+
{ Layout }: AppProps,
176+
) => {
177177
ReactDOM.render(
178-
<Layout aria-label={NETWORK_SECURITY_TITLE} items={items}>
178+
<Layout>
179179
<FirewallMonitoringApp params={params} />
180180
</Layout>,
181181
params.element,
@@ -199,12 +199,21 @@ import {
199199
AppNavLinkStatus,
200200
AppUpdater,
201201
} from '../../../../../src/core/public';
202+
import { ApplicationService } from '../../../../wazuh-core/public/services/application/application';
202203
import {
203204
FIREWALL_MONITORING_ID,
204205
FIREWALL_MONITORING_TITLE,
205206
} from './apps/firewall-monitoring/constants';
207+
import { NetworkSecurityNavGroup } from '.';
208+
209+
export function getNetworkSecurityApps(
210+
applicationService?: ApplicationService,
211+
updater$?: Subject<AppUpdater>,
212+
): App[] {
213+
const networkSecurityLayout = applicationService?.createLayout(
214+
NetworkSecurityNavGroup,
215+
);
206216

207-
export function getNetworkSecurityApps(updater$?: Subject<AppUpdater>): App[] {
208217
return [
209218
{
210219
id: FIREWALL_MONITORING_ID,
@@ -215,7 +224,10 @@ export function getNetworkSecurityApps(updater$?: Subject<AppUpdater>): App[] {
215224
const { renderApp } = await import(
216225
'./apps/firewall-monitoring/application'
217226
);
218-
return await renderApp(params);
227+
228+
return await renderApp(params, {
229+
Layout: networkSecurityLayout!(FIREWALL_MONITORING_ID),
230+
});
219231
},
220232
},
221233
];

0 commit comments

Comments
 (0)