From c58238d989dd7d64b375b50e77dfcb856002fe94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:20:59 +0200 Subject: [PATCH] [Index Management] Remove old code (#168885) ## Summary This PR removes some leftover code from deleting the index details flyout in https://github.com/elastic/kibana/pull/165705 --- .../constants/detail_panel_tabs.ts | 12 --- .../public/application/constants/index.ts | 8 -- .../public/application/lib/ace.js | 75 ------------------- .../public/application/services/api.ts | 14 ---- .../public/application/services/index.ts | 1 - 5 files changed, 110 deletions(-) delete mode 100644 x-pack/plugins/index_management/public/application/constants/detail_panel_tabs.ts delete mode 100644 x-pack/plugins/index_management/public/application/lib/ace.js diff --git a/x-pack/plugins/index_management/public/application/constants/detail_panel_tabs.ts b/x-pack/plugins/index_management/public/application/constants/detail_panel_tabs.ts deleted file mode 100644 index 29000412d30e88..00000000000000 --- a/x-pack/plugins/index_management/public/application/constants/detail_panel_tabs.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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. - */ - -export const TAB_SUMMARY = 'TAB_SUMMARY'; -export const TAB_SETTINGS = 'TAB_SETTINGS'; -export const TAB_MAPPING = 'TAB_MAPPING'; -export const TAB_STATS = 'TAB_STATS'; -export const TAB_EDIT_SETTINGS = 'TAB_EDIT_SETTINGS'; diff --git a/x-pack/plugins/index_management/public/application/constants/index.ts b/x-pack/plugins/index_management/public/application/constants/index.ts index 7a1caf5e507714..939a5867a47dfa 100644 --- a/x-pack/plugins/index_management/public/application/constants/index.ts +++ b/x-pack/plugins/index_management/public/application/constants/index.ts @@ -7,14 +7,6 @@ export { REFRESH_RATE_INDEX_LIST } from './refresh_intervals'; -export { - TAB_SUMMARY, - TAB_SETTINGS, - TAB_MAPPING, - TAB_STATS, - TAB_EDIT_SETTINGS, -} from './detail_panel_tabs'; - export const REACT_ROOT_ID = 'indexManagementReactRoot'; export * from './ilm_locator'; diff --git a/x-pack/plugins/index_management/public/application/lib/ace.js b/x-pack/plugins/index_management/public/application/lib/ace.js deleted file mode 100644 index 3b6c6637215a38..00000000000000 --- a/x-pack/plugins/index_management/public/application/lib/ace.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 brace from 'brace'; -import 'brace/ext/language_tools'; - -const splitTokens = (line) => { - return line.split(/\s+/); -}; -const wordCompleter = (words) => { - return { - identifierRegexps: [ - /[a-zA-Z_0-9\.\$\-\u00A2-\uFFFF]/, // adds support for dot character - ], - getCompletions: (editor, session, pos, prefix, callback) => { - const document = session.getDocument(); - const currentLine = document.getLine(pos.row); - const previousLine = document.getLine(pos.row - 1); - const currentTokens = splitTokens(currentLine.slice(0, pos.column)); - const fullLineTokens = splitTokens(currentLine); - const isInArray = previousLine && splitTokens(previousLine).slice(-1)[0] === '['; - const [, secondToken = null] = currentTokens; - const [, secondFullToken = null] = fullLineTokens; - if (isInArray || currentTokens.length > 2) { - return callback(null, []); - } - const startQuote = secondToken === '"' ? '' : '"'; - const endQuote = secondFullToken === '""' ? '' : '"'; - callback( - null, - words.map((word) => { - return { - caption: ` ${word}`, - value: `${startQuote}${word}${endQuote}`, - }; - }) - ); - }, - }; -}; - -export const createAceEditor = (div, value, readOnly = true, autocompleteArray) => { - const editor = brace.edit(div); - editor.$blockScrolling = Infinity; - editor.setValue(value, -1); - const session = editor.getSession(); - session.setUseWrapMode(true); - session.setMode('ace/mode/json'); - if (autocompleteArray) { - const languageTools = brace.acequire('ace/ext/language_tools'); - const autocompleter = wordCompleter(autocompleteArray); - languageTools.setCompleters([autocompleter]); - } - const options = { - readOnly, - highlightActiveLine: false, - highlightGutterLine: false, - minLines: 20, - maxLines: 30, - }; - //done this way to avoid warnings about unrecognized options - const autocompleteOptions = readOnly - ? {} - : { - enableBasicAutocompletion: true, - enableLiveAutocompletion: true, - }; - editor.setOptions({ ...options, ...autocompleteOptions }); - editor.setBehavioursEnabled(!readOnly); - return editor; -}; diff --git a/x-pack/plugins/index_management/public/application/services/api.ts b/x-pack/plugins/index_management/public/application/services/api.ts index 54391aaaedf437..30c83398400185 100644 --- a/x-pack/plugins/index_management/public/application/services/api.ts +++ b/x-pack/plugins/index_management/public/application/services/api.ts @@ -41,7 +41,6 @@ import { Index, IndexSettingsResponse, } from '../../../common'; -import { TAB_SETTINGS, TAB_MAPPING, TAB_STATS } from '../constants'; import { useRequest, sendRequest } from './use_request'; import { httpService } from './http'; import { UiMetricService } from './ui_metric'; @@ -245,19 +244,6 @@ export async function loadIndexMapping(indexName: string) { return response; } -export async function loadIndexData(type: string, indexName: string) { - switch (type) { - case TAB_MAPPING: - return loadIndexMapping(indexName); - - case TAB_SETTINGS: - return loadIndexSettings(indexName); - - case TAB_STATS: - return loadIndexStats(indexName); - } -} - export function useLoadIndexTemplates() { return useRequest<{ templates: TemplateListItem[]; legacyTemplates: TemplateListItem[] }>({ path: `${API_BASE_PATH}/index_templates`, diff --git a/x-pack/plugins/index_management/public/application/services/index.ts b/x-pack/plugins/index_management/public/application/services/index.ts index 058a09d3f15d1a..2a88ce37d9a99f 100644 --- a/x-pack/plugins/index_management/public/application/services/index.ts +++ b/x-pack/plugins/index_management/public/application/services/index.ts @@ -20,7 +20,6 @@ export { updateIndexSettings, loadIndexStats, loadIndexMapping, - loadIndexData, useLoadIndexTemplates, simulateIndexTemplate, useLoadNodesPlugins,