-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
There are no files selected for viewing
This CODEOWNERS file contains errors …
CODEOWNERS errors
-
Unknown owner on line 6: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/x-pack/plugins/lens/ @elastic/kibana-app
-
Unknown owner on line 7: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/x-pack/plugins/graph/ @elastic/kibana-app
-
Unknown owner on line 8: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…legacy/server/url_shortening/ @elastic/kibana-app
-
Unknown owner on line 9: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…rc/legacy/server/sample_data/ @elastic/kibana-app
-
Unknown owner on line 10: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…gins/kibana/public/dashboard/ @elastic/kibana-app
-
Unknown owner on line 11: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…ugins/kibana/public/discover/ @elastic/kibana-app
-
Unknown owner on line 12: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…ic/local_application_service/ @elastic/kibana-app
-
Unknown owner on line 13: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…gins/kibana/public/dev_tools/ @elastic/kibana-app
-
Unknown owner on line 14: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…core_plugins/vis_type_vislib/ @elastic/kibana-app
-
Unknown owner on line 15: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/vis_type_xy/ @elastic/kibana-app
-
Unknown owner on line 16: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/vis_type_table/ @elastic/kibana-app
-
Unknown owner on line 17: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/kibana_legacy/ @elastic/kibana-app
-
Unknown owner on line 18: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…rc/plugins/vis_type_timelion/ @elastic/kibana-app
-
Unknown owner on line 19: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/dashboard/ @elastic/kibana-app
-
Unknown owner on line 20: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/discover/ @elastic/kibana-app
-
Unknown owner on line 21: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…rc/plugins/input_control_vis/ @elastic/kibana-app
-
Unknown owner on line 22: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/visualize/ @elastic/kibana-app
-
Unknown owner on line 23: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…/plugins/vis_type_timeseries/ @elastic/kibana-app
-
Unknown owner on line 24: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
/src/plugins/vis_type_metric/ @elastic/kibana-app
-
Unknown owner on line 25: make sure the team @elastic/kibana-app exists, is publicly visible, and has write access to the repository
…rc/plugins/vis_type_markdown/ @elastic/kibana-app
-
Unknown owner on line 29: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
/src/plugins/home/public @elastic/kibana-core-ui
-
Unknown owner on line 30: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
/src/plugins/home/server/*.ts @elastic/kibana-core-ui
-
Unknown owner on line 31: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
…plugins/home/server/services/ @elastic/kibana-core-ui
-
Unknown owner on line 33: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
…ugins/kibana/public/home/*.ts @elastic/kibana-core-ui
-
Unknown owner on line 34: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
…ins/kibana/public/home/*.scss @elastic/kibana-core-ui
-
Unknown owner on line 35: make sure the team @elastic/kibana-core-ui exists, is publicly visible, and has write access to the repository
…/kibana/public/home/np_ready/ @elastic/kibana-core-ui
-
Unknown owner on line 38: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…ples/url_generators_examples/ @elastic/kibana-app-arch
-
Unknown owner on line 39: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…ples/url_generators_explorer/ @elastic/kibana-app-arch
-
Unknown owner on line 40: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/packages/kbn-interpreter/ @elastic/kibana-app-arch
-
Unknown owner on line 41: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…/core_plugins/embeddable_api/ @elastic/kibana-app-arch
-
Unknown owner on line 42: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…acy/core_plugins/interpreter/ @elastic/kibana-app-arch
-
Unknown owner on line 43: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…cy/core_plugins/kibana_react/ @elastic/kibana-app-arch
-
Unknown owner on line 44: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…ins/kibana/public/management/ @elastic/kibana-app-arch
-
Unknown owner on line 45: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…server/routes/api/management/ @elastic/kibana-app-arch
-
Unknown owner on line 46: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…/core_plugins/visualizations/ @elastic/kibana-app-arch
-
Unknown owner on line 47: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…legacy/server/index_patterns/ @elastic/kibana-app-arch
-
Unknown owner on line 48: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…rc/plugins/advanced_settings/ @elastic/kibana-app-arch
-
Unknown owner on line 49: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/bfetch/ @elastic/kibana-app-arch
-
Unknown owner on line 50: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/data/ @elastic/kibana-app-arch
-
Unknown owner on line 51: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/embeddable/ @elastic/kibana-app-arch
-
Unknown owner on line 52: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/expressions/ @elastic/kibana-app-arch
-
Unknown owner on line 53: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/inspector/ @elastic/kibana-app-arch
-
Unknown owner on line 54: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/kibana_react/ @elastic/kibana-app-arch
-
Unknown owner on line 55: make sure the team @elastic/kibana-canvas exists, is publicly visible, and has write access to the repository
…bana_react/public/code_editor @elastic/kibana-canvas
-
Unknown owner on line 56: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
-
Unknown owner on line 57: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/management/ @elastic/kibana-app-arch
-
Unknown owner on line 58: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/navigation/ @elastic/kibana-app-arch
-
Unknown owner on line 59: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/share/ @elastic/kibana-app-arch
-
Unknown owner on line 60: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/ui_actions/ @elastic/kibana-app-arch
-
Unknown owner on line 61: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/src/plugins/visualizations/ @elastic/kibana-app-arch
-
Unknown owner on line 62: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…/plugins/advanced_ui_actions/ @elastic/kibana-app-arch
-
Unknown owner on line 63: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
…x-pack/plugins/data_enhanced/ @elastic/kibana-app-arch
-
Unknown owner on line 64: make sure the team @elastic/kibana-app-arch exists, is publicly visible, and has write access to the repository
/x-pack/plugins/drilldowns/ @elastic/kibana-app-arch
-
Unknown owner on line 72: make sure @watson exists and has write access to the repository
/src/apm.js @watson
-
Unknown owner on line 75: make sure the team @elastic/beats exists, is publicly visible, and has write access to the repository
…cy/plugins/beats_management/ @elastic/beats
-
Unknown owner on line 78: make sure the team @elastic/kibana-canvas exists, is publicly visible, and has write access to the repository
…-pack/legacy/plugins/canvas/ @elastic/kibana-canvas
-
Unknown owner on line 81: make sure the team @elastic/logs-metrics-ui exists, is publicly visible, and has write access to the repository
/x-pack/legacy/plugins/infra/ @elastic/logs-metrics-ui
-
Unknown owner on line 82: make sure the team @elastic/logs-metrics-ui exists, is publicly visible, and has write access to the repository
/x-pack/plugins/infra/ @elastic/logs-metrics-ui
-
Unknown owner on line 83: make sure the team @elastic/ingest-management exists, is publicly visible, and has write access to the repository
…-pack/plugins/ingest_manager/ @elastic/ingest-management
-
Unknown owner on line 84: make sure the team @elastic/ingest-management exists, is publicly visible, and has write access to the repository
…egacy/plugins/ingest_manager/ @elastic/ingest-management
-
Unknown owner on line 85: make sure the team @elastic/ingest-management exists, is publicly visible, and has write access to the repository
…lastic/apm-ui @elastic/uptime @elastic/ingest-management
-
Unknown owner on line 85: make sure the team @elastic/logs-metrics-ui exists, is publicly visible, and has write access to the repository
…x-pack/plugins/observability/ @elastic/logs-metrics-ui @elastic/apm-ui @elastic/uptime @elastic/ingest-management
-
Unknown owner on line 86: make sure the team @elastic/stack-monitoring-ui exists, is publicly visible, and has write access to the repository
…ck/legacy/plugins/monitoring/ @elastic/stack-monitoring-ui
-
Unknown owner on line 130: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/core/ @elastic/kibana-platform
-
Unknown owner on line 131: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/config/kibana.yml @elastic/kibana-platform
-
Unknown owner on line 132: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/x-pack/plugins/features/ @elastic/kibana-platform
-
Unknown owner on line 133: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/x-pack/plugins/licensing/ @elastic/kibana-platform
-
Unknown owner on line 134: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/packages/kbn-config-schema/ @elastic/kibana-platform
-
Unknown owner on line 135: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/legacy/server/config/ @elastic/kibana-platform
-
Unknown owner on line 136: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/legacy/server/http/ @elastic/kibana-platform
-
Unknown owner on line 137: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/legacy/server/logging/ @elastic/kibana-platform
-
Unknown owner on line 138: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
…legacy/server/saved_objects/ @elastic/kibana-platform
-
Unknown owner on line 139: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/legacy/server/status/ @elastic/kibana-platform
-
Unknown owner on line 140: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
/src/plugins/status_page/ @elastic/kibana-platform
-
Unknown owner on line 141: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
…ins/saved_objects_management/ @elastic/kibana-platform
-
Unknown owner on line 142: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
…heck_published_api_changes.ts @elastic/kibana-platform
-
Unknown owner on line 145: make sure the team @elastic/kibana-platform exists, is publicly visible, and has write access to the repository
…sp/ @elastic/kibana-security @elastic/kibana-platform
-
Unknown owner on line 161: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
/packages/kbn-analytics/ @elastic/pulse
-
Unknown owner on line 162: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
…egacy/core_plugins/ui_metric/ @elastic/pulse
-
Unknown owner on line 163: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
/src/plugins/telemetry/ @elastic/pulse
-
Unknown owner on line 164: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
…telemetry_collection_manager/ @elastic/pulse
-
Unknown owner on line 165: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
…telemetry_management_section/ @elastic/pulse
-
Unknown owner on line 166: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
…src/plugins/usage_collection/ @elastic/pulse
-
Unknown owner on line 167: make sure the team @elastic/pulse exists, is publicly visible, and has write access to the repository
…s/telemetry_collection_xpack/ @elastic/pulse
-
Unknown owner on line 170: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…pack/legacy/plugins/alerting/ @elastic/kibana-alerting-services
-
Unknown owner on line 171: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…-pack/legacy/plugins/actions/ @elastic/kibana-alerting-services
-
Unknown owner on line 172: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
/x-pack/plugins/alerting/ @elastic/kibana-alerting-services
-
Unknown owner on line 173: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
/x-pack/plugins/actions/ @elastic/kibana-alerting-services
-
Unknown owner on line 174: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
/x-pack/plugins/event_log/ @elastic/kibana-alerting-services
-
Unknown owner on line 175: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
/x-pack/plugins/task_manager/ @elastic/kibana-alerting-services
-
Unknown owner on line 176: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…est/alerting_api_integration/ @elastic/kibana-alerting-services
-
Unknown owner on line 177: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…gration/plugins/task_manager/ @elastic/kibana-alerting-services
-
Unknown owner on line 178: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…ion/test_suites/task_manager/ @elastic/kibana-alerting-services
-
Unknown owner on line 179: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services
-
Unknown owner on line 180: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services
-
Unknown owner on line 181: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…ssl/apps/triggers_actions_ui/ @elastic/kibana-alerting-services
-
Unknown owner on line 182: make sure the team @elastic/kibana-alerting-services exists, is publicly visible, and has write access to the repository
…_ssl/fixtures/plugins/alerts/ @elastic/kibana-alerting-services
-
Unknown owner on line 188: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
/src/plugins/dev_tools/ @elastic/es-ui
-
Unknown owner on line 189: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
/src/plugins/console/ @elastic/es-ui
-
Unknown owner on line 190: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
/src/plugins/es_ui_shared/ @elastic/es-ui
-
Unknown owner on line 191: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…s/cross_cluster_replication/ @elastic/es-ui
-
Unknown owner on line 192: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…/index_lifecycle_management/ @elastic/es-ui
-
Unknown owner on line 193: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…cy/plugins/index_management/ @elastic/es-ui
-
Unknown owner on line 194: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…/plugins/license_management/ @elastic/es-ui
-
Unknown owner on line 195: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…-pack/legacy/plugins/rollup/ @elastic/es-ui
-
Unknown owner on line 196: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…cy/plugins/snapshot_restore/ @elastic/es-ui
-
Unknown owner on line 197: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…y/plugins/upgrade_assistant/ @elastic/es-ui
-
Unknown owner on line 198: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…/plugins/console_extensions/ @elastic/es-ui
-
Unknown owner on line 199: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…x-pack/plugins/es_ui_shared/ @elastic/es-ui
-
Unknown owner on line 200: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…x-pack/plugins/grokdebugger/ @elastic/es-ui
-
Unknown owner on line 201: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…ck/plugins/index_management/ @elastic/es-ui
-
Unknown owner on line 202: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…/plugins/license_management/ @elastic/es-ui
-
Unknown owner on line 203: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…x-pack/plugins/painless_lab/ @elastic/es-ui
-
Unknown owner on line 204: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…ack/plugins/remote_clusters/ @elastic/es-ui
-
Unknown owner on line 205: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
/x-pack/plugins/rollup/ @elastic/es-ui
-
Unknown owner on line 206: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…pack/plugins/searchprofiler/ @elastic/es-ui
-
Unknown owner on line 207: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…ck/plugins/snapshot_restore/ @elastic/es-ui
-
Unknown owner on line 208: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
…k/plugins/upgrade_assistant/ @elastic/es-ui
-
Unknown owner on line 209: make sure the team @elastic/es-ui exists, is publicly visible, and has write access to the repository
/x-pack/plugins/watcher/ @elastic/es-ui
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
module.exports = function(source) { | ||
const options = this.query; | ||
return `__webpack_public_path__ = window.__kbnPublicPath__['${options.key}'];${source}`; | ||
}; |
This file was deleted.
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { filter } from 'lodash'; | ||
import React, { useEffect, useState, useCallback } from 'react'; | ||
import { withRouter, RouteComponentProps } from 'react-router-dom'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSpacer, | ||
EuiBadge, | ||
EuiText, | ||
EuiLink, | ||
EuiIcon, | ||
EuiCallOut, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { IndexPattern, IndexPatternField } from '../../../../../../../../plugins/data/public'; | ||
import { | ||
ChromeDocTitle, | ||
NotificationsStart, | ||
OverlayStart, | ||
} from '../../../../../../../../core/public'; | ||
import { IndexPatternManagementStart } from '../../../../../../../../plugins/index_pattern_management/public'; | ||
import { Tabs } from './tabs'; | ||
import { IndexHeader } from './index_header'; | ||
|
||
interface EditIndexPatternProps extends RouteComponentProps { | ||
indexPattern: IndexPattern; | ||
indexPatterns: IndexPattern[]; | ||
config: Record<string, any>; | ||
services: { | ||
notifications: NotificationsStart; | ||
docTitle: ChromeDocTitle; | ||
overlays: OverlayStart; | ||
indexPatternManagement: IndexPatternManagementStart; | ||
}; | ||
} | ||
|
||
const mappingAPILink = i18n.translate( | ||
'kbn.management.editIndexPattern.timeFilterLabel.mappingAPILink', | ||
{ | ||
defaultMessage: 'Mapping API', | ||
} | ||
); | ||
|
||
const mappingConflictHeader = i18n.translate( | ||
'kbn.management.editIndexPattern.mappingConflictHeader', | ||
{ | ||
defaultMessage: 'Mapping conflict', | ||
} | ||
); | ||
|
||
const confirmMessage = i18n.translate('kbn.management.editIndexPattern.refreshLabel', { | ||
defaultMessage: 'This action resets the popularity counter of each field.', | ||
}); | ||
|
||
const confirmModalOptionsRefresh = { | ||
confirmButtonText: i18n.translate('kbn.management.editIndexPattern.refreshButton', { | ||
defaultMessage: 'Refresh', | ||
}), | ||
title: i18n.translate('kbn.management.editIndexPattern.refreshHeader', { | ||
defaultMessage: 'Refresh field list?', | ||
}), | ||
}; | ||
|
||
const confirmModalOptionsDelete = { | ||
confirmButtonText: i18n.translate('kbn.management.editIndexPattern.deleteButton', { | ||
defaultMessage: 'Delete', | ||
}), | ||
title: i18n.translate('kbn.management.editIndexPattern.deleteHeader', { | ||
defaultMessage: 'Delete index pattern?', | ||
}), | ||
}; | ||
|
||
export const EditIndexPattern = withRouter( | ||
({ indexPattern, indexPatterns, config, services, history, location }: EditIndexPatternProps) => { | ||
const [fields, setFields] = useState<IndexPatternField[]>(indexPattern.getNonScriptedFields()); | ||
const [conflictedFields, setConflictedFields] = useState<IndexPatternField[]>( | ||
indexPattern.fields.filter(field => field.type === 'conflict') | ||
); | ||
const [defaultIndex, setDefaultIndex] = useState<string>(config.get('defaultIndex')); | ||
const [tags, setTags] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
setFields(indexPattern.getNonScriptedFields()); | ||
setConflictedFields(indexPattern.fields.filter(field => field.type === 'conflict')); | ||
}, [indexPattern, indexPattern.fields]); | ||
|
||
useEffect(() => { | ||
const indexPatternTags = | ||
services.indexPatternManagement.list.getIndexPatternTags( | ||
indexPattern, | ||
indexPattern.id === defaultIndex | ||
) || []; | ||
setTags(indexPatternTags); | ||
}, [defaultIndex, indexPattern, services.indexPatternManagement.list]); | ||
|
||
const setDefaultPattern = useCallback(() => { | ||
config.set('defaultIndex', indexPattern.id); | ||
setDefaultIndex(indexPattern.id || ''); | ||
}, [config, indexPattern.id]); | ||
|
||
const refreshFields = () => { | ||
services.overlays | ||
.openConfirm(confirmMessage, confirmModalOptionsRefresh) | ||
.then(async isConfirmed => { | ||
if (isConfirmed) { | ||
await indexPattern.init(true); | ||
setFields(indexPattern.getNonScriptedFields()); | ||
} | ||
}); | ||
}; | ||
|
||
const removePattern = () => { | ||
function doRemove() { | ||
if (indexPattern.id === defaultIndex) { | ||
config.remove('defaultIndex'); | ||
const otherPatterns = filter(indexPatterns, pattern => { | ||
return pattern.id !== indexPattern.id; | ||
}); | ||
|
||
if (otherPatterns.length) { | ||
config.set('defaultIndex', otherPatterns[0].id); | ||
} | ||
} | ||
|
||
Promise.resolve(indexPattern.destroy()).then(function() { | ||
history.push('/management/kibana/index_patterns'); | ||
}); | ||
} | ||
|
||
services.overlays.openConfirm('', confirmModalOptionsDelete).then(isConfirmed => { | ||
if (isConfirmed) { | ||
doRemove(); | ||
} | ||
}); | ||
}; | ||
|
||
const timeFilterHeader = i18n.translate('kbn.management.editIndexPattern.timeFilterHeader', { | ||
defaultMessage: "Time Filter field name: '{timeFieldName}'", | ||
values: { timeFieldName: indexPattern.timeFieldName }, | ||
}); | ||
|
||
const mappingConflictLabel = i18n.translate( | ||
'kbn.management.editIndexPattern.mappingConflictLabel', | ||
{ | ||
defaultMessage: | ||
'{conflictFieldsLength, plural, one {A field is} other {# fields are}} defined as several types (string, integer, etc) across the indices that match this pattern. You may still be able to use these conflict fields in parts of Kibana, but they will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data.', | ||
values: { conflictFieldsLength: conflictedFields.length }, | ||
} | ||
); | ||
|
||
services.docTitle.change(indexPattern.title); | ||
|
||
const showTagsSection = Boolean(indexPattern.timeFieldName || (tags && tags.length > 0)); | ||
|
||
return ( | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem> | ||
<IndexHeader | ||
indexPattern={indexPattern} | ||
setDefault={setDefaultPattern} | ||
refreshFields={refreshFields} | ||
deleteIndexPattern={removePattern} | ||
defaultIndex={defaultIndex} | ||
/> | ||
<EuiSpacer size="s" /> | ||
{showTagsSection && ( | ||
<EuiFlexGroup wrap> | ||
{Boolean(indexPattern.timeFieldName) && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge color="warning">{timeFilterHeader}</EuiBadge> | ||
</EuiFlexItem> | ||
)} | ||
{tags.map((tag: any) => ( | ||
<EuiFlexItem grow={false} key={tag.key}> | ||
<EuiBadge color="hollow">{tag.name}</EuiBadge> | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGroup> | ||
)} | ||
<EuiSpacer size="m" /> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="kbn.management.editIndexPattern.timeFilterLabel.timeFilterDetail" | ||
defaultMessage="This page lists every field in the {indexPatternTitle} index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch" | ||
values={{ indexPatternTitle: <strong>{indexPattern.title}</strong> }} | ||
/>{' '} | ||
<EuiLink | ||
href="http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html" | ||
target="_blank" | ||
> | ||
{mappingAPILink} | ||
<EuiIcon type="link" /> | ||
</EuiLink> | ||
</p> | ||
</EuiText> | ||
{conflictedFields.length > 0 && ( | ||
<EuiCallOut title={mappingConflictHeader} color="warning" iconType="alert"> | ||
<p>{mappingConflictLabel}</p> | ||
</EuiCallOut> | ||
)} | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<Tabs | ||
indexPattern={indexPattern} | ||
fields={fields} | ||
config={config} | ||
services={{ | ||
indexPatternManagement: services.indexPatternManagement, | ||
}} | ||
history={history} | ||
location={location} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} | ||
); |
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React, { useState, useCallback, useEffect, Fragment, useMemo } from 'react'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiTabbedContent, | ||
EuiTabbedContentTab, | ||
EuiSpacer, | ||
EuiFieldSearch, | ||
EuiSelect, | ||
EuiSelectOption, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { fieldWildcardMatcher } from '../../../../../../../../../plugins/kibana_utils/public'; | ||
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public'; | ||
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public'; | ||
import { createEditIndexPatternPageStateContainer } from '../edit_index_pattern_state_container'; | ||
import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from '../constants'; | ||
import { SourceFiltersTable } from '../source_filters_table'; | ||
import { IndexedFieldsTable } from '../indexed_fields_table'; | ||
import { ScriptedFieldsTable } from '../scripted_fields_table'; | ||
import { getTabs, getPath, convertToEuiSelectOption } from './utils'; | ||
|
||
interface TabsProps extends Pick<RouteComponentProps, 'history' | 'location'> { | ||
indexPattern: IndexPattern; | ||
config: Record<string, any>; | ||
fields: IndexPatternField[]; | ||
services: { | ||
indexPatternManagement: IndexPatternManagementStart; | ||
}; | ||
} | ||
|
||
const filterAriaLabel = i18n.translate('kbn.management.editIndexPattern.fields.filterAria', { | ||
defaultMessage: 'Filter', | ||
}); | ||
|
||
const filterPlaceholder = i18n.translate( | ||
'kbn.management.editIndexPattern.fields.filterPlaceholder', | ||
{ | ||
defaultMessage: 'Filter', | ||
} | ||
); | ||
|
||
export function Tabs({ config, indexPattern, fields, services, history, location }: TabsProps) { | ||
const [fieldFilter, setFieldFilter] = useState<string>(''); | ||
const [indexedFieldTypeFilter, setIndexedFieldTypeFilter] = useState<string>(''); | ||
const [scriptedFieldLanguageFilter, setScriptedFieldLanguageFilter] = useState<string>(''); | ||
const [indexedFieldTypes, setIndexedFieldType] = useState<EuiSelectOption[]>([]); | ||
const [scriptedFieldLanguages, setScriptedFieldLanguages] = useState<EuiSelectOption[]>([]); | ||
const [syncingStateFunc, setSyncingStateFunc] = useState<any>({ | ||
getCurrentTab: () => TAB_INDEXED_FIELDS, | ||
}); | ||
|
||
const refreshFilters = useCallback(() => { | ||
const tempIndexedFieldTypes: string[] = []; | ||
const tempScriptedFieldLanguages: string[] = []; | ||
indexPattern.fields.forEach(field => { | ||
if (field.scripted) { | ||
if (field.lang) { | ||
tempScriptedFieldLanguages.push(field.lang); | ||
} | ||
} else { | ||
tempIndexedFieldTypes.push(field.type); | ||
} | ||
}); | ||
|
||
setIndexedFieldType(convertToEuiSelectOption(tempIndexedFieldTypes, 'indexedFiledTypes')); | ||
setScriptedFieldLanguages( | ||
convertToEuiSelectOption(tempScriptedFieldLanguages, 'scriptedFieldLanguages') | ||
); | ||
}, [indexPattern]); | ||
|
||
useEffect(() => { | ||
refreshFilters(); | ||
}, [indexPattern, indexPattern.fields, refreshFilters]); | ||
|
||
const fieldWildcardMatcherDecorated = useCallback( | ||
(filters: string[]) => fieldWildcardMatcher(filters, config.get('metaFields')), | ||
[config] | ||
); | ||
|
||
const getFilterSection = useCallback( | ||
(type: string) => { | ||
return ( | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={true}> | ||
<EuiFieldSearch | ||
placeholder={filterPlaceholder} | ||
value={fieldFilter} | ||
onChange={e => setFieldFilter(e.target.value)} | ||
data-test-subj="indexPatternFieldFilter" | ||
aria-label={filterAriaLabel} | ||
/> | ||
</EuiFlexItem> | ||
{type === TAB_INDEXED_FIELDS && indexedFieldTypes.length > 0 && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiSelect | ||
options={indexedFieldTypes} | ||
value={indexedFieldTypeFilter} | ||
onChange={e => setIndexedFieldTypeFilter(e.target.value)} | ||
data-test-subj="indexedFieldTypeFilterDropdown" | ||
/> | ||
</EuiFlexItem> | ||
)} | ||
{type === TAB_SCRIPTED_FIELDS && scriptedFieldLanguages.length > 0 && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiSelect | ||
options={scriptedFieldLanguages} | ||
value={scriptedFieldLanguageFilter} | ||
onChange={e => setScriptedFieldLanguageFilter(e.target.value)} | ||
data-test-subj="scriptedFieldLanguageFilterDropdown" | ||
/> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
); | ||
}, | ||
[ | ||
fieldFilter, | ||
indexedFieldTypeFilter, | ||
indexedFieldTypes, | ||
scriptedFieldLanguageFilter, | ||
scriptedFieldLanguages, | ||
] | ||
); | ||
|
||
const getContent = useCallback( | ||
(type: string) => { | ||
switch (type) { | ||
case TAB_INDEXED_FIELDS: | ||
return ( | ||
<Fragment> | ||
<EuiSpacer size="m" /> | ||
{getFilterSection(type)} | ||
<EuiSpacer size="m" /> | ||
<IndexedFieldsTable | ||
fields={fields} | ||
indexPattern={indexPattern} | ||
fieldFilter={fieldFilter} | ||
fieldWildcardMatcher={fieldWildcardMatcherDecorated} | ||
indexedFieldTypeFilter={indexedFieldTypeFilter} | ||
helpers={{ | ||
redirectToRoute: (field: IndexPatternField) => { | ||
history.push(getPath(field)); | ||
}, | ||
getFieldInfo: services.indexPatternManagement.list.getFieldInfo, | ||
}} | ||
/> | ||
</Fragment> | ||
); | ||
case TAB_SCRIPTED_FIELDS: | ||
return ( | ||
<Fragment> | ||
<EuiSpacer size="m" /> | ||
{getFilterSection(type)} | ||
<EuiSpacer size="m" /> | ||
<ScriptedFieldsTable | ||
indexPattern={indexPattern} | ||
fieldFilter={fieldFilter} | ||
scriptedFieldLanguageFilter={scriptedFieldLanguageFilter} | ||
helpers={{ | ||
redirectToRoute: (field: IndexPatternField) => { | ||
history.push(getPath(field)); | ||
}, | ||
}} | ||
onRemoveField={refreshFilters} | ||
/> | ||
</Fragment> | ||
); | ||
case TAB_SOURCE_FILTERS: | ||
return ( | ||
<Fragment> | ||
<EuiSpacer size="m" /> | ||
{getFilterSection(type)} | ||
<EuiSpacer size="m" /> | ||
<SourceFiltersTable | ||
indexPattern={indexPattern} | ||
filterFilter={fieldFilter} | ||
fieldWildcardMatcher={fieldWildcardMatcherDecorated} | ||
onAddOrRemoveFilter={refreshFilters} | ||
/> | ||
</Fragment> | ||
); | ||
} | ||
}, | ||
[ | ||
fieldFilter, | ||
fieldWildcardMatcherDecorated, | ||
fields, | ||
getFilterSection, | ||
history, | ||
indexPattern, | ||
indexedFieldTypeFilter, | ||
refreshFilters, | ||
scriptedFieldLanguageFilter, | ||
services.indexPatternManagement.list.getFieldInfo, | ||
] | ||
); | ||
|
||
const euiTabs: EuiTabbedContentTab[] = useMemo( | ||
() => | ||
getTabs(indexPattern, fieldFilter, services.indexPatternManagement.list).map( | ||
(tab: Pick<EuiTabbedContentTab, 'name' | 'id'>) => { | ||
return { | ||
...tab, | ||
content: getContent(tab.id), | ||
}; | ||
} | ||
), | ||
[fieldFilter, getContent, indexPattern, services.indexPatternManagement.list] | ||
); | ||
|
||
const [selectedTabId, setSelectedTabId] = useState(euiTabs[0].id); | ||
|
||
useEffect(() => { | ||
const { | ||
startSyncingState, | ||
stopSyncingState, | ||
setCurrentTab, | ||
getCurrentTab, | ||
} = createEditIndexPatternPageStateContainer({ | ||
useHashedUrl: config.get('state:storeInSessionStorage'), | ||
defaultTab: TAB_INDEXED_FIELDS, | ||
}); | ||
|
||
startSyncingState(); | ||
setSyncingStateFunc({ | ||
setCurrentTab, | ||
getCurrentTab, | ||
}); | ||
setSelectedTabId(getCurrentTab()); | ||
|
||
return () => { | ||
stopSyncingState(); | ||
}; | ||
}, [config]); | ||
|
||
return ( | ||
<EuiTabbedContent | ||
tabs={euiTabs} | ||
selectedTab={euiTabs.find(tab => tab.id === selectedTabId)} | ||
onTabClick={tab => { | ||
setSelectedTabId(tab.id); | ||
syncingStateFunc.setCurrentTab(tab.id); | ||
}} | ||
/> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Dictionary, countBy, defaults, unique } from 'lodash'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public'; | ||
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public'; | ||
import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from '../constants'; | ||
|
||
function filterByName(items: IndexPatternField[], filter: string) { | ||
const lowercaseFilter = (filter || '').toLowerCase(); | ||
return items.filter(item => item.name.toLowerCase().includes(lowercaseFilter)); | ||
} | ||
|
||
function getCounts( | ||
fields: IndexPatternField[], | ||
sourceFilters: { | ||
excludes: string[]; | ||
}, | ||
fieldFilter = '' | ||
) { | ||
const fieldCount = countBy(filterByName(fields, fieldFilter), function(field) { | ||
return field.scripted ? 'scripted' : 'indexed'; | ||
}); | ||
|
||
defaults(fieldCount, { | ||
indexed: 0, | ||
scripted: 0, | ||
sourceFilters: sourceFilters.excludes | ||
? sourceFilters.excludes.filter(value => | ||
value.toLowerCase().includes(fieldFilter.toLowerCase()) | ||
).length | ||
: 0, | ||
}); | ||
|
||
return fieldCount; | ||
} | ||
|
||
function getTitle(type: string, filteredCount: Dictionary<number>, totalCount: Dictionary<number>) { | ||
let title = ''; | ||
switch (type) { | ||
case 'indexed': | ||
title = i18n.translate('kbn.management.editIndexPattern.tabs.fieldsHeader', { | ||
defaultMessage: 'Fields', | ||
}); | ||
break; | ||
case 'scripted': | ||
title = i18n.translate('kbn.management.editIndexPattern.tabs.scriptedHeader', { | ||
defaultMessage: 'Scripted fields', | ||
}); | ||
break; | ||
case 'sourceFilters': | ||
title = i18n.translate('kbn.management.editIndexPattern.tabs.sourceHeader', { | ||
defaultMessage: 'Source filters', | ||
}); | ||
break; | ||
} | ||
const count = ` (${ | ||
filteredCount[type] === totalCount[type] | ||
? filteredCount[type] | ||
: filteredCount[type] + ' / ' + totalCount[type] | ||
})`; | ||
return title + count; | ||
} | ||
|
||
export function getTabs( | ||
indexPattern: IndexPattern, | ||
fieldFilter: string, | ||
indexPatternListProvider: IndexPatternManagementStart['list'] | ||
) { | ||
const totalCount = getCounts(indexPattern.fields, indexPattern.getSourceFiltering()); | ||
const filteredCount = getCounts( | ||
indexPattern.fields, | ||
indexPattern.getSourceFiltering(), | ||
fieldFilter | ||
); | ||
|
||
const tabs = []; | ||
|
||
tabs.push({ | ||
name: getTitle('indexed', filteredCount, totalCount), | ||
id: TAB_INDEXED_FIELDS, | ||
}); | ||
|
||
if (indexPatternListProvider.areScriptedFieldsEnabled(indexPattern)) { | ||
tabs.push({ | ||
name: getTitle('scripted', filteredCount, totalCount), | ||
id: TAB_SCRIPTED_FIELDS, | ||
}); | ||
} | ||
|
||
tabs.push({ | ||
name: getTitle('sourceFilters', filteredCount, totalCount), | ||
id: TAB_SOURCE_FILTERS, | ||
}); | ||
|
||
return tabs; | ||
} | ||
|
||
export function getPath(field: IndexPatternField) { | ||
return `/management/kibana/index_patterns/${field.indexPattern?.id}/field/${field.name}`; | ||
} | ||
|
||
const allTypesDropDown = i18n.translate('kbn.management.editIndexPattern.fields.allTypesDropDown', { | ||
defaultMessage: 'All field types', | ||
}); | ||
|
||
const allLangsDropDown = i18n.translate('kbn.management.editIndexPattern.fields.allLangsDropDown', { | ||
defaultMessage: 'All languages', | ||
}); | ||
|
||
export function convertToEuiSelectOption(options: string[], type: string) { | ||
const euiOptions = | ||
options.length > 0 | ||
? [ | ||
{ | ||
value: '', | ||
text: type === 'scriptedFieldLanguages' ? allLangsDropDown : allTypesDropDown, | ||
}, | ||
] | ||
: []; | ||
return euiOptions.concat( | ||
unique(options).map(option => { | ||
return { | ||
value: option, | ||
text: option, | ||
}; | ||
}) | ||
); | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { contains } from 'lodash'; | ||
import React from 'react'; | ||
import { History } from 'history'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiCallOut } from '@elastic/eui'; | ||
import { CoreStart } from 'kibana/public'; | ||
import { toMountPoint } from '../../../../kibana_react/public'; | ||
import { IndexPatternsContract } from './index_patterns'; | ||
|
||
export type EnsureDefaultIndexPattern = (history: History) => Promise<unknown> | undefined; | ||
|
||
export const createEnsureDefaultIndexPattern = (core: CoreStart) => { | ||
let bannerId: string; | ||
let timeoutId: NodeJS.Timeout | undefined; | ||
|
||
/** | ||
* Checks whether a default index pattern is set and exists and defines | ||
* one otherwise. | ||
* | ||
* If there are no index patterns, redirect to management page and show | ||
* banner. In this case the promise returned from this function will never | ||
* resolve to wait for the URL change to happen. | ||
*/ | ||
return async function ensureDefaultIndexPattern(this: IndexPatternsContract, history: History) { | ||
const patterns = await this.getIds(); | ||
let defaultId = core.uiSettings.get('defaultIndex'); | ||
let defined = !!defaultId; | ||
const exists = contains(patterns, defaultId); | ||
|
||
if (defined && !exists) { | ||
core.uiSettings.remove('defaultIndex'); | ||
defaultId = defined = false; | ||
} | ||
|
||
if (defined) { | ||
return; | ||
} | ||
|
||
// If there is any index pattern created, set the first as default | ||
if (patterns.length >= 1) { | ||
defaultId = patterns[0]; | ||
core.uiSettings.set('defaultIndex', defaultId); | ||
} else { | ||
const canManageIndexPatterns = core.application.capabilities.management.kibana.index_patterns; | ||
const redirectTarget = canManageIndexPatterns ? '/management/kibana/index_pattern' : '/home'; | ||
|
||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
|
||
// Avoid being hostile to new users who don't have an index pattern setup yet | ||
// give them a friendly info message instead of a terse error message | ||
bannerId = core.overlays.banners.replace( | ||
bannerId, | ||
toMountPoint( | ||
<EuiCallOut | ||
color="warning" | ||
iconType="iInCircle" | ||
title={i18n.translate('data.indexPatterns.ensureDefaultIndexPattern.bannerLabel', { | ||
defaultMessage: | ||
"In order to visualize and explore data in Kibana, you'll need to create an index pattern to retrieve data from Elasticsearch.", | ||
})} | ||
/> | ||
) | ||
); | ||
|
||
// hide the message after the user has had a chance to acknowledge it -- so it doesn't permanently stick around | ||
timeoutId = setTimeout(() => { | ||
core.overlays.banners.remove(bannerId); | ||
timeoutId = undefined; | ||
}, 15000); | ||
|
||
history.push(redirectTarget); | ||
|
||
// return never-resolving promise to stop resolving and wait for the url change | ||
return new Promise(() => {}); | ||
} | ||
}; | ||
}; |