Skip to content

Commit

Permalink
fix(RHINENG-9046): report details remove Usechrome hook (#1992)
Browse files Browse the repository at this point in the history
* fix(RHINENG-9046): report details remove usechrome hook

* fixed a test

* fixed a test
  • Loading branch information
Fewwy authored Apr 2, 2024
1 parent 8e32ca5 commit 25bd8a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const props = {
report,
kbaDetail: { view_uri: 'https://access.redhat.com/solutions/12345678', publishedTitle: 'Lorem ipsum article' },
kbaLoading: false,
isProd: true,
};

describe('report details: kba loaded', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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 @@ -25,6 +24,7 @@ interface ReportDetailsProps {
view_uri: string;
};
kbaLoading: boolean; // if true, renders skeleton instead of kba link
isProd: boolean;
}

const ReportDetails: React.FC<ReportDetailsProps> = ({
Expand All @@ -35,10 +35,10 @@ const ReportDetails: React.FC<ReportDetailsProps> = ({
view_uri: '',
},
kbaLoading,
isProd,
}) => {
const { rule, details, resolution } = report;
const [error, setError] = useState<Error | null>(null);
const { isProd } = useChrome();

const handleError = (e: Error) => {
if (error === null) {
Expand All @@ -48,7 +48,7 @@ const ReportDetails: React.FC<ReportDetailsProps> = ({

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

0 comments on commit 25bd8a5

Please sign in to comment.