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.
- Loading branch information
Showing
26 changed files
with
642 additions
and
11 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
Empty file.
9 changes: 9 additions & 0 deletions
9
packages/core/help-center/core-help-center-browser-internal/index.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,9 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { HelpCenterService } from './src/help_center_service'; |
13 changes: 13 additions & 0 deletions
13
packages/core/help-center/core-help-center-browser-internal/jest.config.js
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,13 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../../..', | ||
roots: ['<rootDir>/packages/core/help-center/core-help-center-browser-internal'], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/core/help-center/core-help-center-browser-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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/core-help-center-browser-internal", | ||
"owner": "@elastic/appex-sharedux" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/core/help-center/core-help-center-browser-internal/package.json
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,6 @@ | ||
{ | ||
"name": "@kbn/core-help-center-browser-internal", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
65 changes: 65 additions & 0 deletions
65
packages/core/help-center/core-help-center-browser-internal/src/help_center_service.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,65 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Subject, BehaviorSubject } from 'rxjs'; | ||
import { shareReplay, takeUntil, map } from 'rxjs'; | ||
import type { HelpCenterSetup, HelpCenterStart } from '@kbn/core-help-center-browser'; | ||
import { HelpTopic } from '@elastic/help-center-common'; | ||
|
||
export class HelpCenterService { | ||
private helpCenterUrl$ = new BehaviorSubject<string | undefined>(undefined); | ||
private helpTopics$ = new BehaviorSubject<Record<string, HelpTopic>>({}); | ||
private version$ = new BehaviorSubject<string | undefined>(undefined); | ||
private stop$ = new Subject<void>(); | ||
|
||
/** | ||
* @public | ||
*/ | ||
public setup(): HelpCenterSetup { | ||
return { | ||
configure: ({ helpCenterUrl, version, helpTopics }) => { | ||
this.helpCenterUrl$.next(helpCenterUrl); | ||
this.version$.next(version); | ||
if (helpTopics && Object.keys(helpTopics).length > 0) { | ||
this.helpTopics$.next(helpTopics); | ||
} | ||
}, | ||
addHelpTopics: (helpTopics) => { | ||
this.helpTopics$.next({ ...this.helpTopics$.value, ...helpTopics }); | ||
}, | ||
hasHelpTopics$: this.helpTopics$.pipe( | ||
takeUntil(this.stop$), | ||
map((cb) => Object.keys(cb).length > 0), | ||
shareReplay(1) | ||
), | ||
}; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
public start(): HelpCenterStart { | ||
if (!this.helpTopics$) { | ||
throw new Error('Setup needs to be called before start'); | ||
} | ||
return { | ||
hasHelpTopics$: this.helpTopics$.pipe( | ||
takeUntil(this.stop$), | ||
map((cb) => Object.keys(cb).length > 0), | ||
shareReplay(1) | ||
), | ||
helpCenterUrl$: this.helpCenterUrl$.pipe(takeUntil(this.stop$), shareReplay(1)), | ||
helpTopics$: this.helpTopics$.pipe(takeUntil(this.stop$), shareReplay(1)), | ||
version$: this.version$.pipe(takeUntil(this.stop$), shareReplay(1)), | ||
}; | ||
} | ||
|
||
public stop() { | ||
this.stop$.next(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/core/help-center/core-help-center-browser-internal/tsconfig.json
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,19 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [] | ||
} |
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,8 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
export type { HelpCenterSetup, HelpCenterStart } from './types'; |
13 changes: 13 additions & 0 deletions
13
packages/core/help-center/core-help-center-browser/jest.config.js
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,13 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test/jest_node', | ||
rootDir: '../../../..', | ||
roots: ['<rootDir>/packages/core/help-center/core-help-center-browser'], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/core/help-center/core-help-center-browser/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/core-help-center-browser", | ||
"owner": "@elastic/appex-sharedux" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/core/help-center/core-help-center-browser/package.json
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,6 @@ | ||
{ | ||
"name": "@kbn/core-help-center-browser", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/core/help-center/core-help-center-browser/tsconfig.json
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,17 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [] | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/core/help-center/core-help-center-browser/types.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,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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Observable } from 'rxjs'; | ||
import { HelpTopic } from '@elastic/help-center-common'; | ||
|
||
export interface HelpCenterStart { | ||
helpTopics$: Observable<Record<string, HelpTopic>>; | ||
hasHelpTopics$: Observable<boolean>; | ||
version$: Observable<string | undefined>; | ||
helpCenterUrl$: Observable<string | undefined>; | ||
} | ||
|
||
export interface HelpCenterSetup { | ||
configure: (config: { | ||
helpCenterUrl: string; | ||
version: string; | ||
helpTopics?: Record<string, HelpTopic>; | ||
}) => void; | ||
addHelpTopics: (helpTopics: Record<string, HelpTopic>) => void; | ||
hasHelpTopics$: Observable<boolean>; | ||
} |
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
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
Oops, something went wrong.