From 06fac716d14cdac475b79d00bbd2c5f27b4de109 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 1 Apr 2025 11:48:35 +0200 Subject: [PATCH] Migrate server-related components to tailwind --- src/servers/CreateServer.tsx | 20 +++++++++++--------- src/servers/EditServer.tsx | 8 ++++---- src/servers/ManageServers.tsx | 12 +++++------- src/servers/helpers/ImportServersBtn.tsx | 5 +++-- src/servers/helpers/ServerError.tsx | 4 ++-- src/servers/helpers/ServerForm.tsx | 18 ++++++++++++------ src/servers/helpers/withSelectedServer.tsx | 2 +- 7 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/servers/CreateServer.tsx b/src/servers/CreateServer.tsx index b8c718fa..fc83e75e 100644 --- a/src/servers/CreateServer.tsx +++ b/src/servers/CreateServer.tsx @@ -1,5 +1,7 @@ import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit'; -import { Result, useToggle } from '@shlinkio/shlink-frontend-kit'; +import { useToggle } from '@shlinkio/shlink-frontend-kit'; +import type { ResultProps } from '@shlinkio/shlink-frontend-kit/tailwind'; +import { Result } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { FC } from 'react'; import { useCallback, useState } from 'react'; import { useNavigate } from 'react-router'; @@ -26,11 +28,11 @@ type CreateServerDeps = { useTimeoutToggle: TimeoutToggle; }; -const ImportResult = ({ type }: { type: 'error' | 'success' }) => ( +const ImportResult = ({ variant }: Pick) => (
- - {type === 'success' && 'Servers properly imported. You can now select one from the list :)'} - {type === 'error' && 'The servers could not be imported. Make sure the format is correct.'} + + {variant === 'success' && 'Servers properly imported. You can now select one from the list :)'} + {variant === 'error' && 'The servers could not be imported. Make sure the format is correct.'}
); @@ -68,16 +70,16 @@ const CreateServer: FCWithDeps = ({ servers return ( - Add new server} onSubmit={onSubmit}> + {!hasServers && ( )} {hasServers && } - + - {serversImported && } - {errorImporting && } + {serversImported && } + {errorImporting && } = withSelectedServ return ( Edit "{selectedServer.name}"} + title={<>Edit "{selectedServer.name}"} initialValues={selectedServer} onSubmit={handleSubmit} > - - + + ); diff --git a/src/servers/ManageServers.tsx b/src/servers/ManageServers.tsx index 25fad262..3cf1fb61 100644 --- a/src/servers/ManageServers.tsx +++ b/src/servers/ManageServers.tsx @@ -1,11 +1,9 @@ import { faFileDownload as exportIcon, faPlus as plusIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit'; -import { Result, SearchField, SimpleCard } from '@shlinkio/shlink-frontend-kit'; +import { Button, Result, SearchInput, SimpleCard } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { FC } from 'react'; import { useMemo, useState } from 'react'; -import { Link } from 'react-router'; -import { Button } from 'reactstrap'; import { NoMenuLayout } from '../common/NoMenuLayout'; import type { FCWithDeps } from '../container/utils'; import { componentFactory, useDependencies } from '../container/utils'; @@ -46,18 +44,18 @@ const ManageServers: FCWithDeps = ({ serv return ( - +
Import servers {filteredServers.length > 0 && ( - )}
-
@@ -83,7 +81,7 @@ const ManageServers: FCWithDeps = ({ serv {errorImporting && (
- The servers could not be imported. Make sure the format is correct. + The servers could not be imported. Make sure the format is correct.
)}
diff --git a/src/servers/helpers/ImportServersBtn.tsx b/src/servers/helpers/ImportServersBtn.tsx index 5010ce59..30fd5717 100644 --- a/src/servers/helpers/ImportServersBtn.tsx +++ b/src/servers/helpers/ImportServersBtn.tsx @@ -1,9 +1,10 @@ import { faFileUpload as importIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useElementRef, useToggle } from '@shlinkio/shlink-frontend-kit'; +import { Button } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { ChangeEvent, PropsWithChildren } from 'react'; import { useCallback, useRef, useState } from 'react'; -import { Button, UncontrolledTooltip } from 'reactstrap'; +import { UncontrolledTooltip } from 'reactstrap'; import type { FCWithDeps } from '../../container/utils'; import { componentFactory, useDependencies } from '../../container/utils'; import type { ServerData, ServersMap, ServerWithId } from '../data'; @@ -83,7 +84,7 @@ const ImportServersBtn: FCWithDeps - diff --git a/src/servers/helpers/ServerError.tsx b/src/servers/helpers/ServerError.tsx index b7504285..16b894d3 100644 --- a/src/servers/helpers/ServerError.tsx +++ b/src/servers/helpers/ServerError.tsx @@ -1,4 +1,4 @@ -import { Message } from '@shlinkio/shlink-frontend-kit'; +import { Message } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { FC } from 'react'; import { Link } from 'react-router'; import { NoMenuLayout } from '../../common/NoMenuLayout'; @@ -25,7 +25,7 @@ const ServerError: FCWithDeps = ({ servers, s return (
- + {!isServerWithId(selectedServer) && 'Could not find this Shlink server.'} {isServerWithId(selectedServer) && ( <> diff --git a/src/servers/helpers/ServerForm.tsx b/src/servers/helpers/ServerForm.tsx index a1b8b53f..00ea2f10 100644 --- a/src/servers/helpers/ServerForm.tsx +++ b/src/servers/helpers/ServerForm.tsx @@ -1,4 +1,4 @@ -import { InputFormGroup, SimpleCard } from '@shlinkio/shlink-frontend-kit'; +import { LabelledInput, SimpleCard } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { FC, PropsWithChildren, ReactNode } from 'react'; import { useState } from 'react'; import { handleEventPreventingDefault } from '../../utils/utils'; @@ -18,13 +18,19 @@ export const ServerForm: FC = ({ onSubmit, initialValues, child return (
- - Name - URL - API key + + setName(e.target.value)} required /> + setUrl(e.target.value)} required /> + setApiKey(e.target.value)} + required + /> -
{children}
+
{children}
); }; diff --git a/src/servers/helpers/withSelectedServer.tsx b/src/servers/helpers/withSelectedServer.tsx index e1b41ba1..b1b86b66 100644 --- a/src/servers/helpers/withSelectedServer.tsx +++ b/src/servers/helpers/withSelectedServer.tsx @@ -1,4 +1,4 @@ -import { Message } from '@shlinkio/shlink-frontend-kit'; +import { Message } from '@shlinkio/shlink-frontend-kit/tailwind'; import type { FC } from 'react'; import { useEffect } from 'react'; import { useParams } from 'react-router';