-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Ingest Pipelines] Add url generator for ingest pipelines app #77872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
858da91
2d065d0
65c5f58
14e92c1
833ecd0
2e94ed2
8173db2
7c63503
52f9396
573c9f2
56fa521
9b3e223
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import { | |
| EuiSpacer, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import { BASE_PATH } from '../../../../common/constants'; | ||
| import { INGEST_PIPELINES_PAGES, URL_GENERATOR } from '../../services/navigation'; | ||
| import { Pipeline } from '../../../../common/types'; | ||
| import { useKibana } from '../../../shared_imports'; | ||
| import { PipelineForm } from '../../components'; | ||
|
|
@@ -50,11 +50,11 @@ export const PipelinesCreate: React.FunctionComponent<RouteComponentProps & Prop | |
| return; | ||
| } | ||
|
|
||
| history.push(BASE_PATH + `?pipeline=${encodeURIComponent(pipeline.name)}`); | ||
| history.push(URL_GENERATOR[INGEST_PIPELINES_PAGES.LIST](pipeline.name)); | ||
|
||
| }; | ||
|
|
||
| const onCancel = () => { | ||
| history.push(BASE_PATH); | ||
| history.push(URL_GENERATOR[INGEST_PIPELINES_PAGES.LIST]()); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| const BASE_PATH = '/'; | ||
|
|
||
| const EDIT_PATH = 'edit'; | ||
|
|
||
| const CREATE_PATH = 'create'; | ||
|
|
||
| const getEditPath = (name: string, encode = true): string => { | ||
| return `${BASE_PATH}${EDIT_PATH}/${encode ? encodeURIComponent(name) : name}`; | ||
| }; | ||
|
|
||
| const getCreatePath = (): string => { | ||
| return `${BASE_PATH}${CREATE_PATH}`; | ||
| }; | ||
|
|
||
| const getClonePath = (name: string, encode = true): string => { | ||
|
||
| return `${BASE_PATH}${CREATE_PATH}/${encode ? encodeURIComponent(name) : name}`; | ||
| }; | ||
| const getListPath = (name?: string): string => { | ||
| return `${BASE_PATH}${name ? `?pipeline=${encodeURIComponent(name)}` : ''}`; | ||
| }; | ||
|
|
||
| export enum INGEST_PIPELINES_PAGES { | ||
| LIST = 'pipelines_list', | ||
| EDIT = 'pipeline_edit', | ||
| CREATE = 'pipeline_create', | ||
| CLONE = 'pipeline_clone', | ||
| } | ||
|
|
||
| export const ROUTES_CONFIG = { | ||
|
||
| [INGEST_PIPELINES_PAGES.LIST]: getListPath(), | ||
| [INGEST_PIPELINES_PAGES.EDIT]: getEditPath(':name', false), | ||
| [INGEST_PIPELINES_PAGES.CREATE]: getCreatePath(), | ||
| [INGEST_PIPELINES_PAGES.CLONE]: getClonePath(':sourceName', false), | ||
| }; | ||
|
|
||
| export const URL_GENERATOR = { | ||
| [INGEST_PIPELINES_PAGES.LIST]: (selectedPipelineName?: string) => | ||
| getListPath(selectedPipelineName), | ||
| [INGEST_PIPELINES_PAGES.EDIT]: (pipelineName: string) => getEditPath(pipelineName, true), | ||
| [INGEST_PIPELINES_PAGES.CREATE]: getCreatePath, | ||
| [INGEST_PIPELINES_PAGES.CLONE]: (pipelineName: string) => getClonePath(pipelineName, true), | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like something the
managementplugin should define inside acommon/constants.tsfile and export in https://github.com/elastic/kibana/blob/master/src/plugins/management/public/index.ts. Since themanagementplugin is already a dependency of this plugin, it seems like it would be straightforward to make that change and consume the constant wherever we need it like this:The only slightly invasive change would be you'd have to update the
managementplugin to consume this constant on this line: https://github.com/elastic/kibana/blob/master/src/plugins/management/public/plugin.ts#L75There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was looking at the management app for an exported constant but couldn't find any. So I added an export, do you know maybe who would be a code owner for this plugin? @cjcenizal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be the Kibana App Arch team.