-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into serverless/plugin
- Loading branch information
Showing
90 changed files
with
989 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
[ | ||
"x-pack/plugins/watcher/jest.config.js", | ||
"src/core/server/integration_tests/ui_settings/jest.integration.config.js" | ||
"x-pack/plugins/watcher/jest.config.js" | ||
] |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/core/user-settings/core-user-settings-server-internal/kibana.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/core-user-settings-server-internal", | ||
"owner": "@elastic/platform-security", | ||
"owner": "@elastic/kibana-security", | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/core/user-settings/core-user-settings-server-mocks/kibana.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/core-user-settings-server-mocks", | ||
"owner": "@elastic/platform-security", | ||
"owner": "@elastic/kibana-security", | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/core/user-settings/core-user-settings-server/kibana.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/core-user-settings-server", | ||
"owner": "@elastic/platform-security", | ||
"owner": "@elastic/kibana-security", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { licensingMock } from '@kbn/licensing-plugin/public/mocks'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { useLicense } from './use_license'; | ||
import { AppMockRenderer, createAppMockRenderer } from '../lib/test_utils'; | ||
|
||
let appMockRenderer: AppMockRenderer; | ||
|
||
describe('useLicense', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('isAtLeastPlatinum', () => { | ||
it('returns true on a valid platinum license', () => { | ||
const license = licensingMock.createLicense({ | ||
license: { type: 'platinum' }, | ||
}); | ||
appMockRenderer = createAppMockRenderer({ license }); | ||
|
||
const { result } = renderHook( | ||
() => { | ||
return useLicense(); | ||
}, | ||
{ | ||
wrapper: appMockRenderer.AppWrapper, | ||
} | ||
); | ||
|
||
expect(result.current.isAtLeastPlatinum()).toBeTruthy(); | ||
}); | ||
|
||
it('returns false on a valid gold license', () => { | ||
const license = licensingMock.createLicense({ | ||
license: { type: 'gold' }, | ||
}); | ||
appMockRenderer = createAppMockRenderer({ license }); | ||
|
||
const { result } = renderHook( | ||
() => { | ||
return useLicense(); | ||
}, | ||
{ wrapper: appMockRenderer.AppWrapper } | ||
); | ||
|
||
expect(result.current.isAtLeastPlatinum()).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { ILicense, LicenseType } from '@kbn/licensing-plugin/public'; | ||
import { useCallback } from 'react'; | ||
import useObservable from 'react-use/lib/useObservable'; | ||
import { Observable } from 'rxjs'; | ||
import { useKibana } from '../utils/kibana_react'; | ||
|
||
interface UseLicenseReturnValue { | ||
isAtLeastPlatinum: () => boolean; | ||
} | ||
|
||
export const useLicense = (): UseLicenseReturnValue => { | ||
const { licensing } = useKibana().services; | ||
const license = useObservable<ILicense | null>(licensing?.license$ ?? new Observable(), null); | ||
|
||
const isAtLeast = useCallback( | ||
(level: LicenseType): boolean => { | ||
return !!license && license.isAvailable && license.isActive && license.hasAtLeast(level); | ||
}, | ||
[license] | ||
); | ||
|
||
const isAtLeastPlatinum = useCallback(() => isAtLeast('platinum'), [isAtLeast]); | ||
|
||
return { | ||
isAtLeastPlatinum, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/alerting/public/pages/maintenance_windows/components/license_prompt.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { AppMockRenderer, createAppMockRenderer } from '../../../lib/test_utils'; | ||
import { LicensePrompt } from './license_prompt'; | ||
|
||
describe('LicensePrompt', () => { | ||
let appMockRenderer: AppMockRenderer; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
appMockRenderer = createAppMockRenderer(); | ||
}); | ||
|
||
test('it renders', () => { | ||
const result = appMockRenderer.render(<LicensePrompt />); | ||
|
||
expect(result.getByTestId('license-prompt-title')).toBeInTheDocument(); | ||
expect(result.getByTestId('license-prompt-upgrade')).toBeInTheDocument(); | ||
expect(result.getByTestId('license-prompt-trial')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.