-
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.
* feat: ๐ธ create management app locator * refactor: ๐ก simplify management locator * feat: ๐ธ export management app locator from plugin contract * feat: ๐ธ improve share plugin exports * test: ๐ fix test mock * test: ๐ adjust test mocks * Update src/plugins/management/public/plugin.ts Co-authored-by: Tim Roes <mail@timroes.de> * Update src/plugins/management/public/types.ts Co-authored-by: Tim Roes <mail@timroes.de> * Update src/plugins/management/public/types.ts Co-authored-by: Tim Roes <mail@timroes.de> * Update src/plugins/management/server/plugin.ts Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Tim Roes <mail@timroes.de>
- Loading branch information
1 parent
b60a438
commit fa855b3
Showing
11 changed files
with
150 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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 { MANAGEMENT_APP_ID } from './contants'; | ||
import { ManagementAppLocator, MANAGEMENT_APP_LOCATOR } from './locator'; | ||
|
||
test('locator has the right ID', () => { | ||
const locator = new ManagementAppLocator(); | ||
|
||
expect(locator.id).toBe(MANAGEMENT_APP_LOCATOR); | ||
}); | ||
|
||
test('returns management app ID', async () => { | ||
const locator = new ManagementAppLocator(); | ||
const location = await locator.getLocation({ | ||
sectionId: 'a', | ||
appId: 'b', | ||
}); | ||
|
||
expect(location).toMatchObject({ | ||
app: MANAGEMENT_APP_ID, | ||
}); | ||
}); | ||
|
||
test('returns Kibana location for section ID and app ID pair', async () => { | ||
const locator = new ManagementAppLocator(); | ||
const location = await locator.getLocation({ | ||
sectionId: 'ingest', | ||
appId: 'index', | ||
}); | ||
|
||
expect(location).toMatchObject({ | ||
route: '/ingest/index', | ||
state: {}, | ||
}); | ||
}); | ||
|
||
test('when app ID is not provided, returns path to just the section ID', async () => { | ||
const locator = new ManagementAppLocator(); | ||
const location = await locator.getLocation({ | ||
sectionId: 'data', | ||
}); | ||
|
||
expect(location).toMatchObject({ | ||
route: '/data', | ||
state: {}, | ||
}); | ||
}); |
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,32 @@ | ||
/* | ||
* 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 { SerializableState } from 'src/plugins/kibana_utils/common'; | ||
import { LocatorDefinition } from 'src/plugins/share/common'; | ||
import { MANAGEMENT_APP_ID } from './contants'; | ||
|
||
export const MANAGEMENT_APP_LOCATOR = 'MANAGEMENT_APP_LOCATOR'; | ||
|
||
export interface ManagementAppLocatorParams extends SerializableState { | ||
sectionId: string; | ||
appId?: string; | ||
} | ||
|
||
export class ManagementAppLocator implements LocatorDefinition<ManagementAppLocatorParams> { | ||
public readonly id = MANAGEMENT_APP_LOCATOR; | ||
|
||
public readonly getLocation = async (params: ManagementAppLocatorParams) => { | ||
const route = `/${params.sectionId}${params.appId ? '/' + params.appId : ''}`; | ||
|
||
return { | ||
app: MANAGEMENT_APP_ID, | ||
route, | ||
state: {}, | ||
}; | ||
}; | ||
} |
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
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 { LocatorDefinition, LocatorPublic } from './url_service'; |
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