Skip to content

Commit

Permalink
fix(manager-react-components): update eslint error and breadcrumb
Browse files Browse the repository at this point in the history
ref: MANAGER-14535

Signed-off-by: Alex Boungnaseng <[email protected]>
  • Loading branch information
aboungnaseng-ovhcloud committed Jan 15, 2025
1 parent d467824 commit e815d63
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ export interface BreadcrumbProps {
appName: string;
}

export function Breadcrumb({
export const Breadcrumb: React.FC<BreadcrumbProps> = ({
rootLabel,
appName,
}: BreadcrumbProps): JSX.Element {
}) => {
const label = rootLabel;

const breadcrumbItems = useBreadcrumb({
rootLabel: label,
appName,
});

return (
<OdsBreadcrumb>
{breadcrumbItems?.map((item) => (
Expand All @@ -34,4 +32,4 @@ export function Breadcrumb({
))}
</OdsBreadcrumb>
);
}
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Breadcrumb } from './breadcrumb.component';
import {
withRouter,
reactRouterParameters,
} from 'storybook-addon-react-router-v6';
import { Breadcrumb } from './breadcrumb.component';

const BreadcrumbStory = (args) => {
return <Breadcrumb rootLabel={args.rootLabel} appName={args.appName} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { OdsText, OdsButton, OdsMessage } from '@ovhcloud/ods-components/react';
import {
ODS_BUTTON_VARIANT,
ODS_MESSAGE_COLOR,
ODS_TEXT_PRESET,
} from '@ovhcloud/ods-components';
import { PageType } from '@ovh-ux/manager-react-shell-client';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
import { ErrorMessage, TRACKING_LABELS } from './error.types';
import './translations/translations';

import { ErrorBannerProps } from './error.types';
import { useTranslation } from 'react-i18next';
import { PageType, ShellContext } from '@ovh-ux/manager-react-shell-client';

import { ErrorMessage, TRACKING_LABELS, ErrorBannerProps } from './error.types';
import './translations/translations';
import ErrorImg from '../../../../public/assets/error-banner-oops.png';

function getTrackingTypology(error: ErrorMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ describe('useBreadcrumb', () => {
expect(current[0].label).toBe('vrackServices');
expect(current[0].href).toBe('/#/vrack-services/vrackServices');
});

});
describe('useBreadcrumb', () => {
it('should return an array with 3 breadcrumb items', async () => {
beforeEach(() => {
vitest.mock('react-router-dom', async () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export type BreadcrumbItem = {
href?: string;
};

export interface useBreadcrumbProps {
export interface UseBreadcrumbProps {
rootLabel?: string;
appName?: string;
projectId?: string;
items?: BreadcrumbItem[];
}
export const useBreadcrumb = ({ rootLabel, appName }: useBreadcrumbProps) => {
export const useBreadcrumb = ({ rootLabel, appName }: UseBreadcrumbProps) => {
const { shell } = useContext(ShellContext);
const [root, setRoot] = useState<BreadcrumbItem[]>([]);
const [paths, setPaths] = useState<BreadcrumbItem[]>([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Card, OnboardingLayout } from '@ovh-ux/manager-react-components';
import {
Card,
OnboardingLayout,
Breadcrumb,
} from '@ovh-ux/manager-react-components';
import useGuideUtils from '@/hooks/guide/useGuideUtils';
import { Breadcrumb } from '@ovh-ux/manager-react-components';
import onboardingImgSrc from './onboarding-img.png';

import appConfig from '@/{{appName}}.config';
Expand Down

0 comments on commit e815d63

Please sign in to comment.