Skip to content

Commit

Permalink
Add Wazuh version and links (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Ruiz Becerra <[email protected]>
  • Loading branch information
yenienserrano and AlexRuiz7 committed Jun 9, 2023
1 parent 27e01b6 commit 1097581
Show file tree
Hide file tree
Showing 26 changed files with 119 additions and 16 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"number": 8467,
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
},
"wazuh": {
"version": "4.4.0"
},
"homepage": "https://opensearch.org",
"bugs": {
"url": "http://github.com/opensearch-project/OpenSearch-Dashboards/issues"
Expand Down
8 changes: 8 additions & 0 deletions packages/osd-config/src/__snapshots__/env.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/osd-config/src/config_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const packageInfos: RawPackageInfo = {
number: 42,
sha: 'one',
},
wazuh: {
version: '4.4.0',
},
};
const emptyArgv = getEnvOptions();
const defaultEnv = new Env('/opensearch-dashboards', packageInfos, emptyArgv);
Expand Down Expand Up @@ -270,6 +273,9 @@ test('correctly passes context', async () => {
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.4.0',
},
};

const env = new Env('/opensearch-dashboards', mockPackage, getEnvOptions());
Expand Down
24 changes: 24 additions & 0 deletions packages/osd-config/src/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const packageInfos: RawPackageInfo = {
number: 42,
sha: 'one',
},
wazuh: {
version: '4.4.0',
},
};

