Skip to content

Commit

Permalink
Change message for API version mismatch in Kibana (#4529)
Browse files Browse the repository at this point in the history
* Modified the message to be clearer, removed <a>

* Added function to add <a> to urls in errors

* changed structure

* Fixed error on function

* Add PLUGIN_APP_NAME constant to match wzd

* Change error message to match structure of wzd

* Improve addTagsToUrl

* Add change to changelog

* Change structure

* Update CHANGELOG.md

* Improve message

Co-authored-by: Álex <[email protected]>
  • Loading branch information
Tostti and AlexRuiz7 authored Sep 26, 2022
1 parent 74600f0 commit 28370ee
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Improved alerts summary performance [#4376](https:/wazuh/wazuh-kibana-app/pull/4376)
- The endpoint `/agents/summary/status` response was adapted. [#3874](https:/wazuh/wazuh-kibana-app/pull/3874)
- Made Agents Overview icons load independently [#4363](https:/wazuh/wazuh-kibana-app/pull/4363)
- Improved the message displayed when there is a versions mismatch between the Wazuh API and the Wazuh APP [#4529](https:/wazuh/wazuh-kibana-app/pull/4529)

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ export const PLUGIN_PLATFORM_REQUEST_HEADERS = {
'kbn-xsrf': 'kibana'
};

// Plugin app
export const PLUGIN_APP_NAME = 'Wazuh App';

// UI
export const API_NAME_AGENT_STATUS = {
ACTIVE: 'active',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,36 @@ function HealthCheckComponent() {
);
});
};

const addTagsToUrl = (error) => {
const words = error.split(' ');
words.forEach((word, index) => {
if (word.includes('http://') || word.includes('https://')) {
if (words[index - 1] === 'guide:') {
if (word.endsWith('.') || word.endsWith(',')) {
words[index - 2] = `<a href="${word.slice(0, -1)}" target="_blank">${words[index - 2]} ${words[index - 1].slice(0, -1)}</a>${word.slice(-1)}`;
} else {
words[index - 2] = `<a href="${word}" target="_blank">${words[index - 2]} ${words[index - 1].slice(0, -1)}</a> `;
}
words.splice(index - 1, 2);
} else{
if (word.endsWith('.') || word.endsWith(',')) {
words[index] = `<a href="${word.slice(0, -1)}" target="_blank">${word.slice(0, -1)}</a>${word.slice(-1)}`;
} else {
words[index] = `<a href="${word}" target="_blank">${word}</a>`;
}
}
}
});
return words.join(' ');
};

const renderErrors = () => {
return Object.keys(checkErrors).map((checkID) =>
checkErrors[checkID].map((error, index) => (
<Fragment key={index}>
<EuiCallOut
title={(<>{`[${checks[checkID].label}]`} <span dangerouslySetInnerHTML={{__html: error}}></span></>)}
title={(<>{`[${checks[checkID].label}]`} <span dangerouslySetInnerHTML={{__html: addTagsToUrl(error)}}></span></>)}
color="danger"
iconType="alert"
style={{ textAlign: 'left' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { AppState, GenericRequest, WzRequest } from '../../../react-services';
import { CheckLogger } from '../types/check_logger';
import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_UPGRADE_PLATFORM } from '../../../../common/constants';
import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING, PLUGIN_APP_NAME } from '../../../../common/constants';
import { webDocumentationLink } from '../../../../common/services/web_documentation';

export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => {
Expand Down Expand Up @@ -44,7 +44,7 @@ export const checkSetupService = appInfo => async (checkLogger: CheckLogger) =>
api.groups.version !== appSplit[0] ||
api.groups.minor !== appSplit[1]
) {
checkLogger.error(`Wazuh API and Wazuh App version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. At least, major and minor should match. Check more info about upgrading Wazuh App <a target='_blank' href='${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_UPGRADE_PLATFORM)}'>here</a>.`);
checkLogger.error(`Wazuh API and ${PLUGIN_APP_NAME} version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Read more about this error in our troubleshooting guide: ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`);
}
}
}
Expand Down

0 comments on commit 28370ee

Please sign in to comment.