From 0d40be3db14bf0813dfc5f29b9612f6bad1f894f Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 1 Aug 2024 20:43:41 -0600 Subject: [PATCH] refactor: Update APIKeyView and TelemetryIngestionKeyView to use RouteUtil.populateRouteParams This refactor updates the APIKeyView and TelemetryIngestionKeyView components to use the RouteUtil.populateRouteParams function when navigating to other routes. This ensures that route parameters are properly populated, improving the reliability and consistency of the navigation logic. Files modified: - Dashboard/src/Pages/Settings/APIKeyView.tsx - Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx --- Dashboard/src/Pages/Settings/APIKeyView.tsx | 8 ++++++-- .../src/Pages/Settings/TelemetryIngestionKeyView.tsx | 6 ++++-- Ingestor/API/OTelIngest.ts | 12 ++++++++++-- Model/Models/ApiKey.ts | 7 ------- Model/Models/TelemetryIngestionKey.ts | 7 ------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Dashboard/src/Pages/Settings/APIKeyView.tsx b/Dashboard/src/Pages/Settings/APIKeyView.tsx index ad086ccac7..b070233802 100644 --- a/Dashboard/src/Pages/Settings/APIKeyView.tsx +++ b/Dashboard/src/Pages/Settings/APIKeyView.tsx @@ -1,7 +1,7 @@ import LabelsElement from "../../Components/Label/Labels"; import DashboardNavigation from "../../Utils/Navigation"; import PageMap from "../../Utils/PageMap"; -import RouteMap from "../../Utils/RouteMap"; +import RouteMap, { RouteUtil } from "../../Utils/RouteMap"; import PageComponentProps from "../PageComponentProps"; import Route from "Common/Types/API/Route"; import URL from "Common/Types/API/URL"; @@ -353,7 +353,11 @@ const APIKeyView: FunctionComponent = ( modelType={ApiKey} modelId={modelId} onDeleteSuccess={() => { - Navigation.navigate(RouteMap[PageMap.SETTINGS_APIKEYS] as Route); + Navigation.navigate( + RouteUtil.populateRouteParams( + RouteMap[PageMap.SETTINGS_APIKEYS] as Route, + ), + ); }} /> diff --git a/Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx b/Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx index dd76be0713..3e9fa985af 100644 --- a/Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx +++ b/Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx @@ -1,5 +1,5 @@ import PageMap from "../../Utils/PageMap"; -import RouteMap from "../../Utils/RouteMap"; +import RouteMap, { RouteUtil } from "../../Utils/RouteMap"; import PageComponentProps from "../PageComponentProps"; import Route from "Common/Types/API/Route"; import ObjectID from "Common/Types/ObjectID"; @@ -107,7 +107,9 @@ const TelemetryIngestionKeyView: FunctionComponent = ( modelId={modelId} onDeleteSuccess={() => { Navigation.navigate( - RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route, + RouteUtil.populateRouteParams( + RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route, + ), ); }} /> diff --git a/Ingestor/API/OTelIngest.ts b/Ingestor/API/OTelIngest.ts index 37f1bafe56..142a68e3e6 100644 --- a/Ingestor/API/OTelIngest.ts +++ b/Ingestor/API/OTelIngest.ts @@ -858,8 +858,16 @@ const getServiceNameFromAttributes: GetServiceNameFromAttributesFunction = ( attributes: JSONArray, ): string => { for (const attribute of attributes) { - if (attribute["key"] === "service.name") { - return attribute["value"] as string; + if ( + attribute["key"] === "service.name" && + attribute["value"] && + (attribute["value"] as JSONObject)["stringValue"] + ) { + if ( + typeof (attribute["value"] as JSONObject)["stringValue"] === "string" + ) { + return (attribute["value"] as JSONObject)["stringValue"] as string; + } } } diff --git a/Model/Models/ApiKey.ts b/Model/Models/ApiKey.ts index 16884cd1f5..b3b8b11458 100644 --- a/Model/Models/ApiKey.ts +++ b/Model/Models/ApiKey.ts @@ -10,7 +10,6 @@ import ColumnLength from "Common/Types/Database/ColumnLength"; import ColumnType from "Common/Types/Database/ColumnType"; import CrudApiEndpoint from "Common/Types/Database/CrudApiEndpoint"; import EnableDocumentation from "Common/Types/Database/EnableDocumentation"; -import EnableWorkflow from "Common/Types/Database/EnableWorkflow"; import SlugifyColumn from "Common/Types/Database/SlugifyColumn"; import TableColumn from "Common/Types/Database/TableColumn"; import TableColumnType from "Common/Types/Database/TableColumnType"; @@ -34,12 +33,6 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm"; @Entity({ name: "ApiKey", }) -@EnableWorkflow({ - create: true, - delete: true, - update: true, - read: true, -}) @TableAccessControl({ create: [ Permission.ProjectOwner, diff --git a/Model/Models/TelemetryIngestionKey.ts b/Model/Models/TelemetryIngestionKey.ts index c69e28c828..4378a3ec1e 100644 --- a/Model/Models/TelemetryIngestionKey.ts +++ b/Model/Models/TelemetryIngestionKey.ts @@ -8,7 +8,6 @@ import ColumnLength from "Common/Types/Database/ColumnLength"; import ColumnType from "Common/Types/Database/ColumnType"; import CrudApiEndpoint from "Common/Types/Database/CrudApiEndpoint"; import EnableDocumentation from "Common/Types/Database/EnableDocumentation"; -import EnableWorkflow from "Common/Types/Database/EnableWorkflow"; import TableColumn from "Common/Types/Database/TableColumn"; import TableColumnType from "Common/Types/Database/TableColumnType"; import TableMetadata from "Common/Types/Database/TableMetadata"; @@ -24,12 +23,6 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm"; @Entity({ name: "TelemetryIngestionKey", }) -@EnableWorkflow({ - create: true, - delete: true, - update: true, - read: true, -}) @TableAccessControl({ create: [ Permission.ProjectOwner,