Skip to content

Commit

Permalink
[FIX] Visualizations are not built due a Types was not set error in a…
Browse files Browse the repository at this point in the history
… production package (#4200)

* fix: fix an error that avoids the visualizations are built correctly in a production package

- fix `Types was not set` error appearing in production package
More information in: #4199 (comment)

* changelog: add PR entry
  • Loading branch information
Desvelao committed Jun 6, 2022
1 parent 05013f5 commit e8c4815
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Replaced the visualization of `Status` panel in `Agents` [#4166](https://github.com/wazuh/wazuh-kibana-app/pull/4166)
- Replaced the visualization of policy in `Modules/Security configuration assessment/Inventory` [#4166](https://github.com/wazuh/wazuh-kibana-app/pull/4166)
- Consistency in the colors and labels used for the agent status [#4166](https://github.com/wazuh/wazuh-kibana-app/pull/4166)
- Consistency in the colors and labels used for the agent status [#4166](https://github.com/wazuh/wazuh-kibana-app/pull/4166) [#4199](https://github.com/wazuh/wazuh-kibana-app/issues/4199)
- Replaced how the full and partial scan dates are displayed in the `Details` panel of `Vulnerabilities/Inventory` [#4169](https://github.com/wazuh/wazuh-kibana-app/pull/4169)

### Fixed
Expand Down
16 changes: 12 additions & 4 deletions public/kibana-integrations/kibana-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { updateMetric } from '../redux/actions/visualizationsActions';
import { GenericRequest } from '../react-services/generic-request';
import { createSavedVisLoader } from './visualizations/saved_visualizations';
import { WzDatePicker } from '../components/wz-date-picker/wz-date-picker';
import { Vis } from '../../../../src/plugins/visualizations/public';
import { PersistedState } from '../../../../src/plugins/visualizations/public';
import {
EuiLoadingChart,
EuiLoadingSpinner,
Expand Down Expand Up @@ -289,9 +289,17 @@ class KibanaVis extends Component {
// that the visualization, for example, doesn't use the defined colors in the `.uiStateJSON` property.
// `createVis` method of Visualizations plugin: https://github.com/elastic/kibana/blob/v7.10.2/src/plugins/visualizations/public/plugin.ts#L207-L211
// `Vis` class constructor: https://github.com/elastic/kibana/blob/v7.10.2/src/plugins/visualizations/public/vis.ts#L99-L104
// This problem is fixed replicating the logic of Visualization plugin's `createVis` method and pass the expected parameters to the `Vis` class constructor.
const vis = new Vis(visState.type, visState);
await vis.setState(visState);
// This problem would be fixed replicating the logic of Visualization plugin's `createVis` method and passing the expected parameters to the `Vis` class constructor
// but there is an error in the generated plugin package in production related to `Types was not set`.
// The remediation is creating the visualization with `.createVis` and set the `.params` and `.uiState` and `.id` properties
// as is done in the `Vis` class constructor https://github.com/elastic/kibana/blob/v7.10.2/src/plugins/visualizations/public/vis.ts#L99-L104
const vis = await getVisualizationsPlugin().createVis(
this.visualization.visState.type,
visState
);
vis.params = vis.getParams(visState.params);
vis.uiState = new PersistedState(visState.uiState);
vis.id = visState.id;

this.visHandler = await getVisualizationsPlugin().__LEGACY.createVisEmbeddableFromObject(
vis,
Expand Down

0 comments on commit e8c4815

Please sign in to comment.