Skip to content

Commit

Permalink
refactor: Update APIKeyView and TelemetryIngestionKeyView to use Rout…
Browse files Browse the repository at this point in the history
…eUtil.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
  • Loading branch information
simlarsen committed Aug 2, 2024
1 parent 6754167 commit 0d40be3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 6 additions & 2 deletions Dashboard/src/Pages/Settings/APIKeyView.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -353,7 +353,11 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
modelType={ApiKey}
modelId={modelId}
onDeleteSuccess={() => {
Navigation.navigate(RouteMap[PageMap.SETTINGS_APIKEYS] as Route);
Navigation.navigate(
RouteUtil.populateRouteParams(
RouteMap[PageMap.SETTINGS_APIKEYS] as Route,
),
);
}}
/>
</Fragment>
Expand Down
6 changes: 4 additions & 2 deletions Dashboard/src/Pages/Settings/TelemetryIngestionKeyView.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -107,7 +107,9 @@ const TelemetryIngestionKeyView: FunctionComponent<PageComponentProps> = (
modelId={modelId}
onDeleteSuccess={() => {
Navigation.navigate(
RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route,
RouteUtil.populateRouteParams(
RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route,
),
);
}}
/>
Expand Down
12 changes: 10 additions & 2 deletions Ingestor/API/OTelIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions Model/Models/ApiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions Model/Models/TelemetryIngestionKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down

0 comments on commit 0d40be3

Please sign in to comment.