-
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.
Add ILM url generator and use it in Index Management (#82165)
* Add ILM url generator and use in IM for cross linking to policy edit page * Fix policy name in the link * Add review suggestions * Fix import * Fix eslint error Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
94d0e60
commit 71ec5bd
Showing
27 changed files
with
362 additions
and
84 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
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
60 changes: 60 additions & 0 deletions
60
x-pack/plugins/index_lifecycle_management/public/url_generator.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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreSetup } from 'kibana/public'; | ||
import { UrlGeneratorsDefinition } from '../../../../src/plugins/share/public/'; | ||
import { | ||
getPoliciesListPath, | ||
getPolicyCreatePath, | ||
getPolicyEditPath, | ||
} from './application/services/navigation'; | ||
import { MANAGEMENT_APP_ID } from '../../../../src/plugins/management/public'; | ||
import { SetupDependencies } from './types'; | ||
import { PLUGIN } from '../common/constants'; | ||
|
||
export const ILM_URL_GENERATOR_ID = 'ILM_URL_GENERATOR_ID'; | ||
|
||
export interface IlmUrlGeneratorState { | ||
page: 'policies_list' | 'policy_edit' | 'policy_create'; | ||
policyName?: string; | ||
absolute?: boolean; | ||
} | ||
export const createIlmUrlGenerator = ( | ||
getAppBasePath: (absolute?: boolean) => Promise<string> | ||
): UrlGeneratorsDefinition<typeof ILM_URL_GENERATOR_ID> => { | ||
return { | ||
id: ILM_URL_GENERATOR_ID, | ||
createUrl: async (state: IlmUrlGeneratorState): Promise<string> => { | ||
switch (state.page) { | ||
case 'policy_create': { | ||
return `${await getAppBasePath(!!state.absolute)}${getPolicyCreatePath()}`; | ||
} | ||
case 'policy_edit': { | ||
return `${await getAppBasePath(!!state.absolute)}${getPolicyEditPath(state.policyName!)}`; | ||
} | ||
case 'policies_list': { | ||
return `${await getAppBasePath(!!state.absolute)}${getPoliciesListPath()}`; | ||
} | ||
} | ||
}, | ||
}; | ||
}; | ||
|
||
export const registerUrlGenerator = ( | ||
coreSetup: CoreSetup, | ||
management: SetupDependencies['management'], | ||
share: SetupDependencies['share'] | ||
) => { | ||
const getAppBasePath = async (absolute = false) => { | ||
const [coreStart] = await coreSetup.getStartServices(); | ||
return coreStart.application.getUrlForApp(MANAGEMENT_APP_ID, { | ||
path: management.sections.section.data.getApp(PLUGIN.ID)!.basePath, | ||
absolute, | ||
}); | ||
}; | ||
|
||
share.urlGenerators.registerUrlGenerator(createIlmUrlGenerator(getAppBasePath)); | ||
}; |
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.