Skip to content

Commit

Permalink
fix(advisor components): fixed links to the stage env
Browse files Browse the repository at this point in the history
  • Loading branch information
Fewwy committed Apr 25, 2023
1 parent d093c83 commit 1d05d86
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/advisor-components/src/ReportDetails/ReportDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useState } from 'react';
import { Alert, Card, CardBody, CardHeader, Divider, Stack, StackItem } from '@patternfly/react-core';
import { BullseyeIcon, InfoCircleIcon, LightbulbIcon, ThumbsUpIcon } from '@patternfly/react-icons';
import { Skeleton, SkeletonSize } from '@redhat-cloud-services/frontend-components/Skeleton';
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';

import { RuleContentOcp, RuleContentRhel } from '../types';
import { TemplateProcessor } from '../TemplateProcessor';
Expand All @@ -28,16 +29,21 @@ interface ReportDetailsProps {
const ReportDetails: React.FC<ReportDetailsProps> = ({ report, kbaDetail, kbaLoading }) => {
const { rule, details, resolution } = report;
const [error, setError] = useState<Error | null>(null);
const { isProd } = useChrome();

const handleError = (e: Error) => {
if (error === null) {
setError(e);
}
};

const fixBrokenHydraLink = (url: string) => {
const linkEditor = (url: string) => {
const linkToArray = url.split('/');
return `https://access.redhat.com/solutions/${linkToArray.at(-1)}`;
if (isProd()) {
return `https://access.redhat.com/solutions/${linkToArray.at(-1)}`;
} else {
return `https://access.stage.redhat.com/solutions/${linkToArray.at(-1)}`;
}
};

return (
Expand Down Expand Up @@ -84,7 +90,7 @@ const ReportDetails: React.FC<ReportDetailsProps> = ({ report, kbaDetail, kbaLoa
) : (
<React.Fragment>
<ExternalLink
href={`${kbaDetail?.view_uri?.includes('hydra') ? fixBrokenHydraLink(kbaDetail?.view_uri) : kbaDetail.view_uri}`}
href={`${linkEditor(kbaDetail?.view_uri)}`}
content={kbaDetail.publishedTitle ? kbaDetail.publishedTitle : `Knowledgebase article`}
/>
.
Expand Down

0 comments on commit 1d05d86

Please sign in to comment.