From 7f767791244617ae65f250bfab3e22390112561a Mon Sep 17 00:00:00 2001 From: carlosmonastyrski Date: Thu, 6 Mar 2025 09:17:55 -0300 Subject: [PATCH] Fix frontend type errors --- ...250305131152_add-actor-id-to-secret-versions-v2.ts | 4 ++-- .../components/SecretListView/SecretDetailSidebar.tsx | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/src/db/migrations/20250305131152_add-actor-id-to-secret-versions-v2.ts b/backend/src/db/migrations/20250305131152_add-actor-id-to-secret-versions-v2.ts index e4340a436..25237122b 100644 --- a/backend/src/db/migrations/20250305131152_add-actor-id-to-secret-versions-v2.ts +++ b/backend/src/db/migrations/20250305131152_add-actor-id-to-secret-versions-v2.ts @@ -38,13 +38,13 @@ export async function down(knex: Knex): Promise { }); } - if (!hasSecretVersionV2IdentityActorId) { + if (hasSecretVersionV2IdentityActorId) { await knex.schema.alterTable(TableName.SecretVersionV2, (t) => { t.dropColumn("identityActorId"); }); } - if (!hasSecretVersionV2ActorType) { + if (hasSecretVersionV2ActorType) { await knex.schema.alterTable(TableName.SecretVersionV2, (t) => { t.dropColumn("actorType"); }); diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx index 2f1a178b9..1f8907385 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx @@ -214,7 +214,7 @@ export const SecretDetailSidebar = ({ const secretReminderRepeatDays = watch("reminderRepeatDays"); const secretReminderNote = watch("reminderNote"); - const getModifiedByIcon = (userType: string) => { + const getModifiedByIcon = (userType: string | undefined | null) => { switch (userType) { case ActorType.USER: return faUser; @@ -225,7 +225,7 @@ export const SecretDetailSidebar = ({ } }; - const getModifiedByName = (userType: string, userName: string | undefined) => { + const getModifiedByName = (userType: string | undefined | null, userName: string | null | undefined) => { switch (userType) { case ActorType.PLATFORM: return "System-generated"; @@ -235,7 +235,8 @@ export const SecretDetailSidebar = ({ }; const getUserMembershipId = (actorId: string) => { - return members.filter((member) => member.user?.id === actorId)?.[0].id || null; + const foundMember = members.find((member) => member.user?.id === actorId); + return foundMember?.id || null; }; const getLinkToModifyHistoryEntity = (actorId: string, actorType: string) => { @@ -249,8 +250,8 @@ export const SecretDetailSidebar = ({ } }; - const onModifyHistoryClick = (actorId: string | undefined, actorType: string) => { - if (actorId && actorType !== ActorType.PLATFORM) { + const onModifyHistoryClick = (actorId: string | undefined | null, actorType: string | undefined | null) => { + if (actorType && actorId && actorType !== ActorType.PLATFORM) { const redirectLink = getLinkToModifyHistoryEntity(actorId, actorType); if (redirectLink) { navigate({ to: redirectLink });