mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
Add snapshotsUrl to Cloud plugin public interface. (#110328)
* Add unit tests for Cloud plugin setup interface.
This commit is contained in:
parent
f58865c1f5
commit
cf8ab3bb11
4 changed files with 82 additions and 4 deletions
|
@ -30,6 +30,12 @@ This is the path to the Cloud deployment management page for the deployment to w
|
|||
|
||||
**Example:** `{baseUrl}/deployments/bfdad4ef99a24212a06d387593686d63`
|
||||
|
||||
### `snapshotsUrl`
|
||||
|
||||
This is the path to the Snapshots page for the deployment to which the Kibana instance belongs. The value is already prepended with `deploymentUrl`.
|
||||
|
||||
**Example:** `{deploymentUrl}/elasticsearch/snapshots`
|
||||
|
||||
### `profileUrl`
|
||||
|
||||
This is the path to the Cloud User Profile page. The value is already prepended with `baseUrl`.
|
||||
|
|
|
@ -6,3 +6,8 @@
|
|||
*/
|
||||
|
||||
export const ELASTIC_SUPPORT_LINK = 'https://support.elastic.co/';
|
||||
|
||||
/**
|
||||
* This is the page for managing your snapshots on Cloud.
|
||||
*/
|
||||
export const CLOUD_SNAPSHOTS_PATH = 'elasticsearch/snapshots/';
|
||||
|
|
|
@ -141,6 +141,65 @@ describe('Cloud Plugin', () => {
|
|||
expect(initializeFullStoryMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('interface', () => {
|
||||
const setupPlugin = () => {
|
||||
const initContext = coreMock.createPluginInitializerContext({
|
||||
id: 'cloudId',
|
||||
cname: 'cloud.elastic.co',
|
||||
base_url: 'https://cloud.elastic.co',
|
||||
deployment_url: '/abc123',
|
||||
profile_url: '/user/settings/',
|
||||
organization_url: '/account/',
|
||||
});
|
||||
const plugin = new CloudPlugin(initContext);
|
||||
|
||||
const coreSetup = coreMock.createSetup();
|
||||
const setup = plugin.setup(coreSetup, {});
|
||||
|
||||
return { setup };
|
||||
};
|
||||
|
||||
it('exposes isCloudEnabled', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.isCloudEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('exposes cloudId', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.cloudId).toBe('cloudId');
|
||||
});
|
||||
|
||||
it('exposes baseUrl', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.baseUrl).toBe('https://cloud.elastic.co');
|
||||
});
|
||||
|
||||
it('exposes deploymentUrl', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.deploymentUrl).toBe('https://cloud.elastic.co/abc123');
|
||||
});
|
||||
|
||||
it('exposes snapshotsUrl', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.snapshotsUrl).toBe('https://cloud.elastic.co/abc123/elasticsearch/snapshots/');
|
||||
});
|
||||
|
||||
it('exposes profileUrl', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.profileUrl).toBe('https://cloud.elastic.co/user/settings/');
|
||||
});
|
||||
|
||||
it('exposes organizationUrl', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.organizationUrl).toBe('https://cloud.elastic.co/account/');
|
||||
});
|
||||
|
||||
it('exposes cname', () => {
|
||||
const { setup } = setupPlugin();
|
||||
expect(setup.cname).toBe('cloud.elastic.co');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#start', () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
|||
SecurityPluginStart,
|
||||
} from '../../security/public';
|
||||
import { getIsCloudEnabled } from '../common/is_cloud_enabled';
|
||||
import { ELASTIC_SUPPORT_LINK } from '../common/constants';
|
||||
import { ELASTIC_SUPPORT_LINK, CLOUD_SNAPSHOTS_PATH } from '../common/constants';
|
||||
import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
|
||||
import { createUserMenuLinks } from './user_menu_links';
|
||||
import { getFullCloudUrl } from './utils';
|
||||
|
@ -54,6 +54,7 @@ export interface CloudSetup {
|
|||
deploymentUrl?: string;
|
||||
profileUrl?: string;
|
||||
organizationUrl?: string;
|
||||
snapshotsUrl?: string;
|
||||
isCloudEnabled: boolean;
|
||||
}
|
||||
|
||||
|
@ -80,6 +81,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
|
|||
deployment_url: deploymentUrl,
|
||||
base_url: baseUrl,
|
||||
} = this.config;
|
||||
|
||||
this.isCloudEnabled = getIsCloudEnabled(id);
|
||||
|
||||
if (home) {
|
||||
|
@ -89,13 +91,19 @@ export class CloudPlugin implements Plugin<CloudSetup> {
|
|||
}
|
||||
}
|
||||
|
||||
const fullCloudDeploymentUrl = getFullCloudUrl(baseUrl, deploymentUrl);
|
||||
const fullCloudProfileUrl = getFullCloudUrl(baseUrl, profileUrl);
|
||||
const fullCloudOrganizationUrl = getFullCloudUrl(baseUrl, organizationUrl);
|
||||
const fullCloudSnapshotsUrl = `${fullCloudDeploymentUrl}/${CLOUD_SNAPSHOTS_PATH}`;
|
||||
|
||||
return {
|
||||
cloudId: id,
|
||||
cname,
|
||||
baseUrl,
|
||||
deploymentUrl: getFullCloudUrl(baseUrl, deploymentUrl),
|
||||
profileUrl: getFullCloudUrl(baseUrl, profileUrl),
|
||||
organizationUrl: getFullCloudUrl(baseUrl, organizationUrl),
|
||||
deploymentUrl: fullCloudDeploymentUrl,
|
||||
profileUrl: fullCloudProfileUrl,
|
||||
organizationUrl: fullCloudOrganizationUrl,
|
||||
snapshotsUrl: fullCloudSnapshotsUrl,
|
||||
isCloudEnabled: this.isCloudEnabled,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue