Skip to content

Commit

Permalink
fix(routing): fix Link routing when using custom basepath
Browse files Browse the repository at this point in the history
  • Loading branch information
aptmac committed Jan 24, 2025
1 parent a765726 commit 3769602
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export const AppLayout: React.FC<AppLayoutProps> = ({ children }) => {
</MastheadToggle>
<MastheadMain>
<MastheadBrand component={'div'}>
<Link to="/">
<Link to={toPath("/")}>
<Brand alt="Cryostat" src={cryostatLogo} className="cryostat-logo" />
</Link>
</MastheadBrand>
Expand Down
3 changes: 2 additions & 1 deletion src/app/BreadcrumbPage/BreadcrumbPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { toPath } from '@app/utils/utils';
import {
Breadcrumb,
BreadcrumbHeading,
Expand Down Expand Up @@ -40,7 +41,7 @@ export const BreadcrumbPage: React.FC<BreadcrumbPageProps> = ({ pageTitle, bread
<Breadcrumb>
{(breadcrumbs || []).map(({ title, path }) => (
<BreadcrumbItem key={path}>
<Link to={path}>{title}</Link>
<Link to={toPath(path)}>{title}</Link>
</BreadcrumbItem>
))}
<BreadcrumbHeading>{pageTitle}</BreadcrumbHeading>
Expand Down
3 changes: 2 additions & 1 deletion src/app/NotFound/NotFoundCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { toPath } from '@app/utils/utils';
import { Card, CardTitle, CardBody, CardFooter } from '@patternfly/react-core';
import * as React from 'react';
import { Link } from 'react-router-dom-v5-compat';
Expand All @@ -31,7 +32,7 @@ export const NotFoundCard: React.FC<NotFoundCardProps> = ({ title, bodyText, lin
<CardTitle>{title}</CardTitle>
<CardBody isFilled>{bodyText}</CardBody>
<CardFooter>
<Link to={linkPath}>{linkText}</Link>
<Link to={toPath(linkPath)}>{linkText}</Link>
</CardFooter>
</Card>
);
Expand Down
10 changes: 5 additions & 5 deletions src/app/Rules/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MatchExpressionDisplay } from '@app/Shared/Components/MatchExpression/M
import { Rule, NotificationCategory } from '@app/Shared/Services/api.types';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { TableColumn, formatBytes, formatDuration, sortResources, portalRoot } from '@app/utils/utils';
import { TableColumn, formatBytes, formatDuration, sortResources, portalRoot, toPath } from '@app/utils/utils';
import { useCryostatTranslation } from '@i18n/i18nextUtil';
import {
Button,
Expand Down Expand Up @@ -497,10 +497,10 @@ export const RulesTable: React.FC<RulesTableProps> = () => {
<Trans
t={t}
components={[
<Link to={'/recordings'} />,
<Link to={'/events'} />,
<Link to={'/security'} />,
<Link to={'/archives'} />,
<Link to={toPath('/recordings')} />,
<Link to={toPath('/events')} />,
<Link to={toPath('/security')} />,
<Link to={toPath('/archives')} />,
]}
>
Rules.ABOUT_BODY
Expand Down
4 changes: 2 additions & 2 deletions src/app/Topology/Actions/QuickSearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { NotificationsContext } from '@app/Shared/Services/Notifications.service';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useFeatureLevel } from '@app/utils/hooks/useFeatureLevel';
import { portalRoot } from '@app/utils/utils';
import { portalRoot, toPath } from '@app/utils/utils';
import {
Bullseye,
Button,
Expand Down Expand Up @@ -218,7 +218,7 @@ export const QuickSearchModal: React.FC<QuickSearchModalProps> = ({ isOpen, onCl
const description = React.useMemo(() => {
return (
<span>
For quickstarts on how to create these entities, visit <Link to={'/quickstarts'}>Quick Starts</Link>.
For quickstarts on how to create these entities, visit <Link to={toPath('/quickstarts')}>Quick Starts</Link>.
</span>
);
}, []);
Expand Down
3 changes: 2 additions & 1 deletion src/app/Topology/Shared/Components/TopologyEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { topologyDeleteAllFiltersIntent } from '@app/Shared/Redux/ReduxStore';
import { getAllLeaves } from '@app/Shared/Services/api.utils';
import { SearchExprServiceContext } from '@app/Shared/Services/service.utils';
import { toPath } from '@app/utils/utils';
import {
Bullseye,
Button,
Expand Down Expand Up @@ -49,7 +50,7 @@ export const TopologyEmptyState: React.FC<TopologyEmptyStateProps> = ({ ...props
return (
<EmptyStateActions>
Start launching a Java application or define a{' '}
<Link to={'/topology/create-custom-target'}>Custom Target</Link>.
<Link to={toPath('/topology/create-custom-target')}>Custom Target</Link>.
</EmptyStateActions>
);
}
Expand Down

0 comments on commit 3769602

Please sign in to comment.