fix: display aws connection credentials error and sync status on details page

This commit is contained in:
Scott Wilson
2025-01-22 21:00:01 -08:00
parent 0ff18e277f
commit 81420198cb
3 changed files with 43 additions and 33 deletions

View File

@@ -81,11 +81,14 @@ export const getAwsConnectionConfig = async (appConnection: TAwsConnectionConfig
}; };
export const validateAwsConnectionCredentials = async (appConnection: TAwsConnectionConfig) => { export const validateAwsConnectionCredentials = async (appConnection: TAwsConnectionConfig) => {
const awsConfig = await getAwsConnectionConfig(appConnection); let resp: AWS.STS.GetCallerIdentityResponse & {
const sts = new AWS.STS(awsConfig); $response: AWS.Response<AWS.STS.GetCallerIdentityResponse, AWS.AWSError>;
let resp: Awaited<ReturnType<ReturnType<typeof sts.getCallerIdentity>["promise"]>>; };
try { try {
const awsConfig = await getAwsConnectionConfig(appConnection);
const sts = new AWS.STS(awsConfig);
resp = await sts.getCallerIdentity().promise(); resp = await sts.getCallerIdentity().promise();
} catch (e: unknown) { } catch (e: unknown) {
throw new BadRequestError({ throw new BadRequestError({
@@ -93,7 +96,7 @@ export const validateAwsConnectionCredentials = async (appConnection: TAwsConnec
}); });
} }
if (resp.$response.httpResponse.statusCode !== 200) if (resp?.$response.httpResponse.statusCode !== 200)
throw new InternalServerError({ throw new InternalServerError({
message: `Unable to validate credentials: ${ message: `Unable to validate credentials: ${
resp.$response.error?.message ?? resp.$response.error?.message ??

View File

@@ -289,34 +289,36 @@ export const SecretSyncsTable = ({ secretSyncs }: Props) => {
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent className="thin-scrollbar max-h-[70vh] overflow-y-auto" align="end"> <DropdownMenuContent className="thin-scrollbar max-h-[70vh] overflow-y-auto" align="end">
<DropdownMenuLabel>Status</DropdownMenuLabel> <DropdownMenuLabel>Status</DropdownMenuLabel>
{Object.values(SecretSyncStatus).map((status) => ( {[SecretSyncStatus.Running, SecretSyncStatus.Succeeded, SecretSyncStatus.Failed].map(
<DropdownMenuItem (status) => (
onClick={(e) => { <DropdownMenuItem
e.preventDefault(); onClick={(e) => {
setFilters((prev) => ({ e.preventDefault();
...prev, setFilters((prev) => ({
status: prev.status.includes(status) ...prev,
? prev.status.filter((s) => s !== status) status: prev.status.includes(status)
: [...prev.status, status] ? prev.status.filter((s) => s !== status)
})); : [...prev.status, status]
}} }));
key={status} }}
icon={ key={status}
filters.status.includes(status) && ( icon={
<FontAwesomeIcon className="text-primary" icon={faCheckCircle} /> filters.status.includes(status) && (
) <FontAwesomeIcon className="text-primary" icon={faCheckCircle} />
} )
iconPos="right" }
> iconPos="right"
<div className="flex items-center gap-2"> >
<FontAwesomeIcon <div className="flex items-center gap-2">
icon={STATUS_ICON_MAP[status].icon} <FontAwesomeIcon
className={STATUS_ICON_MAP[status].className} icon={STATUS_ICON_MAP[status].icon}
/> className={STATUS_ICON_MAP[status].className}
<span className="capitalize">{STATUS_ICON_MAP[status].name}</span> />
</div> <span className="capitalize">{STATUS_ICON_MAP[status].name}</span>
</DropdownMenuItem> </div>
))} </DropdownMenuItem>
)
)}
<DropdownMenuLabel>Service</DropdownMenuLabel> <DropdownMenuLabel>Service</DropdownMenuLabel>
{secretSyncs.length ? ( {secretSyncs.length ? (
[...new Set(secretSyncs.map(({ destination }) => destination))].map((destination) => { [...new Set(secretSyncs.map(({ destination }) => destination))].map((destination) => {

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { format } from "date-fns"; import { format } from "date-fns";
import { ProjectPermissionCan } from "@app/components/permissions"; import { ProjectPermissionCan } from "@app/components/permissions";
import { SecretSyncLabel } from "@app/components/secret-syncs"; import { SecretSyncLabel, SecretSyncStatusBadge } from "@app/components/secret-syncs";
import { IconButton } from "@app/components/v2"; import { IconButton } from "@app/components/v2";
import { ProjectPermissionSub } from "@app/context"; import { ProjectPermissionSub } from "@app/context";
import { ProjectPermissionSecretSyncActions } from "@app/context/ProjectPermissionContext/types"; import { ProjectPermissionSecretSyncActions } from "@app/context/ProjectPermissionContext/types";
@@ -57,6 +57,11 @@ export const SecretSyncDetailsSection = ({ secretSync, onEditDetails }: Props) =
<div className="space-y-3"> <div className="space-y-3">
<SecretSyncLabel label="Name">{name}</SecretSyncLabel> <SecretSyncLabel label="Name">{name}</SecretSyncLabel>
<SecretSyncLabel label="Description">{description}</SecretSyncLabel> <SecretSyncLabel label="Description">{description}</SecretSyncLabel>
{syncStatus && (
<SecretSyncLabel label="Status">
<SecretSyncStatusBadge status={syncStatus} />
</SecretSyncLabel>
)}
{lastSyncedAt && ( {lastSyncedAt && (
<SecretSyncLabel label="Last Synced"> <SecretSyncLabel label="Last Synced">
{format(new Date(lastSyncedAt), "yyyy-MM-dd, hh:mm aaa")} {format(new Date(lastSyncedAt), "yyyy-MM-dd, hh:mm aaa")}