-
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.
- Loading branch information
1 parent
a6b67c6
commit df0c83f
Showing
24 changed files
with
483 additions
and
48 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
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/file_upload/public/api/index_name_form_async_wrapper.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,43 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiLoadingContent } from '@elastic/eui'; | ||
import { lazyLoadModules } from '../lazy_load_bundle'; | ||
import { IndexNameFormProps } from '../index'; | ||
|
||
interface State { | ||
IndexNameForm: React.ComponentType<IndexNameFormProps> | null; | ||
} | ||
|
||
export class IndexNameFormAsyncWrapper extends React.Component<IndexNameFormProps, State> { | ||
state: State = { | ||
IndexNameForm: null, | ||
}; | ||
|
||
private _isMounted = false; | ||
|
||
componentWillUnmount(): void { | ||
this._isMounted = false; | ||
} | ||
|
||
componentDidMount() { | ||
this._isMounted = true; | ||
lazyLoadModules().then((modules) => { | ||
if (this._isMounted) { | ||
this.setState({ | ||
IndexNameForm: modules.IndexNameForm, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
render() { | ||
const { IndexNameForm } = this.state; | ||
return IndexNameForm ? <IndexNameForm {...this.props} /> : <EuiLoadingContent lines={3} />; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/file_upload/public/api/json_upload_and_parse_async_wrapper.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,48 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiLoadingContent } from '@elastic/eui'; | ||
import { FileUploadComponentProps, lazyLoadModules } from '../lazy_load_bundle'; | ||
|
||
interface State { | ||
JsonUploadAndParse: React.ComponentType<FileUploadComponentProps> | null; | ||
} | ||
|
||
export class JsonUploadAndParseAsyncWrapper extends React.Component< | ||
FileUploadComponentProps, | ||
State | ||
> { | ||
state: State = { | ||
JsonUploadAndParse: null, | ||
}; | ||
private _isMounted = false; | ||
|
||
componentDidMount() { | ||
this._isMounted = true; | ||
lazyLoadModules().then((modules) => { | ||
if (this._isMounted) { | ||
this.setState({ | ||
JsonUploadAndParse: modules.JsonUploadAndParse, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
componentWillUnmount(): void { | ||
this._isMounted = false; | ||
} | ||
|
||
render() { | ||
const { JsonUploadAndParse } = this.state; | ||
return JsonUploadAndParse ? ( | ||
<JsonUploadAndParse {...this.props} /> | ||
) : ( | ||
<EuiLoadingContent lines={3} /> | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
*/ | ||
|
||
export interface CreateDocSourceResp { | ||
indexPatternId?: string; | ||
success: boolean; | ||
error?: Error; | ||
} | ||
|
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
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/maps/public/classes/layers/icons/draw_layer_icon.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,37 @@ | ||
/* | ||
* 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 React, { FunctionComponent } from 'react'; | ||
|
||
export const DrawLayerIcon: FunctionComponent = () => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="49" | ||
height="25" | ||
fill="none" | ||
viewBox="0 0 49 25" | ||
className="mapLayersWizardIcon" | ||
> | ||
<path | ||
className="mapLayersWizardIcon__background" | ||
d="M12.281 3l-6.625 7.625 1.657 8.938 35.218-.813v-13l-10.625-3.5-9.781 9.5L12.281 3z" | ||
/> | ||
<path | ||
className="mapLayersWizardIcon__highlight" | ||
fillRule="evenodd" | ||
d="M31.775 1.68l11.256 3.708v13.85l-36.133.834-1.777-9.593 7.114-8.189 9.875 8.778 9.665-9.388zm.262 1.14l-9.897 9.612-9.813-8.722-6.135 7.06 1.535 8.283 34.304-.792V6.111L32.037 2.82z" | ||
clipRule="evenodd" | ||
/> | ||
<circle cx="7.281" cy="19.5" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="5.656" cy="10.25" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="12.156" cy="3.625" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="22" cy="11.6" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="31.969" cy="2.5" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="42.344" cy="6.125" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
<circle cx="42.344" cy="19" r="2.5" className="mapLayersWizardIcon__highlight" /> | ||
</svg> | ||
); |
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
49 changes: 49 additions & 0 deletions
49
x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/config.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,49 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import { LayerWizard, RenderWizardArguments } from '../../layers/layer_wizard_registry'; | ||
import { NewVectorLayerEditor } from './wizard'; | ||
import { DrawLayerIcon } from '../../layers/icons/draw_layer_icon'; | ||
import { getFileUpload } from '../../../kibana_services'; | ||
import { LAYER_WIZARD_CATEGORY } from '../../../../common'; | ||
|
||
const ADD_VECTOR_DRAWING_LAYER = 'ADD_VECTOR_DRAWING_LAYER'; | ||
|
||
export const newVectorLayerWizardConfig: LayerWizard = { | ||
categories: [LAYER_WIZARD_CATEGORY.ELASTICSEARCH], | ||
description: i18n.translate('xpack.maps.newVectorLayerWizard.description', { | ||
defaultMessage: 'Creates a new empty layer. Use this to add shapes to the map', | ||
}), | ||
disabledReason: i18n.translate('xpack.maps.newVectorLayerWizard.disabledDesc', { | ||
defaultMessage: | ||
'Unable to draw vector shapes, you are missing the Kibana privilege "Index Pattern Management".', | ||
}), | ||
getIsDisabled: async () => { | ||
const hasImportPermission = await getFileUpload().hasImportPermission({ | ||
checkCreateIndexPattern: true, | ||
checkHasManagePipeline: false, | ||
}); | ||
return !hasImportPermission; | ||
}, | ||
icon: DrawLayerIcon, | ||
prerequisiteSteps: [ | ||
{ | ||
id: ADD_VECTOR_DRAWING_LAYER, | ||
label: i18n.translate('xpack.maps.newVectorLayerWizard.indexNewLayer', { | ||
defaultMessage: 'Index new layer', | ||
}), | ||
}, | ||
], | ||
renderWizard: (renderWizardArguments: RenderWizardArguments) => { | ||
return <NewVectorLayerEditor {...renderWizardArguments} />; | ||
}, | ||
title: i18n.translate('xpack.maps.newVectorLayerWizard.title', { | ||
defaultMessage: 'Create new layer', | ||
}), | ||
}; |
27 changes: 27 additions & 0 deletions
27
...ck/plugins/maps/public/classes/layers/new_vector_layer_wizard/create_new_index_pattern.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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getHttp } from '../../../kibana_services'; | ||
import { CreateDocSourceResp, INDEX_SOURCE_API_PATH } from '../../../../common'; | ||
|
||
export const createNewIndexAndPattern = async (indexName: string) => { | ||
return await getHttp().fetch<CreateDocSourceResp>({ | ||
path: `/${INDEX_SOURCE_API_PATH}`, | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
index: indexName, | ||
// Initially set to static mappings | ||
mappings: { | ||
properties: { | ||
coordinates: { | ||
type: 'geo_shape', | ||
}, | ||
}, | ||
}, | ||
}), | ||
}); | ||
}; |
Oops, something went wrong.