forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Search][Fix] Inference Endpoints deep link & Side Nav acce…
…ss (elastic#197461) (elastic#197547) # Backport This will backport the following commits from `main` to `8.x`: - [[Search][Fix] Inference Endpoints deep link & Side Nav access (elastic#197461)](elastic#197461) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rodney Norris","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-23T23:44:23Z","message":"[Search][Fix] Inference Endpoints deep link & Side Nav access (elastic#197461)","sha":"a124493b8c5aa1dc71c4cf8f2caf134c4355987f","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:prev-major","v8.16.0","v8.17.0"],"title":"[Search][Fix] Inference Endpoints deep link & Side Nav access","number":197461,"url":"https://github.com/elastic/kibana/pull/197461","mergeCommit":{"message":"[Search][Fix] Inference Endpoints deep link & Side Nav access (elastic#197461)","sha":"a124493b8c5aa1dc71c4cf8f2caf134c4355987f"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197461","number":197461,"mergeCommit":{"message":"[Search][Fix] Inference Endpoints deep link & Side Nav access (elastic#197461)","sha":"a124493b8c5aa1dc71c4cf8f2caf134c4355987f"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rodney Norris <[email protected]>
- Loading branch information
1 parent
19590f9
commit 324b7bf
Showing
9 changed files
with
151 additions
and
23 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
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
96 changes: 96 additions & 0 deletions
96
x-pack/plugins/enterprise_search/common/utils/licensing.test.ts
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,96 @@ | ||
/* | ||
* 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 } from '@kbn/licensing-plugin/public'; | ||
|
||
import { hasEnterpriseLicense } from './licensing'; | ||
|
||
describe('licensing utils', () => { | ||
const baseLicense: ILicense = { | ||
isActive: true, | ||
type: 'trial', | ||
isAvailable: true, | ||
signature: 'fake', | ||
toJSON: jest.fn(), | ||
getUnavailableReason: jest.fn().mockReturnValue(undefined), | ||
hasAtLeast: jest.fn().mockReturnValue(false), | ||
check: jest.fn().mockReturnValue({ state: 'valid' }), | ||
getFeature: jest.fn().mockReturnValue({ isAvailable: false, isEnabled: false }), | ||
}; | ||
describe('hasEnterpriseLicense', () => { | ||
let license: ILicense; | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
license = { | ||
...baseLicense, | ||
}; | ||
}); | ||
it('returns true for active enterprise license', () => { | ||
license.type = 'enterprise'; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(true); | ||
}); | ||
it('returns true for active trial license', () => { | ||
expect(hasEnterpriseLicense(license)).toEqual(true); | ||
}); | ||
it('returns false for active basic license', () => { | ||
license.type = 'basic'; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for active gold license', () => { | ||
license.type = 'gold'; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for active platinum license', () => { | ||
license.type = 'platinum'; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for inactive enterprise license', () => { | ||
license.type = 'enterprise'; | ||
license.isActive = false; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for inactive trial license', () => { | ||
license.isActive = false; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for inactive basic license', () => { | ||
license.type = 'basic'; | ||
license.isActive = false; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for inactive gold license', () => { | ||
license.type = 'gold'; | ||
license.isActive = false; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for inactive platinum license', () => { | ||
license.type = 'platinum'; | ||
license.isActive = false; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for active license is missing type', () => { | ||
delete license.type; | ||
|
||
expect(hasEnterpriseLicense(license)).toEqual(false); | ||
}); | ||
it('returns false for null license', () => { | ||
expect(hasEnterpriseLicense(null)).toEqual(false); | ||
}); | ||
it('returns false for undefined license', () => { | ||
expect(hasEnterpriseLicense(undefined)).toEqual(false); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/enterprise_search/common/utils/licensing.ts
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,16 @@ | ||
/* | ||
* 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 } from '@kbn/licensing-plugin/public'; | ||
|
||
/* hasEnterpriseLicense return if the given license is an active `enterprise` or `trial` license | ||
*/ | ||
export function hasEnterpriseLicense(license: ILicense | null | undefined): boolean { | ||
if (license === undefined || license === null) return false; | ||
const qualifyingLicenses = ['enterprise', 'trial']; | ||
return license.isActive && qualifyingLicenses.includes(license?.type ?? ''); | ||
} |
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