From 821369785923c24f056784f22a9485d1dfa731db Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 18 Sep 2024 12:51:05 -0400 Subject: [PATCH 1/2] Incinerate unused Uptime code. --- .../uptime/common/constants/data_filters.ts | 12 ------ .../uptime/common/field_names.ts | 22 ----------- .../common/formatters/format_space_name.ts | 13 ------- .../uptime/common/formatters/index.ts | 8 ---- .../uptime/common/rules/status_rule.ts | 12 ------ .../uptime/common/utils/t_enum.ts | 38 ------------------- .../legacy_uptime/lib/helper/get_title.ts | 15 -------- .../lib/helper/spy_use_fetcher.ts | 32 ---------------- 8 files changed, 152 deletions(-) delete mode 100644 x-pack/plugins/observability_solution/uptime/common/constants/data_filters.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/common/field_names.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/common/formatters/format_space_name.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/common/formatters/index.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/common/rules/status_rule.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/common/utils/t_enum.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/get_title.ts delete mode 100644 x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/spy_use_fetcher.ts diff --git a/x-pack/plugins/observability_solution/uptime/common/constants/data_filters.ts b/x-pack/plugins/observability_solution/uptime/common/constants/data_filters.ts deleted file mode 100644 index d7ca3b43376b9..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/constants/data_filters.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 STEP_END_FILTER = { - terms: { - 'synthetics.type': ['step/end'], - }, -}; diff --git a/x-pack/plugins/observability_solution/uptime/common/field_names.ts b/x-pack/plugins/observability_solution/uptime/common/field_names.ts deleted file mode 100644 index 0407fad341d8a..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/field_names.ts +++ /dev/null @@ -1,22 +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 AGENT_NAME = 'agent.name'; -export const MONITOR_ID = 'monitor.id'; -export const MONITOR_NAME = 'monitor.name'; -export const MONITOR_TYPE = 'monitor.type'; -export const URL_FULL = 'url.full'; -export const URL_PORT = 'url.port'; -export const OBSERVER_GEO_NAME = 'observer.geo.name'; -export const ERROR_MESSAGE = 'error.message'; -export const STATE_ID = 'monitor.state.id'; - -export const CERT_COMMON_NAME = 'tls.server.x509.subject.common_name'; -export const CERT_ISSUER_NAME = 'tls.server.x509.issuer.common_name'; -export const CERT_VALID_NOT_AFTER = 'tls.server.x509.not_after'; -export const CERT_VALID_NOT_BEFORE = 'tls.server.x509.not_before'; -export const CERT_HASH_SHA256 = 'tls.server.hash.sha256'; diff --git a/x-pack/plugins/observability_solution/uptime/common/formatters/format_space_name.ts b/x-pack/plugins/observability_solution/uptime/common/formatters/format_space_name.ts deleted file mode 100644 index 88beb7cda1407..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/formatters/format_space_name.ts +++ /dev/null @@ -1,13 +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. - */ -/* Formats kibana space id into a valid Fleet-compliant data-stream namespace */ -import { INVALID_NAMESPACE_CHARACTERS } from '@kbn/fleet-plugin/common'; - -export const formatKibanaNamespace = (spaceId: string) => { - const namespaceRegExp = new RegExp(INVALID_NAMESPACE_CHARACTERS, 'g'); - return spaceId.replace(namespaceRegExp, '_'); -}; diff --git a/x-pack/plugins/observability_solution/uptime/common/formatters/index.ts b/x-pack/plugins/observability_solution/uptime/common/formatters/index.ts deleted file mode 100644 index 17c9567043197..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/formatters/index.ts +++ /dev/null @@ -1,8 +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 { formatKibanaNamespace } from './format_space_name'; diff --git a/x-pack/plugins/observability_solution/uptime/common/rules/status_rule.ts b/x-pack/plugins/observability_solution/uptime/common/rules/status_rule.ts deleted file mode 100644 index 375e0c0dd08c1..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/rules/status_rule.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. - */ - -import { schema, TypeOf } from '@kbn/config-schema'; - -export const StatusRulePramsSchema = schema.object({}); - -export type StatusRuleParams = TypeOf; diff --git a/x-pack/plugins/observability_solution/uptime/common/utils/t_enum.ts b/x-pack/plugins/observability_solution/uptime/common/utils/t_enum.ts deleted file mode 100644 index e00a51dbdf438..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/common/utils/t_enum.ts +++ /dev/null @@ -1,38 +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 * as t from 'io-ts'; - -/** - * This utility function can be used to turn a TypeScript enum into a io-ts codec. - * - * @example - * import { PathReporter } from "io-ts/lib/PathReporter"; - * - * enum Thing { - * FOO = "foo", - * BAR = "bar" - * } - * - * const ThingCodec = tEnum("Thing", Thing); - * - * console.log(PathReporter.report(ThingCodec.decode('invalidvalue'))); - * // prints [ 'Invalid value "invalidvalue" supplied to : Thing' ] - * console.log(PathReporter.report(ThingCodec.decode('foo'))); - * // prints [ 'No errors!' ] - */ -export function tEnum(enumName: string, theEnum: Record) { - const isEnumValue = (input: unknown): input is EnumType => - Object.values(theEnum).includes(input); - - return new t.Type( - enumName, - isEnumValue, - (input, context) => (isEnumValue(input) ? t.success(input) : t.failure(input, context)), - t.identity - ); -} diff --git a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/get_title.ts b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/get_title.ts deleted file mode 100644 index d2ad0dd3296b3..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/get_title.ts +++ /dev/null @@ -1,15 +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 { i18n } from '@kbn/i18n'; - -export const getTitle = (name?: string) => { - const appName = i18n.translate('xpack.uptime.title', { - defaultMessage: 'Uptime', - }); - return `${appName} ${name ? '| ' + name : ''} - Kibana`; -}; diff --git a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/spy_use_fetcher.ts b/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/spy_use_fetcher.ts deleted file mode 100644 index e1f43ee0b003e..0000000000000 --- a/x-pack/plugins/observability_solution/uptime/public/legacy_uptime/lib/helper/spy_use_fetcher.ts +++ /dev/null @@ -1,32 +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 * as observabilitySharedPublic from '@kbn/observability-shared-plugin/public'; - -jest.mock('@kbn/observability-shared-plugin/public', () => { - const originalModule = jest.requireActual('@kbn/observability-shared-plugin/public'); - - return { - ...originalModule, - useFetcher: jest.fn().mockReturnValue({ - data: null, - status: 'success', - }), - useTrackPageview: jest.fn(), - }; -}); - -export function spyOnUseFetcher( - payload: unknown, - status = observabilitySharedPublic.FETCH_STATUS.SUCCESS -) { - return jest.spyOn(observabilitySharedPublic, 'useFetcher').mockReturnValue({ - status, - data: payload, - refetch: () => null, - }); -} From 4453d6ff052f67add6c3fcf600d5150a37dffd09 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 18 Sep 2024 13:34:15 -0400 Subject: [PATCH 2/2] Delete unused translations. --- x-pack/plugins/translations/translations/fr-FR.json | 1 - x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 3 files changed, 3 deletions(-) diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 5a4660f362987..95879f64100d5 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -47276,7 +47276,6 @@ "xpack.uptime.synthetics.waterfallChart.labels.timings.ssl": "TLS", "xpack.uptime.synthetics.waterfallChart.labels.timings.wait": "En attente (TTFB)", "xpack.uptime.syntheticsFeatureCatalogueTitle": "Synthetics", - "xpack.uptime.title": "Uptime", "xpack.uptime.tls.ageExpression.description": "ou antérieur à (jours) : ", "xpack.uptime.tls.criteriaExpression.value": "le moniteur correspondant", "xpack.uptime.tls.expirationExpression.description": "possède un certificat expirant dans (jours) : ", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index c112b137c2e2b..887063f865d5a 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -47258,7 +47258,6 @@ "xpack.uptime.synthetics.waterfallChart.labels.timings.ssl": "TLS", "xpack.uptime.synthetics.waterfallChart.labels.timings.wait": "待機中(TTFB)", "xpack.uptime.syntheticsFeatureCatalogueTitle": "Synthetics", - "xpack.uptime.title": "アップタイム", "xpack.uptime.tls.ageExpression.description": "または次の日数を経過:", "xpack.uptime.tls.criteriaExpression.value": "一致するモニター", "xpack.uptime.tls.expirationExpression.description": "次の日数以内に有効期限切れになる証明書があります:", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 30d822480bdff..13100c9cabde1 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -47309,7 +47309,6 @@ "xpack.uptime.synthetics.waterfallChart.labels.timings.ssl": "TLS", "xpack.uptime.synthetics.waterfallChart.labels.timings.wait": "等待中 (TTFB)", "xpack.uptime.syntheticsFeatureCatalogueTitle": "Synthetics", - "xpack.uptime.title": "运行时间", "xpack.uptime.tls.ageExpression.description": "或早于以下天数:", "xpack.uptime.tls.criteriaExpression.value": "正在匹配监测", "xpack.uptime.tls.expirationExpression.description": "具有的证书将在以下天数内到期:",