beforeEach(() => {
Expand All @@ -52,6 +55,9 @@ test('correctly creates default environment in dev mode when isDevClusterMaster
mockPackage.raw = {
branch: 'some-branch',
version: 'some-version',
wazuh: {
version: '4.x.x',
},
};

const defaultEnv = Env.createDefault(
Expand All @@ -71,6 +77,9 @@ test('correctly creates default environment in dev mode when isDevClusterManager
mockPackage.raw = {
branch: 'some-branch',
version: 'some-version',
wazuh: {
version: '4.x.x',
},
};

const defaultEnv = Env.createDefault(
Expand All @@ -90,6 +99,9 @@ test('correctly creates default environment in dev mode when isDevClusterManager
mockPackage.raw = {
branch: 'some-branch',
version: 'some-version',
wazuh: {
version: '4.x.x',
},
};

const defaultEnv = Env.createDefault(
Expand All @@ -114,6 +126,9 @@ test('correctly creates default environment in prod distributable mode.', () =>
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.x.x',
},
};

const defaultEnv = Env.createDefault(
Expand All @@ -136,6 +151,9 @@ test('correctly creates default environment in prod non-distributable mode.', ()
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.x.x',
},
};

const defaultEnv = Env.createDefault(
Expand All @@ -158,6 +176,9 @@ test('correctly creates default environment if `--env.name` is supplied.', () =>
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.x.x',
},
};

const defaultDevEnv = Env.createDefault(
Expand Down Expand Up @@ -191,6 +212,9 @@ test('correctly creates environment with constructor.', () => {
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.4.0',
},
},
getEnvOptions({
cliArgs: { dev: false },
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export interface RawPackageInfo {
number: number;
sha: string;
};
wazuh: {
version: string;
};
}

export class Env {
Expand Down Expand Up @@ -159,6 +162,7 @@ export class Env {
: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
version: pkg.version,
dist: isOpenSearchDashboardsDistributable,
wazuhVersion: pkg.wazuh.version,
});
}
}
1 change: 1 addition & 0 deletions packages/osd-config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface PackageInfo {
buildNum: number;
buildSha: string;
dist: boolean;
wazuhVersion: string;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ export class ChromeService {
basePath={http.basePath}
breadcrumbs$={breadcrumbs$.pipe(takeUntil(this.stop$))}
customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))}
opensearchDashboardsDocLink={docLinks.links.opensearchDashboards.introduction}
opensearchDashboardsDocLink={docLinks.links.wazuh.index}
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
homeHref={http.basePath.prepend('/app/home')}
isVisible$={this.isVisible$}
opensearchDashboardsVersion={injectedMetadata.getOpenSearchDashboardsVersion()}
opensearchDashboardsVersion={injectedMetadata.getWazuhVersion()}
navLinks$={navLinks.getNavLinks$()}
recentlyAccessed$={recentlyAccessed.get$()}
navControlsLeft$={navControls.getLeft$()}
Expand Down
6 changes: 3 additions & 3 deletions src/core/public/chrome/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
* under the License.
*/

export const OPENSEARCH_DASHBOARDS_ASK_OPENSEARCH_LINK = 'https://forum.opensearch.org/';
export const GITHUB_CREATE_ISSUE_LINK =
'https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose';
export const OPENSEARCH_DASHBOARDS_FEEDBACK_LINK = 'https://wazuh.com/community/join-us-on-slack';
export const OPENSEARCH_DASHBOARDS_ASK_OPENSEARCH_LINK = OPENSEARCH_DASHBOARDS_FEEDBACK_LINK;
export const GITHUB_CREATE_ISSUE_LINK = 'https://github.com/wazuh/wazuh/issues/new/choose';
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/header_help_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {
<EuiButtonEmpty href={opensearchDashboardsDocLink} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuOpenSearchDashboardsDocumentationTitle"
defaultMessage="Documentation"
defaultMessage="Wazuh documentation"
/>
</EuiButtonEmpty>

Expand Down
10 changes: 10 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ export class DocLinksService {
const OPENSEARCH_WEBSITE_DOCS = `${OPENSEARCH_WEBSITE_URL}docs/${DOC_LINK_VERSION}`;
const OPENSEARCH_VERSIONED_DOCS = `${OPENSEARCH_WEBSITE_DOCS}/opensearch/`;
const OPENSEARCH_DASHBOARDS_VERSIONED_DOCS = `${OPENSEARCH_WEBSITE_DOCS}/dashboards/`;
const WAZUH_DOC_VERSION = injectedMetadata.getWazuhDocVersion();
const WAZUH_WEBSITE_DOCS = `https://documentation.wazuh.com/${WAZUH_DOC_VERSION}`;

return deepFreeze({
DOC_LINK_VERSION,
OPENSEARCH_WEBSITE_URL,
WAZUH_DOC_VERSION,
links: {
wazuh: {
index: `${WAZUH_WEBSITE_DOCS}/index.html`,
},
opensearch: {
// https://opensearch.org/docs/latest/opensearch/index/
introduction: `${OPENSEARCH_VERSIONED_DOCS}index/`,
Expand Down Expand Up @@ -616,7 +622,11 @@ export class DocLinksService {
export interface DocLinksStart {
readonly DOC_LINK_VERSION: string;
readonly OPENSEARCH_WEBSITE_URL: string;
readonly WAZUH_DOC_VERSION: string;
readonly links: {
readonly wazuh: {
readonly index: string;
};
readonly opensearch: {
readonly introduction: string;
readonly installation: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const createSetupContractMock = () => {
getOpenSearchDashboardsBuildNumber: jest.fn(),
getBranding: jest.fn(),
getSurvey: jest.fn(),
getWazuhVersion: jest.fn(),
getWazuhDocVersion: jest.fn(),
};
setupContract.getCspConfig.mockReturnValue({ warnLegacyBrowsers: true });
setupContract.getOpenSearchDashboardsVersion.mockReturnValue('opensearchDashboardsVersion');
Expand All @@ -62,6 +64,8 @@ const createSetupContractMock = () => {
},
} as any);
setupContract.getPlugins.mockReturnValue([]);
setupContract.getWazuhVersion.mockReturnValue('4.x.x');
setupContract.getWazuhDocVersion.mockReturnValue('4.x');
return setupContract;
};

Expand Down
11 changes: 11 additions & 0 deletions src/core/public/injected_metadata/injected_metadata_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface InjectedMetadataParams {
version: string;
buildNumber: number;
branch: string;
wazuhVersion: string;
basePath: string;
serverBasePath: string;
category?: AppCategory;
Expand Down Expand Up @@ -151,6 +152,14 @@ export class InjectedMetadataService {
getSurvey: () => {
return this.state.survey;
},

getWazuhVersion: () => {
return this.state.wazuhVersion;
},

getWazuhDocVersion: () => {
return this.state.wazuhVersion.slice(0, 3) || 'current';
},
};
}
}
Expand Down Expand Up @@ -186,6 +195,8 @@ export interface InjectedMetadataSetup {
};
getBranding: () => Branding;
getSurvey: () => string | undefined;
getWazuhVersion: () => string;
getWazuhDocVersion: () => string;
}

/** @internal */
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function pluginInitializerContextMock() {
buildNum: 100,
buildSha: 'buildSha',
dist: false,
wazuhVersion: 'wazuhVersion',
},
},
config: {
Expand All @@ -151,6 +152,7 @@ function createCoreContext(): CoreContext {
buildNum: 100,
buildSha: 'buildSha',
dist: false,
wazuhVersion: 'wazuhVersion',
},
},
};
Expand Down
1 change: 1 addition & 0 deletions src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function pluginInitializerContextMock<T>(config: T = {} as T) {
buildNum: 100,
buildSha: 'buildSha',
dist: false,
wazuhVersion: 'wazuhVersion',
},
instanceUuid: 'instance-uuid',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const packageInfo = {
buildSha: '',
version: '7.0.0-alpha1',
dist: false,
wazuhVersion: '4.0.0',
};

afterEach(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/core/server/plugins/discovery/plugins_discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ const packageMock = {
number: 1,
sha: '',
},
wazuh: {
version: '4.x.x',
},
};

const manifestPath = (...pluginPath: string[]) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ describe('PluginsService', () => {
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.x.x',
},
};

const env = Env.createDefault(REPO_ROOT, getEnvOptions());
Expand Down
3 changes: 3 additions & 0 deletions src/core/server/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ describe('PluginsService', () => {
number: 100,
sha: 'feature-v1-build-sha',
},
wazuh: {
version: '4.x.x',
},
};

coreId = Symbol('core');
Expand Down
Loading

0 comments on commit 1097581

Please sign in to comment.