Skip to content

Commit

Permalink
chore: Refactor storage route to handle S3 endpoint disablement
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkrumbach07 committed Jun 4, 2024
1 parent 02849a7 commit 6d7d3aa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
31 changes: 17 additions & 14 deletions backend/src/routes/api/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { getAccessToken } from '../../../utils/directCallUtils';
import { OauthFastifyRequest } from '../../../types';

export default async (fastify: FastifyInstance): Promise<void> => {
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;
Expand Down Expand Up @@ -56,7 +56,10 @@ export default async (fastify: FastifyInstance): Promise<void> => {
reply.code(500).send(err.message);
return reply;
}
},
);
}
} else {
reply.code(404).send('Not found');
return reply;
}
},
);
};
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -38,9 +37,14 @@ export const ArtifactUriLink: React.FC<ArtifactUriLinkProps> = ({
</SplitItem>
{directDownload && (
<SplitItem>
<Link target="_blank" rel="noopener noreferrer" to={url} download>
<DownloadIcon />
</Link>
<Button
variant="link"
isInline
href={url}
download
icon={<DownloadIcon />}
iconPosition="right"
/>
</SplitItem>
)}
</Split>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const PipelineTaskDetails: React.FC<TaskDetailsProps> = ({ task }) => {
<StackItem>
<TaskDetailsInputOutput
type="Input"
artifacts={task.inputs.artifacts?.map((a) => ({ label: a.label, value: a.type }))}
artifacts={task.inputs.artifacts}
params={task.inputs.params?.map((p) => ({ label: p.label, value: p.value ?? p.type }))}
/>
</StackItem>
Expand All @@ -41,7 +41,7 @@ const PipelineTaskDetails: React.FC<TaskDetailsProps> = ({ task }) => {
<StackItem>
<TaskDetailsInputOutput
type="Output"
artifacts={task.outputs.artifacts?.map((a) => ({ label: a.label, value: a.type }))}
artifacts={task.outputs.artifacts}
params={task.outputs.params?.map((p) => ({ label: p.label, value: p.value ?? p.type }))}
/>
</StackItem>
Expand Down

0 comments on commit 6d7d3aa

Please sign in to comment.