fix: link dependency coming from react-router-dom

This commit is contained in:
Christian Capeans 2024-04-10 10:59:56 +02:00
parent 316e5189a5
commit 6bf0ee33b0
5 changed files with 28 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import { ContentLayout, EmptyStateLayout, HeaderLayout } from '@strapi/design-sy
import { LinkButton } from '@strapi/design-system/v2'; import { LinkButton } from '@strapi/design-system/v2';
import { ArrowRight, EmptyPictures } from '@strapi/icons'; import { ArrowRight, EmptyPictures } from '@strapi/icons';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import { Page } from '../components/PageHelpers'; import { Page } from '../components/PageHelpers';
@ -27,7 +28,8 @@ export const InternalErrorPage = () => {
<ContentLayout> <ContentLayout>
<EmptyStateLayout <EmptyStateLayout
action={ action={
<LinkButton variant="secondary" endIcon={<ArrowRight />} href="/"> // @ts-expect-error We need to accept the props of the component passed in the `as` prop
<LinkButton as={Link} variant="secondary" endIcon={<ArrowRight />} to="/">
{formatMessage({ {formatMessage({
id: 'app.components.NotFoundPage.back', id: 'app.components.NotFoundPage.back',
defaultMessage: 'Back to homepage', defaultMessage: 'Back to homepage',

View File

@ -8,6 +8,7 @@ import { ContentLayout, EmptyStateLayout, HeaderLayout } from '@strapi/design-sy
import { LinkButton } from '@strapi/design-system/v2'; import { LinkButton } from '@strapi/design-system/v2';
import { ArrowRight, EmptyPictures } from '@strapi/icons'; import { ArrowRight, EmptyPictures } from '@strapi/icons';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import { Page } from '../components/PageHelpers'; import { Page } from '../components/PageHelpers';
@ -26,7 +27,8 @@ export const NotFoundPage = () => {
<ContentLayout> <ContentLayout>
<EmptyStateLayout <EmptyStateLayout
action={ action={
<LinkButton variant="secondary" endIcon={<ArrowRight />} href="/"> // @ts-expect-error We need to accept the props of the component passed in the `as` prop
<LinkButton as={Link} variant="secondary" endIcon={<ArrowRight />} to="/">
{formatMessage({ {formatMessage({
id: 'app.components.NotFoundPage.back', id: 'app.components.NotFoundPage.back',
defaultMessage: 'Back to homepage', defaultMessage: 'Back to homepage',

View File

@ -6,7 +6,7 @@ import { EmptyDocuments, Plus } from '@strapi/icons';
import { Data } from '@strapi/types'; import { Data } from '@strapi/types';
import * as qs from 'qs'; import * as qs from 'qs';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { useGuidedTour } from '../../../../components/GuidedTour/Provider'; import { useGuidedTour } from '../../../../components/GuidedTour/Provider';
import { Page } from '../../../../components/PageHelpers'; import { Page } from '../../../../components/PageHelpers';
@ -147,6 +147,7 @@ export const ListView = () => {
primaryAction={ primaryAction={
canCreate && ( canCreate && (
<LinkButton <LinkButton
as={Link}
data-testid="create-api-token-button" data-testid="create-api-token-button"
startIcon={<Plus />} startIcon={<Plus />}
size="S" size="S"
@ -155,7 +156,8 @@ export const ListView = () => {
tokenType: API_TOKEN_TYPE, tokenType: API_TOKEN_TYPE,
}) })
} }
href="api-tokens/create" // @ts-expect-error We need to accept the props of the component passed in the `as` prop
to="/settings/api-tokens/create"
> >
{formatMessage({ {formatMessage({
id: 'Settings.apiTokens.create', id: 'Settings.apiTokens.create',
@ -188,7 +190,13 @@ export const ListView = () => {
defaultMessage: 'Add your first API Token', defaultMessage: 'Add your first API Token',
})} })}
action={ action={
<LinkButton variant="secondary" startIcon={<Plus />} href="api-tokens/create"> <LinkButton
as={Link}
variant="secondary"
startIcon={<Plus />}
// @ts-expect-error We need to accept the props of the component passed in the `as` prop
to="/settings/api-tokens/create"
>
{formatMessage({ {formatMessage({
id: 'Settings.apiTokens.addNewToken', id: 'Settings.apiTokens.addNewToken',
defaultMessage: 'Add new API Token', defaultMessage: 'Add new API Token',

View File

@ -6,7 +6,7 @@ import { EmptyDocuments, Plus } from '@strapi/icons';
import { Data } from '@strapi/types'; import { Data } from '@strapi/types';
import * as qs from 'qs'; import * as qs from 'qs';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { Page } from '../../../../components/PageHelpers'; import { Page } from '../../../../components/PageHelpers';
import { useTypedSelector } from '../../../../core/store/hooks'; import { useTypedSelector } from '../../../../core/store/hooks';
@ -160,6 +160,7 @@ const ListView = () => {
primaryAction={ primaryAction={
canCreate ? ( canCreate ? (
<LinkButton <LinkButton
forwardedAs={Link}
data-testid="create-transfer-token-button" data-testid="create-transfer-token-button"
startIcon={<Plus />} startIcon={<Plus />}
size="S" size="S"
@ -168,7 +169,8 @@ const ListView = () => {
tokenType: TRANSFER_TOKEN_TYPE, tokenType: TRANSFER_TOKEN_TYPE,
}) })
} }
href="transfer-tokens/create" // @ts-expect-error We need to accept the props of the component passed in the `as` prop
to="/settings/transfer-tokens/create"
> >
{formatMessage({ {formatMessage({
id: 'Settings.transferTokens.create', id: 'Settings.transferTokens.create',
@ -197,9 +199,11 @@ const ListView = () => {
<EmptyStateLayout <EmptyStateLayout
action={ action={
<LinkButton <LinkButton
as={Link}
variant="secondary" variant="secondary"
startIcon={<Plus />} startIcon={<Plus />}
href="transfer-tokens/create" // @ts-expect-error We need to accept the props of the component passed in the `as` prop
to="/settings/transfer-tokens/create"
> >
{formatMessage({ {formatMessage({
id: 'Settings.transferTokens.addNewToken', id: 'Settings.transferTokens.addNewToken',

View File

@ -3,6 +3,7 @@ import { LinkButton } from '@strapi/design-system/v2';
import { EmptyDocuments, Plus } from '@strapi/icons'; import { EmptyDocuments, Plus } from '@strapi/icons';
import * as qs from 'qs'; import * as qs from 'qs';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import styled from 'styled-components'; import styled from 'styled-components';
import { getTrad } from '../../utils'; import { getTrad } from '../../utils';
@ -60,7 +61,9 @@ export const EmptyAttributes = () => {
</Box> </Box>
</Box> </Box>
<LinkButton <LinkButton
href={`/admin/marketplace?${qs.stringify({ categories: ['Custom fields'] })}`} as={Link}
// @ts-expect-error We need to accept the props of the component passed in the `as` prop
to={`/marketplace?${qs.stringify({ categories: ['Custom fields'] })}`}
variant="secondary" variant="secondary"
startIcon={<Plus />} startIcon={<Plus />}
> >