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
This commit is contained in:
Simon Larsen 2024-08-01 20:43:41 -06:00
parent 6754167e57
commit 0d40be3db1
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
5 changed files with 20 additions and 20 deletions

View File

@ -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<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>

View File

@ -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<PageComponentProps> = (
modelId={modelId}
onDeleteSuccess={() => {
Navigation.navigate(
RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route,
RouteUtil.populateRouteParams(
RouteMap[PageMap.SETTINGS_TELEMETRY_INGESTION_KEYS] as Route,
),
);
}}
/>

View File

@ -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;
}
}
}

View File

@ -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,

View File

@ -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,