diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 024d76b30b052..9296d540b5d48 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -11,7 +11,7 @@ pageLoadAssetSize: canvas: 15210 cases: 153204 charts: 40269 - cloud: 9300 + cloud: 9676 cloudDataMigration: 5687 cloudExperiments: 103984 cloudFullStory: 4752 diff --git a/src/platform/plugins/shared/navigation/public/plugin.test.ts b/src/platform/plugins/shared/navigation/public/plugin.test.ts index 02f7c7017399f..42623a496bffb 100644 --- a/src/platform/plugins/shared/navigation/public/plugin.test.ts +++ b/src/platform/plugins/shared/navigation/public/plugin.test.ts @@ -193,11 +193,28 @@ describe('Navigation Plugin', () => { } }); - it('should set the feedback button visibility to "false" for deployment in trial', async () => { + it('should set the feedback button visibility to "false" for deployment in trial via endDate', async () => { const { plugin, coreStart, unifiedSearch, cloud: cloudStart, spaces } = setup(); const coreSetup = coreMock.createSetup(); const cloudSetup = cloudMock.createSetup(); - cloudSetup.trialEndDate = new Date(Date.now() + 1000 * 60 * 60 * 24 * 30); // 30 days from now + cloudSetup.isInTrial.mockReturnValue(true); + plugin.setup(coreSetup, { cloud: cloudSetup }); + + for (const solution of ['es', 'oblt', 'security']) { + spaces.getActiveSpace$ = jest + .fn() + .mockReturnValue(of({ solution } as Pick)); + plugin.start(coreStart, { unifiedSearch, cloud: cloudStart, spaces }); + await new Promise((resolve) => setTimeout(resolve)); + expect(coreStart.chrome.sideNav.setIsFeedbackBtnVisible).toHaveBeenCalledWith(false); + coreStart.chrome.sideNav.setIsFeedbackBtnVisible.mockReset(); + } + }); + it('should set the feedback button visibility to "false" for deployment in trial in serverless', async () => { + const { plugin, coreStart, unifiedSearch, cloud: cloudStart, spaces } = setup(); + const coreSetup = coreMock.createSetup(); + const cloudSetup = cloudMock.createSetup(); + cloudSetup.isInTrial.mockReturnValue(true); plugin.setup(coreSetup, { cloud: cloudSetup }); for (const solution of ['es', 'oblt', 'security']) { diff --git a/src/platform/plugins/shared/navigation/public/plugin.tsx b/src/platform/plugins/shared/navigation/public/plugin.tsx index 345567c419e56..5747847b1d3eb 100644 --- a/src/platform/plugins/shared/navigation/public/plugin.tsx +++ b/src/platform/plugins/shared/navigation/public/plugin.tsx @@ -55,10 +55,7 @@ export class NavigationPublicPlugin public setup(core: CoreSetup, deps: NavigationPublicSetupDependencies): NavigationPublicSetup { registerNavigationEventTypes(core); - const cloudTrialEndDate = deps.cloud?.trialEndDate; - if (cloudTrialEndDate) { - this.isCloudTrialUser = cloudTrialEndDate.getTime() > Date.now(); - } + this.isCloudTrialUser = deps.cloud?.isInTrial() ?? false; return { registerMenuItem: this.topNavMenuExtensionsRegistry.register.bind( diff --git a/x-pack/platform/plugins/private/product_intercept/server/plugin.ts b/x-pack/platform/plugins/private/product_intercept/server/plugin.ts index 30e4a5378fd83..a7758027f1590 100644 --- a/x-pack/platform/plugins/private/product_intercept/server/plugin.ts +++ b/x-pack/platform/plugins/private/product_intercept/server/plugin.ts @@ -13,7 +13,7 @@ import { type Logger, } from '@kbn/core/server'; import type { InterceptSetup, InterceptStart } from '@kbn/intercepts-plugin/server'; -import type { CloudSetup } from '@kbn/cloud-plugin/server'; +import type { CloudSetup, CloudStart } from '@kbn/cloud-plugin/server'; import { TRIGGER_DEF_ID, UPGRADE_TRIGGER_DEF_PREFIX_ID, @@ -22,11 +22,12 @@ import { import type { ServerConfigSchema } from '../common/config'; interface ProductInterceptServerPluginSetup { - cloud: CloudSetup; + cloud?: CloudSetup; intercepts: InterceptSetup; } interface ProductInterceptServerPluginStart { + cloud?: CloudStart; intercepts: InterceptStart; } @@ -39,7 +40,6 @@ export class ProductInterceptServerPlugin private readonly logger: Logger; private readonly config: ServerConfigSchema; private readonly buildVersion: string; - private trialEndDate?: Date; constructor(initContext: PluginInitializerContext) { this.logger = initContext.logger.get(); @@ -48,12 +48,10 @@ export class ProductInterceptServerPlugin } setup(core: CoreSetup, { cloud }: ProductInterceptServerPluginSetup) { - this.trialEndDate = cloud?.trialEndDate; - return {}; } - start(core: CoreStart, { intercepts }: ProductInterceptServerPluginStart) { + start(core: CoreStart, { cloud, intercepts }: ProductInterceptServerPluginStart) { if (this.config.enabled) { void intercepts.registerTriggerDefinition?.(TRIGGER_DEF_ID, () => { this.logger.debug('Registering global product intercept trigger definition'); @@ -69,7 +67,7 @@ export class ProductInterceptServerPlugin ); // Register trial intercept only if the trial end date is set and not passed - if (Date.now() <= (this.trialEndDate?.getTime() ?? 0)) { + if (cloud?.isInTrial()) { void intercepts.registerTriggerDefinition?.( `${TRIAL_TRIGGER_DEF_ID}:${this.buildVersion}`, () => { diff --git a/x-pack/platform/plugins/shared/cloud/public/mocks.tsx b/x-pack/platform/plugins/shared/cloud/public/mocks.tsx index b785ab93b6b78..569c56be7cb78 100644 --- a/x-pack/platform/plugins/shared/cloud/public/mocks.tsx +++ b/x-pack/platform/plugins/shared/cloud/public/mocks.tsx @@ -41,6 +41,7 @@ function createSetupMock(): jest.Mocked { }, getUrls: jest.fn().mockReturnValue({}), getPrivilegedUrls: jest.fn().mockResolvedValue({}), + isInTrial: jest.fn().mockReturnValue(false), ...mockCloudUrls, }; } @@ -61,6 +62,7 @@ const createStartMock = (): jest.Mocked => ({ fetchElasticsearchConfig: jest.fn().mockResolvedValue({ elasticsearchUrl: 'elasticsearch-url' }), getUrls: jest.fn().mockReturnValue({}), getPrivilegedUrls: jest.fn().mockResolvedValue({}), + isInTrial: jest.fn().mockReturnValue(false), ...mockCloudUrls, }); diff --git a/x-pack/platform/plugins/shared/cloud/public/plugin.test.ts b/x-pack/platform/plugins/shared/cloud/public/plugin.test.ts index b418f8cb1ee82..930baf0f44db4 100644 --- a/x-pack/platform/plugins/shared/cloud/public/plugin.test.ts +++ b/x-pack/platform/plugins/shared/cloud/public/plugin.test.ts @@ -163,42 +163,83 @@ describe('Cloud Plugin', () => { }); expect(setup.isServerlessEnabled).toBe(false); }); - }); - - it('exposes `serverless.projectId`', () => { - const { setup } = setupPlugin({ - serverless: { - project_id: 'my-awesome-project', - }, + it('exposes `serverless.projectId`', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + }, + }); + expect(setup.serverless.projectId).toBe('my-awesome-project'); }); - expect(setup.serverless.projectId).toBe('my-awesome-project'); - }); - it('exposes `serverless.projectName`', () => { - const { setup } = setupPlugin({ - serverless: { - project_id: 'my-awesome-project', - project_name: 'My Awesome Project', - }, + it('exposes `serverless.projectName`', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + project_name: 'My Awesome Project', + }, + }); + expect(setup.serverless.projectName).toBe('My Awesome Project'); }); - expect(setup.serverless.projectName).toBe('My Awesome Project'); - }); - it('exposes `serverless.projectType`', () => { - const { setup } = setupPlugin({ - serverless: { - project_id: 'my-awesome-project', - project_name: 'My Awesome Project', - project_type: 'security', - }, + it('exposes `serverless.projectType`', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + project_name: 'My Awesome Project', + project_type: 'security', + }, + }); + expect(setup.serverless.projectType).toBe('security'); + }); + describe('exposes isInTrial', () => { + it('is `true` when `serverless.in_trial` is set', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: true, + }, + }); + + expect(setup.isInTrial()).toBe(true); + }); + it('is `false` when `serverless.in_trial` is set to false', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: false, + }, + }); + expect(setup.isInTrial()).toBe(false); + }); }); - expect(setup.serverless.projectType).toBe('security'); }); + it('exposes fetchElasticsearchConfig', async () => { const { setup } = setupPlugin(); const result = await setup.fetchElasticsearchConfig(); expect(result).toEqual({ elasticsearchUrl: 'elasticsearch-url' }); }); + describe('exposes isInTrial', () => { + it('is `true` when `trial_end_date` is set and is in the future', () => { + const { setup } = setupPlugin({ + trial_end_date: new Date(Date.now() + 10000).toISOString(), + }); + + expect(setup.isInTrial()).toBe(true); + }); + it('is `false` when `trial_end_date` is set and is in the past', () => { + const { setup } = setupPlugin({ + trial_end_date: new Date(Date.now() - 10000).toISOString(), + }); + + expect(setup.isInTrial()).toBe(false); + }); + it('is `false` when `serverless.in_trial` & `trial_end_date` are not set', () => { + const { setup } = setupPlugin({}); + expect(setup.isInTrial()).toBe(false); + }); + }); }); }); @@ -300,30 +341,31 @@ describe('Cloud Plugin', () => { const start = plugin.start(coreStart); expect(start.isServerlessEnabled).toBe(false); }); - }); - it('exposes `serverless.projectId`', () => { - const { plugin } = startPlugin({ - serverless: { - project_id: 'my-awesome-project', - }, + it('exposes `serverless.projectId`', () => { + const { plugin } = startPlugin({ + serverless: { + project_id: 'my-awesome-project', + }, + }); + const coreStart = coreMock.createStart(); + const start = plugin.start(coreStart); + expect(start.serverless.projectId).toBe('my-awesome-project'); }); - const coreStart = coreMock.createStart(); - const start = plugin.start(coreStart); - expect(start.serverless.projectId).toBe('my-awesome-project'); - }); - it('exposes `serverless.projectName`', () => { - const { plugin } = startPlugin({ - serverless: { - project_id: 'my-awesome-project', - project_name: 'My Awesome Project', - }, + it('exposes `serverless.projectName`', () => { + const { plugin } = startPlugin({ + serverless: { + project_id: 'my-awesome-project', + project_name: 'My Awesome Project', + }, + }); + const coreStart = coreMock.createStart(); + const start = plugin.start(coreStart); + expect(start.serverless.projectName).toBe('My Awesome Project'); }); - const coreStart = coreMock.createStart(); - const start = plugin.start(coreStart); - expect(start.serverless.projectName).toBe('My Awesome Project'); }); + it('exposes fetchElasticsearchConfig', async () => { const { plugin } = startPlugin(); const coreStart = coreMock.createStart(); @@ -332,5 +374,38 @@ describe('Cloud Plugin', () => { const result = await start.fetchElasticsearchConfig(); expect(result).toEqual({ elasticsearchUrl: 'elasticsearch-url' }); }); + describe('exposes isInTrial', () => { + const getStart = (configParts: Partial = {}) => { + const { plugin } = startPlugin(configParts); + const coreStart = coreMock.createStart(); + coreStart.http.get.mockResolvedValue({ elasticsearch_url: 'elasticsearch-url' }); + return plugin.start(coreStart); + }; + it('is `true` when `trial_end_date` is set and is in the future', () => { + const pluginStart = getStart({ + trial_end_date: new Date(Date.now() + 10000).toISOString(), + }); + + expect(pluginStart.isInTrial()).toBe(true); + }); + it('is `false` when `trial_end_date` is set and is in the past', () => { + const pluginStart = getStart({ + trial_end_date: new Date(Date.now() - 10000).toISOString(), + }); + + expect(pluginStart.isInTrial()).toBe(false); + }); + it('is `false` when `trial_end_date` is not a valid date', () => { + const pluginStart = getStart({ + trial_end_date: 'invalid-date', + }); + + expect(pluginStart.isInTrial()).toBe(false); + }); + it('is `false` when `serverless.in_trial` & `trial_end_date` are not set', () => { + const pluginStart = getStart(); + expect(pluginStart.isInTrial()).toBe(false); + }); + }); }); }); diff --git a/x-pack/platform/plugins/shared/cloud/public/plugin.tsx b/x-pack/platform/plugins/shared/cloud/public/plugin.tsx index ed8a6a975678f..8149bfca33a76 100644 --- a/x-pack/platform/plugins/shared/cloud/public/plugin.tsx +++ b/x-pack/platform/plugins/shared/cloud/public/plugin.tsx @@ -72,13 +72,7 @@ export class CloudPlugin implements Plugin { public setup(core: CoreSetup): CloudSetup { registerCloudDeploymentMetadataAnalyticsContext(core.analytics, this.config); - const { - id, - cname, - trial_end_date: trialEndDate, - is_elastic_staff_owned: isElasticStaffOwned, - csp, - } = this.config; + const { id, cname, is_elastic_staff_owned: isElasticStaffOwned, csp } = this.config; let decodedId: DecodedCloudId | undefined; if (id) { @@ -96,7 +90,7 @@ export class CloudPlugin implements Plugin { csp, cloudHost: decodedId?.host, cloudDefaultPort: decodedId?.defaultPort, - trialEndDate: trialEndDate ? new Date(trialEndDate) : undefined, + trialEndDate: this.config.trial_end_date ? new Date(this.config.trial_end_date) : undefined, isElasticStaffOwned, isCloudEnabled: this.isCloudEnabled, onboarding: { @@ -121,6 +115,7 @@ export class CloudPlugin implements Plugin { ...this.cloudUrls.getUrls(), // TODO: Deprecate directly accessing URLs, use `getUrls` instead getPrivilegedUrls: this.cloudUrls.getPrivilegedUrls.bind(this.cloudUrls), getUrls: this.cloudUrls.getUrls.bind(this.cloudUrls), + isInTrial: this.isInTrial.bind(this), }; } @@ -170,6 +165,7 @@ export class CloudPlugin implements Plugin { ...this.cloudUrls.getUrls(), // TODO: Deprecate directly accessing URLs, use `getUrls` instead getPrivilegedUrls: this.cloudUrls.getPrivilegedUrls.bind(this.cloudUrls), getUrls: this.cloudUrls.getUrls.bind(this.cloudUrls), + isInTrial: this.isInTrial.bind(this), }; } @@ -196,4 +192,17 @@ export class CloudPlugin implements Plugin { }; } } + + private isInTrial(): boolean { + if (this.config.serverless?.in_trial) return true; + if (this.config.trial_end_date) { + const endDateMs = new Date(this.config.trial_end_date).getTime(); + if (!Number.isNaN(endDateMs)) { + return Date.now() <= endDateMs; + } else { + this.logger.error('cloud.trial_end_date config value could not be parsed.'); + } + } + return false; + } } diff --git a/x-pack/platform/plugins/shared/cloud/public/types.ts b/x-pack/platform/plugins/shared/cloud/public/types.ts index 595711a0341d4..bc7e9272a7455 100644 --- a/x-pack/platform/plugins/shared/cloud/public/types.ts +++ b/x-pack/platform/plugins/shared/cloud/public/types.ts @@ -98,6 +98,10 @@ export interface CloudStart extends CloudBasicUrls { * Method to retrieve basic URLs for the Cloud plugin. */ getUrls: () => CloudBasicUrls; + /** + * Method to retrieve if the organization is in trial. + */ + isInTrial: () => boolean; /** * `true` when running on Serverless Elastic Cloud * Note that `isCloudEnabled` will always be true when `isServerlessEnabled` is. @@ -244,6 +248,10 @@ export interface CloudSetup extends CloudBasicUrls { */ organizationInTrial?: boolean; }; + /** + * Method to retrieve if the organization is in trial. + */ + isInTrial: () => boolean; } export interface PublicElasticsearchConfigType { diff --git a/x-pack/platform/plugins/shared/cloud/server/__snapshots__/plugin.test.ts.snap b/x-pack/platform/plugins/shared/cloud/server/__snapshots__/plugin.test.ts.snap index 37f6178469e71..70a7d4d3c46ba 100644 --- a/x-pack/platform/plugins/shared/cloud/server/__snapshots__/plugin.test.ts.snap +++ b/x-pack/platform/plugins/shared/cloud/server/__snapshots__/plugin.test.ts.snap @@ -16,6 +16,7 @@ Object { "instanceSizeMb": undefined, "isCloudEnabled": true, "isElasticStaffOwned": undefined, + "isInTrial": [Function], "isServerlessEnabled": false, "kibanaUrl": undefined, "onboarding": Object { @@ -39,6 +40,7 @@ exports[`Cloud Plugin #start interface snapshot 1`] = ` Object { "baseUrl": "https://cloud.elastic.co", "isCloudEnabled": true, + "isInTrial": [Function], "projectsUrl": "https://cloud.elastic.co/projects/", } `; diff --git a/x-pack/platform/plugins/shared/cloud/server/mocks.ts b/x-pack/platform/plugins/shared/cloud/server/mocks.ts index 6915f43d53538..d4867ae822683 100644 --- a/x-pack/platform/plugins/shared/cloud/server/mocks.ts +++ b/x-pack/platform/plugins/shared/cloud/server/mocks.ts @@ -35,6 +35,7 @@ function createSetupMock(): jest.Mocked { productTier: undefined, orchestratorTarget: undefined, }, + isInTrial: jest.fn().mockReturnValue(false), }; } @@ -43,6 +44,7 @@ function createStartMock(): jest.Mocked { isCloudEnabled: true, projectsUrl: 'projects-url', baseUrl: 'base-url', + isInTrial: jest.fn().mockReturnValue(false), }; } diff --git a/x-pack/platform/plugins/shared/cloud/server/plugin.test.ts b/x-pack/platform/plugins/shared/cloud/server/plugin.test.ts index 598d03dd96256..cd3cf91ba1f0d 100644 --- a/x-pack/platform/plugins/shared/cloud/server/plugin.test.ts +++ b/x-pack/platform/plugins/shared/cloud/server/plugin.test.ts @@ -160,6 +160,45 @@ describe('Cloud Plugin', () => { }); expect(setup.serverless.projectType).toBe('security'); }); + describe('exposes isInTrial', () => { + it('is `true` when `serverless.in_trial` is set', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: true, + }, + }); + + expect(setup.isInTrial()).toBe(true); + }); + it('is `false` when `serverless.in_trial` is set to false', () => { + const { setup } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: false, + }, + }); + expect(setup.isInTrial()).toBe(false); + }); + it('is `true` when `trial_end_date` is set and is in the future', () => { + const { setup } = setupPlugin({ + trial_end_date: new Date(Date.now() + 10000).toISOString(), + }); + + expect(setup.isInTrial()).toBe(true); + }); + it('is `false` when `trial_end_date` is set and is in the past', () => { + const { setup } = setupPlugin({ + trial_end_date: new Date(Date.now() - 10000).toISOString(), + }); + + expect(setup.isInTrial()).toBe(false); + }); + it('is `false` when `serverless.in_trial` & `trial_end_date` are not set', () => { + const { setup } = setupPlugin({}); + expect(setup.isInTrial()).toBe(false); + }); + }); }); }); @@ -173,6 +212,53 @@ describe('Cloud Plugin', () => { const { start } = setupPlugin(); expect(start.isCloudEnabled).toBe(true); }); + + describe('exposes isInTrial', () => { + it('is `true` when `serverless.in_trial` is set', () => { + const { start } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: true, + }, + }); + + expect(start.isInTrial()).toBe(true); + }); + it('is `false` when `serverless.in_trial` is set to false', () => { + const { start } = setupPlugin({ + serverless: { + project_id: 'my-awesome-project', + in_trial: false, + }, + }); + expect(start.isInTrial()).toBe(false); + }); + it('is `true` when `trial_end_date` is set and is in the future', () => { + const { start } = setupPlugin({ + trial_end_date: new Date(Date.now() + 10000).toISOString(), + }); + + expect(start.isInTrial()).toBe(true); + }); + it('is `false` when `trial_end_date` is set and is in the past', () => { + const { start } = setupPlugin({ + trial_end_date: new Date(Date.now() - 10000).toISOString(), + }); + + expect(start.isInTrial()).toBe(false); + }); + it('is `false` when `trial_end_date` is not a valid date', () => { + const { start } = setupPlugin({ + trial_end_date: 'invalid-date', + }); + + expect(start.isInTrial()).toBe(false); + }); + it('is `false` when `serverless.in_trial` & `trial_end_date` are not set', () => { + const { start } = setupPlugin({}); + expect(start.isInTrial()).toBe(false); + }); + }); }); }); }); diff --git a/x-pack/platform/plugins/shared/cloud/server/plugin.ts b/x-pack/platform/plugins/shared/cloud/server/plugin.ts index 557091f81174b..d4495cc19c396 100644 --- a/x-pack/platform/plugins/shared/cloud/server/plugin.ts +++ b/x-pack/platform/plugins/shared/cloud/server/plugin.ts @@ -166,6 +166,10 @@ export interface CloudSetup { */ organizationInTrial?: boolean; }; + /** + * Method to retrieve if the organization is in trial. + */ + isInTrial: () => boolean; } /** @@ -188,15 +192,23 @@ export interface CloudStart { * @example `https://cloud.elastic.co` (on the ESS production environment) */ baseUrl?: string; + /** + * Method to retrieve if the organization is in trial. + */ + isInTrial: () => boolean; } export class CloudPlugin implements Plugin { private readonly config: CloudConfigType; private readonly logger: Logger; + private readonly trialEndDate: Date | undefined; constructor(private readonly context: PluginInitializerContext) { this.config = this.context.config.get(); this.logger = this.context.logger.get(); + this.trialEndDate = this.config.trial_end_date + ? new Date(this.config.trial_end_date) + : undefined; } public setup(core: CoreSetup, { usageCollection }: PluginsSetup): CloudSetup { @@ -364,7 +376,7 @@ export class CloudPlugin implements Plugin { cloudHost: decodedId?.host, cloudDefaultPort: decodedId?.defaultPort, isCloudEnabled, - trialEndDate: this.config.trial_end_date ? new Date(this.config.trial_end_date) : undefined, + trialEndDate: this.trialEndDate, isElasticStaffOwned: this.config.is_elastic_staff_owned, apm: { url: this.config.apm?.url, @@ -385,6 +397,7 @@ export class CloudPlugin implements Plugin { productTier, organizationInTrial: this.config.serverless?.in_trial, }, + isInTrial: this.isInTrial.bind(this), }; } @@ -392,6 +405,7 @@ export class CloudPlugin implements Plugin { return { ...this.getCloudUrls(), isCloudEnabled: getIsCloudEnabled(this.config.id), + isInTrial: this.isInTrial.bind(this), }; } @@ -403,4 +417,19 @@ export class CloudPlugin implements Plugin { projectsUrl, }; } + + private isInTrial(): boolean { + if (this.config.serverless?.in_trial) return true; + if (this.trialEndDate !== undefined) { + if (this.config.trial_end_date) { + const endDateMs = this.trialEndDate.getTime(); + if (!Number.isNaN(endDateMs)) { + return Date.now() <= endDateMs; + } else { + this.logger.error('cloud.trial_end_date config value could not be parsed.'); + } + } + } + return false; + } } diff --git a/x-pack/platform/plugins/shared/fleet/.storybook/context/cloud.ts b/x-pack/platform/plugins/shared/fleet/.storybook/context/cloud.ts index 767ce29f72da5..cbb80603700bc 100644 --- a/x-pack/platform/plugins/shared/fleet/.storybook/context/cloud.ts +++ b/x-pack/platform/plugins/shared/fleet/.storybook/context/cloud.ts @@ -32,6 +32,7 @@ export const getCloud = ({ isCloudEnabled }: { isCloudEnabled: boolean }) => { ...cloudBasicUrls({ isCloudEnabled }), getUrls: () => cloudBasicUrls({ isCloudEnabled }), getPrivilegedUrls: () => Promise.resolve({}), + isInTrial: () => false, }; return cloud; diff --git a/x-pack/platform/plugins/shared/fleet/server/services/preconfiguration/fleet_server_host.test.ts b/x-pack/platform/plugins/shared/fleet/server/services/preconfiguration/fleet_server_host.test.ts index 905bb71426c36..dea62b940e030 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/preconfiguration/fleet_server_host.test.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/preconfiguration/fleet_server_host.test.ts @@ -274,6 +274,7 @@ describe('getCloudFleetServersHosts', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); expect(getCloudFleetServersHosts()).toBeUndefined(); @@ -292,6 +293,7 @@ describe('getCloudFleetServersHosts', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); expect(getCloudFleetServersHosts()).toMatchInlineSnapshot(` @@ -315,6 +317,7 @@ describe('getCloudFleetServersHosts', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); expect(getCloudFleetServersHosts()).toMatchInlineSnapshot(` @@ -356,6 +359,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: true }, @@ -402,6 +406,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: false }, @@ -450,6 +455,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: true }, @@ -482,6 +488,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: true }, @@ -513,6 +520,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: undefined, }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: false }, @@ -544,6 +552,7 @@ describe('createCloudFleetServerHostsIfNeeded', () => { serverless: { projectId: 'project-123', }, + isInTrial: () => false, }); mockedAppContextService.getConfig.mockReturnValue({ agentless: { enabled: true }, diff --git a/x-pack/platform/plugins/shared/ml/server/routes/system.ts b/x-pack/platform/plugins/shared/ml/server/routes/system.ts index 0f90811fe15af..6f3a16c307712 100644 --- a/x-pack/platform/plugins/shared/ml/server/routes/system.ts +++ b/x-pack/platform/plugins/shared/ml/server/routes/system.ts @@ -183,7 +183,7 @@ export function systemRoutes( try { const body = await mlClient.info(); const cloudId = cloud?.cloudId; - const isCloudTrial = cloud?.trialEndDate && Date.now() < cloud.trialEndDate.getTime(); + const isCloudTrial = cloud?.isInTrial() ?? false; let isMlAutoscalingEnabled = false; try {