-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Maps] add attribution to layer editor #98328
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3b6358f
[Maps] add attribution to layer editor
nreese 6dda9b9
update sources to getAttributionProvider
nreese dd5821f
remove attribution UI from EMS_XYZ source
nreese c7ea76e
remove attribution UI from WMS source editor
nreese f961662
clean up
nreese b133b97
Merge branch 'master' of github.com:elastic/kibana into attribution
nreese c7da5fb
tslint
nreese 90d84da
AttributionFormRow jest test
nreese 786120d
add migration
nreese 0e42b31
tslint
nreese 79e99db
i18n fixes
nreese de41ef7
attribution
nreese 95525b3
Merge branch 'master' into attribution
kibanamachine 9b6d143
Merge branch 'master' into attribution
kibanamachine 98fda85
Merge branch 'master' into attribution
kibanamachine 3e3f2ab
[Maps] Improving design and a11y for attribution layer settings (#38)
elizabetdev 9f971ec
tslint and i18n fixes
nreese 85c6a4c
update jest snapshots
nreese efc506d
remove placeholder for url
nreese a273046
Merge branch 'master' into attribution
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/maps/common/migrations/move_attribution.test.ts
This file contains hidden or 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,67 @@ | ||
| /* | ||
| * 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 { moveAttribution } from './move_attribution'; | ||
| import { LayerDescriptor } from '../descriptor_types'; | ||
|
|
||
| test('Should handle missing layerListJSON attribute', () => { | ||
| const attributes = { | ||
| title: 'my map', | ||
| }; | ||
| expect(moveAttribution({ attributes })).toEqual({ | ||
| title: 'my map', | ||
| }); | ||
| }); | ||
|
|
||
| test('Should migrate source attribution to layer attribution', () => { | ||
| const layerListJSON = JSON.stringify(([ | ||
| { | ||
| sourceDescriptor: { | ||
| attributionText: 'myLabel', | ||
| attributionUrl: 'myUrl', | ||
| id: 'mySourceId', | ||
| }, | ||
| }, | ||
| ] as unknown) as LayerDescriptor[]); | ||
|
|
||
| const attributes = { | ||
| title: 'my map', | ||
| layerListJSON, | ||
| }; | ||
|
|
||
| const { layerListJSON: migratedLayerListJSON } = moveAttribution({ attributes }); | ||
| const migratedLayerList = JSON.parse(migratedLayerListJSON!); | ||
| expect(migratedLayerList).toEqual([ | ||
| { | ||
| attribution: { label: 'myLabel', url: 'myUrl' }, | ||
| sourceDescriptor: { id: 'mySourceId' }, | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| test('Should not add attribution to layer when source does not provide attribution', () => { | ||
| const layerListJSON = JSON.stringify(([ | ||
| { | ||
| sourceDescriptor: { | ||
| id: 'mySourceId', | ||
| }, | ||
| }, | ||
| ] as unknown) as LayerDescriptor[]); | ||
|
|
||
| const attributes = { | ||
| title: 'my map', | ||
| layerListJSON, | ||
| }; | ||
|
|
||
| const { layerListJSON: migratedLayerListJSON } = moveAttribution({ attributes }); | ||
| const migratedLayerList = JSON.parse(migratedLayerListJSON!); | ||
| expect(migratedLayerList).toEqual([ | ||
| { | ||
| sourceDescriptor: { id: 'mySourceId' }, | ||
| }, | ||
| ]); | ||
| }); |
This file contains hidden or 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,42 @@ | ||
| /* | ||
| * 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 { MapSavedObjectAttributes } from '../map_saved_object_type'; | ||
| import { LayerDescriptor } from '../descriptor_types'; | ||
|
|
||
| // In 7.14, attribution added to the layer_descriptor. Prior to 7.14, 2 sources, WMS and TMS, had attribution on source descriptor. | ||
| export function moveAttribution({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx! |
||
| attributes, | ||
| }: { | ||
| attributes: MapSavedObjectAttributes; | ||
| }): MapSavedObjectAttributes { | ||
| if (!attributes || !attributes.layerListJSON) { | ||
| return attributes; | ||
| } | ||
|
|
||
| const layerList: LayerDescriptor[] = JSON.parse(attributes.layerListJSON); | ||
|
|
||
| layerList.forEach((layer: LayerDescriptor) => { | ||
| const sourceDescriptor = layer.sourceDescriptor as { | ||
| attributionText?: string; | ||
| attributionUrl?: string; | ||
| }; | ||
| if (sourceDescriptor.attributionText && sourceDescriptor.attributionUrl) { | ||
| layer.attribution = { | ||
| label: sourceDescriptor.attributionText, | ||
| url: sourceDescriptor.attributionUrl, | ||
| }; | ||
| delete sourceDescriptor.attributionText; | ||
| delete sourceDescriptor.attributionUrl; | ||
| } | ||
| }); | ||
|
|
||
| return { | ||
| ...attributes, | ||
| layerListJSON: JSON.stringify(layerList), | ||
| }; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.