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

Update sidebar menu and overview app #5928

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
109 changes: 60 additions & 49 deletions plugins/main/public/components/common/welcome/overview-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ const appCategories = Applications.reduce((categories, app) => {
const existingCategory = categories.find(
category => category.label === app.category,
);
if (existingCategory) {
existingCategory.apps.push(app);
} else {
categories.push({
label: app.category,
apps: [app],
});
if (app.showInOverviewApp) {
if (existingCategory) {
existingCategory.apps.push(app);
} else {
categories.push({
label: app.category,
apps: [app],
});
}
}
return categories;
}, []);
}, []).sort((a, b) => {
return (
Categories.find(category => a.label === category.id).order -
Categories.find(category => b.label === category.id).order
);
});

export const OverviewWelcome = compose(
withReduxProvider,
Expand Down Expand Up @@ -122,48 +129,52 @@ export const OverviewWelcome = compose(
<Fragment>
<EuiPage className='wz-welcome-page'>
<EuiFlexGroup gutterSize='l'>
{this.props.agentsCountTotal == 0 && this.addAgent()}
<EuiFlexItem>
<EuiFlexGrid columns={2}>
{appCategories.map(({ label, apps }) => (
<EuiFlexItem key={label}>
<EuiCard
title
description
betaBadgeLabel={
Categories.find(category => category.id === label)
?.label
}
>
<EuiSpacer size='s' />
<EuiFlexGrid columns={2}>
{apps.map(app => (
<EuiFlexItem key={app.id}>
<EuiCard
size='xs'
layout='horizontal'
icon={
<EuiIcon
size='xl'
type={app.euiIconType}
color='primary'
/>
}
className='homSynopsis__card'
title={app.title}
onClick={() => navigateAppURL(`/app/${app.id}`)}
data-test-subj={`overviewWelcome${this.strtools.capitalize(
app.id,
)}`}
description={app.description}
/>
</EuiFlexItem>
))}
</EuiFlexGrid>
</EuiCard>
</EuiFlexItem>
))}
</EuiFlexGrid>
{this.props.agentsCountTotal === 0 && this.addAgent()}
<EuiFlexGroup>
<EuiFlexGrid columns={2}>
{appCategories.map(({ label, apps }) => (
<EuiFlexItem key={label}>
<EuiCard
title
description
betaBadgeLabel={
Categories.find(category => category.id === label)
?.label
}
>
<EuiSpacer size='s' />
<EuiFlexGrid columns={2}>
{apps.map(app => (
<EuiFlexItem key={app.id}>
<EuiCard
size='xs'
layout='horizontal'
icon={
<EuiIcon
size='xl'
type={app.euiIconType}
color='primary'
/>
}
className='homSynopsis__card'
title={app.title}
onClick={() =>
navigateAppURL(`/app/${app.id}`)
}
data-test-subj={`overviewWelcome${this.strtools.capitalize(
app.id,
)}`}
description={app.description}
/>
</EuiFlexItem>
))}
</EuiFlexGrid>
</EuiCard>
</EuiFlexItem>
))}
</EuiFlexGrid>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPage>
Expand Down
76 changes: 3 additions & 73 deletions plugins/main/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,80 +77,10 @@ export class WazuhPlugin
}

if (!response.isWazuhDisabled) {
core.application.register({
id: `wazuh`,
title: 'Wazuh',
icon: core.http.basePath.prepend(
getThemeAssetURL('icon.svg', UI_THEME),
),
mount: async (params: AppMountParameters) => {
try {
setWzMainParams('/overview/');
initializeInterceptor(core);
if (!this.initializeInnerAngular) {
throw Error(
'Wazuh plugin method initializeInnerAngular is undefined',
);
}

// Update redux app state logos with the custom logos
if (logosInitialState?.logos) {
store.dispatch(updateAppConfig(logosInitialState.logos));
}
// hide the telemetry banner.
// Set the flag in the telemetry saved object as the notice was seen and dismissed
this.hideTelemetryBanner && (await this.hideTelemetryBanner());
setScopedHistory(params.history);
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in kibana.json
const [coreStart, depsStart] = await core.getStartServices();
setErrorOrchestrator(ErrorOrchestratorService);
setHttp(core.http);
setCookies(new Cookies());
if (
!AppState.checkCookies() ||
params.history.parentHistory.action === 'PUSH'
) {
window.location.reload();
}
await this.initializeInnerAngular();
params.element.classList.add('dscAppWrapper', 'wz-app');
const unmount = await renderApp(innerAngularName, params.element);
this.stateUpdater.next(() => {
return {
status: response.isWazuhDisabled,
category: {
id: 'wazuh',
label: 'Wazuh',
order: 0,
euiIconType: core.http.basePath.prepend(
getThemeAssetURL('icon.svg', UI_THEME),
),
},
};
});
return () => {
unmount();
unregisterInterceptor();
};
} catch (error) {
console.debug(error);
}
},
category: {
id: 'wazuh',
label: 'Wazuh',
order: 0,
euiIconType: core.http.basePath.prepend(
getThemeAssetURL('icon.svg', UI_THEME),
),
},
updater$: this.stateUpdater,
});

// Register the applications
Applications.forEach(({ category, id, title, redirectTo }) => {
Applications.forEach(app => {
const { category, id, title, description, euiIconType, redirectTo } =
app;
core.application.register({
id,
title,
Expand Down
Loading
Loading