Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/HelpPanel/HelpPanelTabs/APIPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
getBundleData: () => ({ bundleId: 'insights' }),
getAvailableBundles: () => [{ id: 'insights', title: 'RHEL' }],
chromeHistory: { push: jest.fn(), replace: jest.fn() },
drawerActions: { setDrawerPanelContent: jest.fn() },
getEnvironment: () => 'prod',
}),
}));
Expand Down
51 changes: 47 additions & 4 deletions src/components/HelpPanel/HelpPanelTabs/APIPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
fetchBundles,
} from '../../../utils/fetchBundleInfoAPI';
import { getBundleDisplayName } from '../../../utils/bundleUtils';
import useNavigateKeepPanel from '../../../hooks/useNavigateKeepPanel';

interface APIDoc {
name: string;
Expand Down Expand Up @@ -252,10 +253,37 @@ const mapBundleInfoWithTitles = async (): Promise<APIDoc[]> => {

const APIResourceItem: React.FC<{ resource: APIDoc }> = ({ resource }) => {
const chrome = useChrome();
const navigateKeepPanel = useNavigateKeepPanel();

const getConsoleDocsUrl = () => {
const environment = chrome.getEnvironment();
return convertToConsoleDocsUrl(resource.name, resource.url, environment);
const environment = chrome.getEnvironment();
const fullUrl = convertToConsoleDocsUrl(
resource.name,
resource.url,
environment
);

const path = (() => {
try {
const url = new URL(fullUrl);
return `${url.pathname}${url.search}${url.hash}`;
} catch {
return fullUrl;
}
})();

const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
if (
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
) {
return;
}

event.preventDefault();
navigateKeepPanel(path);
};

return (
Expand All @@ -274,7 +302,8 @@ const APIResourceItem: React.FC<{ resource: APIDoc }> = ({ resource }) => {
<Button
variant="link"
component="a"
href={getConsoleDocsUrl()}
href={path}
onClick={handleClick}
isInline
className="pf-v6-u-text-align-left pf-v6-u-p-0"
>
Expand Down Expand Up @@ -303,6 +332,7 @@ const APIPanelContent: React.FC<{
}> = ({ setNewActionTitle }) => {
const intl = useIntl();
const chrome = useChrome();
const navigateKeepPanel = useNavigateKeepPanel();
const [activeToggle, setActiveToggle] = useState<string>('all');
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(10);
Expand Down Expand Up @@ -436,6 +466,19 @@ const APIPanelContent: React.FC<{
variant="link"
component="a"
href="/docs/api"
onClick={(event: React.MouseEvent<HTMLAnchorElement>) => {
if (
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
) {
return;
}
event.preventDefault();
navigateKeepPanel('/docs/api');
}}
data-ouia-component-id="help-panel-api-docs-link"
isInline
>
Expand Down
15 changes: 15 additions & 0 deletions src/components/HelpPanel/HelpPanelTabs/LearnPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
import { suspenseLoader as useSuspenseLoader } from '@redhat-cloud-services/frontend-components-utilities/useSuspenseLoader';
import fetchAllData from '../../../utils/fetchAllData';
import useNavigateKeepPanel from '../../../hooks/useNavigateKeepPanel';
import { ExtendedQuickstart } from '../../../utils/fetchQuickstarts';
import {
BookmarkedIcon,
Expand Down Expand Up @@ -176,6 +177,7 @@ const LearnPanelContent: React.FC<{
}) => {
const intl = useIntl();
const chrome = useChrome();
const navigateKeepPanel = useNavigateKeepPanel();
const { loader, purgeCache } = useSuspenseLoader(fetchAllData);

const CONTENT_TYPE_OPTIONS = [
Expand Down Expand Up @@ -655,6 +657,19 @@ const LearnPanelContent: React.FC<{
variant="link"
component="a"
href="/learning-resources?tab=all"
onClick={(event: React.MouseEvent<HTMLAnchorElement>) => {
if (
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
) {
return;
}
event.preventDefault();
navigateKeepPanel('/learning-resources?tab=all');
}}
isInline
iconPosition="end"
>
Expand Down
Loading