forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search] [Playground] Adding playground locators (elastic#190606)
Adds locators for the playground app in the enterprise search and search playground plugins. These will be used by the file upload tool to link to Playground after a successful upload. elastic#186956 These locators are not registered in the observability or security serverless projects, and so the file upload plugin will not render the link to Playground. Note to reviewers, I originally attempted to have one common locator class which would be used by both plugins, this turned out to be more trouble due to cross plugin import restrictions, plus I was concerned the increase to the enterprise search bundle would be larger than the size of the duplicated function. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
e8b82ff
commit e4bd1b2
Showing
10 changed files
with
115 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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 { SharePluginSetup } from '@kbn/share-plugin/public'; | ||
|
||
import { | ||
CreateIndexLocatorDefinition, | ||
type CreateIndexLocatorParams, | ||
} from './create_index_locator'; | ||
import { PlaygroundLocatorDefinition, type PlaygroundLocatorParams } from './playground_locator'; | ||
|
||
export function registerLocators(share: SharePluginSetup) { | ||
share.url.locators.create<CreateIndexLocatorParams>(new CreateIndexLocatorDefinition()); | ||
share.url.locators.create<PlaygroundLocatorParams>(new PlaygroundLocatorDefinition()); | ||
} |
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/enterprise_search/common/locators/playground_locator.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,28 @@ | ||
/* | ||
* 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 { LocatorDefinition } from '@kbn/share-plugin/common'; | ||
import type { SerializableRecord } from '@kbn/utility-types'; | ||
|
||
import { APPLICATIONS_PLUGIN, PLAYGROUND_URL } from '../constants'; | ||
|
||
export type PlaygroundLocatorParams = { 'default-index': string } & SerializableRecord; | ||
|
||
export class PlaygroundLocatorDefinition implements LocatorDefinition<PlaygroundLocatorParams> { | ||
public readonly getLocation = async (params: PlaygroundLocatorParams) => { | ||
const defaultIndex = params['default-index']; | ||
const path = `${PLAYGROUND_URL}${defaultIndex ? `?default-index=${defaultIndex}` : ''}`; | ||
|
||
return { | ||
app: APPLICATIONS_PLUGIN.ID, | ||
path, | ||
state: {}, | ||
}; | ||
}; | ||
|
||
public readonly id = 'PLAYGROUND_LOCATOR_ID'; | ||
} |
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,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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { type SharePluginSetup } from '@kbn/share-plugin/public'; | ||
import { PlaygroundLocatorDefinition, type PlaygroundLocatorParams } from './playground_locator'; | ||
|
||
export function registerLocators(share: SharePluginSetup) { | ||
share.url.locators.create<PlaygroundLocatorParams>(new PlaygroundLocatorDefinition()); | ||
} |
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/search_playground/public/locators/playground_locator.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,30 @@ | ||
/* | ||
* 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 { LocatorDefinition } from '@kbn/share-plugin/common'; | ||
import type { SerializableRecord } from '@kbn/utility-types'; | ||
|
||
import { PLUGIN_ID } from '../../common'; | ||
|
||
export type PlaygroundLocatorParams = { 'default-index': string } & SerializableRecord; | ||
|
||
const PLAYGROUND_URL = '/chat'; | ||
|
||
export class PlaygroundLocatorDefinition implements LocatorDefinition<PlaygroundLocatorParams> { | ||
public readonly getLocation = async (params: PlaygroundLocatorParams) => { | ||
const defaultIndex = params['default-index']; | ||
const path = `${PLAYGROUND_URL}${defaultIndex ? `?default-index=${defaultIndex}` : ''}`; | ||
|
||
return { | ||
app: PLUGIN_ID, | ||
path, | ||
state: {}, | ||
}; | ||
}; | ||
|
||
public readonly id = 'PLAYGROUND_LOCATOR_ID'; | ||
} |
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