-
Notifications
You must be signed in to change notification settings - Fork 60
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
Propose and evaluate different designs #93
Comments
SummaryObjectiveA first proposal of how to organize the navigation drawer entries could be the following:
Design proposalsThere are multiple choices we can make to implement this:
Multi-app pluginWe can register the monolith modules into the global navigation drawer. This is, register the current app several times with different entry points (modules) and categories. Pros
Cons
Modularization of the monolithWe could split the current monolith app into several plugins. Pros
Cons
Router pluginWe could create a new plugin that would manage all the redirections to the monolith plugin (routing). Pros
Cons
ConclusionAfter evaluating these 3 proposals, we think that proposal nr.1 .- Multi-app plugin. Although we are aware that this solution is suboptimal, as it drags and adds to the technical debt, we think this is the most achievable approach right now, as it is the simplest one and has the lowest risks. Also, this means a first step towards the modularization of the app, which is our final goal. |
TL;DRResearchPerformed by @Desvelao Research viability of the router plugin designThe platform menu displays all the registered and visible applications. A plugin can register any number of applications in the platform menu. The app registration needs to define what will be rendered when the user accesses the menu. This means that if we do a plugin to register all the applications, then it must have access to the render methods of them. The rendering method can come from other plugins or itself. If they come from other plugins, this creates more dependency between these plugins. The menu as a standalone plugin can need more logic than if each plugin manages the application registration. I think that @asteriscos was working in a POC to register multiple applications. It would be interesting to know what approach followed. Adding multiple applications breaks some features related to:
Other problems related to the proposition:
Originally posted by @Desvelao in #83 (comment) Research viability of the modularization of the monolith designThe current plugin is a monolith and this can generate multiple problems if we want to decouple into different applications if this architecture is kept as mentioned ones:
Health check page redirections.This is a page that does some checks and creates or updates some elements that are needed to work the plugin. Each route of the current plugin can do some checks. If some of them fail, then a redirection to the health check page will be done. This means we should decide how to accommodate the health check in the different applications. It could be a different application or a route in each future application if we want to keep the current logic. The AngularJS routing problemsThe current plugin uses AngularJS as base, despite part of the application being migrated to ReactJS. The routing is done with AngularJS. The embedded Discover URLsThe Originally posted by @Desvelao in #83 (comment) Research viability of the multi-app design@asteriscos and I were researching how to create the applications in the side menu, and clicking on them redirects to them. This approach does the new applications redirect to the monolith plugin when the link in the side menu is clicked on. The monolith plugin should be hidden. Pros:
Cons:
Problems
ScreenshotsImplementationCreate the application that redirects to the monolith application: core.application.register({
id,
title,
mount: async (params: AppMountParameters) => {
window.location.href = href; // e.g.: /app/wazuh#/agents
},
category,
}); Hide the monolith application: import {
AppNavLinkStatus,
} from '../../../src/core/public';
core.application.register({
id: `wazuh`,
title: 'Wazuh',
navLinkStatus: AppNavLinkStatus.hidden,
// rest of properties
}) Add applications to base import { DEFAULT_APP_CATEGORIES,} from '../../../src/core/public';
core.application.register({
id,
title,
mount: async (params: AppMountParameters) => {
window.location.href = href;
},
category: DEFAULT_APP_CATEGORIES.management,
}) Change the routes dynamically: // public/services/routes.ts
const redirectTo: getApplicationRedirectTo()
// router definition
.when('/', {
redirectTo,
outerAngularWrapperRoute: true,
})
.when('', {
redirectTo,
outerAngularWrapperRoute: true,
})
.otherwise({
redirectTo,
outerAngularWrapperRoute: true,
}); getRootRedirectTo is a getter. Use a setter when the application is mounted in the // public/plugin.ts
mount: (params){
setApplicationRedirectTo(redirectToRoot);
// rest of logic
} Create the getter/setter: // public/kibana_services.js
export const [getApplicationRedirectTo, setApplicationRedirectTo] =
createGetterSetter<any>('WzApplicationRedirectTo'); I was testing this trying to keep the shared state of the selected agent that is stored in Redux store. When I change from a Wazuh application to another one, despite the agentId parameter being added to the URL, it disappears due to the page being refreshed https://github.com/wazuh/wazuh-kibana-app/blob/4.6.0/plugins/main/public/plugin.ts#L96
Reloading the page is used in other situations. So, fixing is not easy because the Redux store is kept, and the page can't be refreshed. Both situations are mutually exclusive. If we need to want to use the Redux store to share critical state, then it seems the page should not be refreshed. As the user can refresh manually the page, this could cause some problems, so it seems these states should be managed in another way, such as local storage/session storage or URL. Update 2023/08/21 // plugins/main/public/redux/reducers/appStateReducers.js
const initialState = {
currentAPI: '',
showMenu: false,
wazuhNotReadyYet: '',
currentTab: '',
extensions: {},
selected_settings_section: '',
currentPlatform: false,
currentAgentData: JSON.parse(
window.sessionStorage.getItem('wz-shared-selected-agent') || '{}',
),
showExploreAgentModal: false,
showExploreAgentModalGlobal: false,
userPermissions: false,
userRoles: [],
toastNotification: false,
withUserLogged: false,
allowedAgents: [],
logtestToken: '',
};
// ....
if (action.type === 'UPDATE_SELECTED_AGENT_DATA') {
window.sessionStorage.setItem(
'wz-shared-selected-agent',
JSON.stringify(action.currentAgentData),
);
return {
...state,
currentAgentData: action.currentAgentData,
};
} Originally posted by @Desvelao in #83 (comment) Originally posted by @Desvelao in #83 (comment) |
Description
The first step of #83 is to generate and evaluate different designs to integrate our modules into the platform menu.
Tasks
The text was updated successfully, but these errors were encountered: