From 6d7d3aa0f2f65071bdf1b4ccdbf0e44b5e25e62e Mon Sep 17 00:00:00 2001 From: Gage Krumbach Date: Tue, 4 Jun 2024 17:22:13 -0500 Subject: [PATCH] chore: Refactor storage route to handle S3 endpoint disablement --- backend/src/routes/api/storage/index.ts | 31 ++++++++++--------- .../content/artifacts/ArtifactUriLink.tsx | 14 ++++++--- .../pipeline/PipelineTaskDetails.tsx | 4 +-- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/backend/src/routes/api/storage/index.ts b/backend/src/routes/api/storage/index.ts index a3a1c09f48..4a71904ecd 100644 --- a/backend/src/routes/api/storage/index.ts +++ b/backend/src/routes/api/storage/index.ts @@ -6,17 +6,17 @@ import { getAccessToken } from '../../../utils/directCallUtils'; import { OauthFastifyRequest } from '../../../types'; export default async (fastify: FastifyInstance): Promise => { - const dashConfig = getDashboardConfig(); - if (dashConfig?.spec.dashboardConfig.disableS3Endpoint === false) { - fastify.get( - '/:namespace/:bucket', - async ( - request: OauthFastifyRequest<{ - Querystring: { key: string; peek?: number }; - Params: { namespace: string; bucket: string }; - }>, - reply: FastifyReply, - ) => { + fastify.get( + '/:namespace/:bucket', + async ( + request: OauthFastifyRequest<{ + Querystring: { key: string; peek?: number }; + Params: { namespace: string; bucket: string }; + }>, + reply: FastifyReply, + ) => { + const dashConfig = getDashboardConfig(); + if (dashConfig?.spec.dashboardConfig.disableS3Endpoint === false) { try { const { namespace, bucket } = request.params; const { key, peek } = request.query; @@ -56,7 +56,10 @@ export default async (fastify: FastifyInstance): Promise => { reply.code(500).send(err.message); return reply; } - }, - ); - } + } else { + reply.code(404).send('Not found'); + return reply; + } + }, + ); }; diff --git a/frontend/src/concepts/pipelines/content/artifacts/ArtifactUriLink.tsx b/frontend/src/concepts/pipelines/content/artifacts/ArtifactUriLink.tsx index 4e6bc219c9..d15ddc2a63 100644 --- a/frontend/src/concepts/pipelines/content/artifacts/ArtifactUriLink.tsx +++ b/frontend/src/concepts/pipelines/content/artifacts/ArtifactUriLink.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { Link } from 'react-router-dom'; -import { Split, SplitItem } from '@patternfly/react-core'; +import { Button, Split, SplitItem } from '@patternfly/react-core'; import { DownloadIcon } from '@patternfly/react-icons'; import { usePipelinesAPI } from '~/concepts/pipelines/context'; import { useIsAreaAvailable, SupportedArea } from '~/concepts/areas'; @@ -38,9 +37,14 @@ export const ArtifactUriLink: React.FC = ({ {directDownload && ( - - - +