From b9e5358cd7401529517fb25a23504e1b94e1ab1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 28 Apr 2024 14:58:09 +0200 Subject: [PATCH] Remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/__fixtures__/rules.json | 4 +- src/api/hooks/admin/useCreateDomain.ts | 23 ------ src/api/hooks/admin/useDeleteDomain.ts | 21 ------ src/api/hooks/admin/useUpdateDomain.ts | 20 ----- src/components/display-name.test.tsx | 15 ---- src/components/display-name.tsx | 49 ------------ src/components/pullable.tsx | 23 ------ src/components/validation-checkmark.test.tsx | 30 -------- src/components/validation-checkmark.tsx | 28 ------- .../discover/group-grid-item.test.tsx | 21 ------ .../components/discover/group-grid-item.tsx | 74 ------------------- .../discover/layout-buttons.test.tsx | 38 ---------- .../components/discover/layout-buttons.tsx | 48 ------------ src/features/groups/components/tab-bar.tsx | 41 ---------- .../mutes/components/group-list-item.tsx | 28 ------- .../components/placeholder-group-discover.tsx | 38 ---------- .../placeholder-material-status.tsx | 16 ---- src/styles/application.scss | 1 - src/styles/components/display-name.scss | 18 ----- src/utils/phone.ts | 19 ----- 20 files changed, 2 insertions(+), 553 deletions(-) delete mode 100644 src/api/hooks/admin/useCreateDomain.ts delete mode 100644 src/api/hooks/admin/useDeleteDomain.ts delete mode 100644 src/api/hooks/admin/useUpdateDomain.ts delete mode 100644 src/components/display-name.test.tsx delete mode 100644 src/components/display-name.tsx delete mode 100644 src/components/pullable.tsx delete mode 100644 src/components/validation-checkmark.test.tsx delete mode 100644 src/components/validation-checkmark.tsx delete mode 100644 src/features/groups/components/discover/group-grid-item.test.tsx delete mode 100644 src/features/groups/components/discover/group-grid-item.tsx delete mode 100644 src/features/groups/components/discover/layout-buttons.test.tsx delete mode 100644 src/features/groups/components/discover/layout-buttons.tsx delete mode 100644 src/features/groups/components/tab-bar.tsx delete mode 100644 src/features/mutes/components/group-list-item.tsx delete mode 100644 src/features/placeholder/components/placeholder-group-discover.tsx delete mode 100644 src/features/placeholder/components/placeholder-material-status.tsx delete mode 100644 src/styles/components/display-name.scss delete mode 100644 src/utils/phone.ts diff --git a/src/__fixtures__/rules.json b/src/__fixtures__/rules.json index b26807ce8..f5f3756f9 100644 --- a/src/__fixtures__/rules.json +++ b/src/__fixtures__/rules.json @@ -2,11 +2,11 @@ { "id": "1", "text": "Illegal activity and behavior", - "subtext": "Content that depicts illegal or criminal acts, threats of violence.", + "subtext": "Content that depicts illegal or criminal acts, threats of violence." }, { "id": "2", "text": "Intellectual property infringement", - "subtext": "Impersonating another account or business, infringing on intellectual property rights.", + "subtext": "Impersonating another account or business, infringing on intellectual property rights." } ] diff --git a/src/api/hooks/admin/useCreateDomain.ts b/src/api/hooks/admin/useCreateDomain.ts deleted file mode 100644 index 5897fda19..000000000 --- a/src/api/hooks/admin/useCreateDomain.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Entities } from 'soapbox/entity-store/entities'; -import { useCreateEntity } from 'soapbox/entity-store/hooks'; -import { useApi } from 'soapbox/hooks'; -import { domainSchema } from 'soapbox/schemas'; - -interface CreateDomainParams { - domain: string; - public: boolean; -} - -const useCreateDomain = () => { - const api = useApi(); - - const { createEntity, ...rest } = useCreateEntity([Entities.DOMAINS], (params: CreateDomainParams) => - api.post('/api/v1/pleroma/admin/domains', params), { schema: domainSchema }); - - return { - createDomain: createEntity, - ...rest, - }; -}; - -export { useCreateDomain, type CreateDomainParams }; diff --git a/src/api/hooks/admin/useDeleteDomain.ts b/src/api/hooks/admin/useDeleteDomain.ts deleted file mode 100644 index 05aeb70e8..000000000 --- a/src/api/hooks/admin/useDeleteDomain.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Entities } from 'soapbox/entity-store/entities'; -import { useDeleteEntity } from 'soapbox/entity-store/hooks'; -import { useApi } from 'soapbox/hooks'; - -const useDeleteDomain = () => { - const api = useApi(); - - const { deleteEntity, ...rest } = useDeleteEntity(Entities.DOMAINS, (id: string) => - api.delete(`/api/v1/pleroma/admin/domains/${id}`, { - headers: { - 'Content-Type': 'multipart/form-data', - }, - })); - - return { - mutate: deleteEntity, - ...rest, - }; -}; - -export { useDeleteDomain }; diff --git a/src/api/hooks/admin/useUpdateDomain.ts b/src/api/hooks/admin/useUpdateDomain.ts deleted file mode 100644 index 8ca27ba97..000000000 --- a/src/api/hooks/admin/useUpdateDomain.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Entities } from 'soapbox/entity-store/entities'; -import { useCreateEntity } from 'soapbox/entity-store/hooks'; -import { useApi } from 'soapbox/hooks'; -import { domainSchema } from 'soapbox/schemas'; - -import type { CreateDomainParams } from './useCreateDomain'; - -const useUpdateDomain = (id: string) => { - const api = useApi(); - - const { createEntity, ...rest } = useCreateEntity([Entities.DOMAINS], (params: Omit) => - api.patch(`/api/v1/pleroma/admin/domains/${id}`, params), { schema: domainSchema }); - - return { - updateDomain: createEntity, - ...rest, - }; -}; - -export { useUpdateDomain }; diff --git a/src/components/display-name.test.tsx b/src/components/display-name.test.tsx deleted file mode 100644 index 7c819f637..000000000 --- a/src/components/display-name.test.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; - -import { buildAccount } from 'soapbox/jest/factory'; -import { render, screen } from 'soapbox/jest/test-helpers'; - -import DisplayName from './display-name'; - -describe('', () => { - it('renders display name + account name', () => { - const account = buildAccount({ acct: 'bar@baz' }); - render(); - - expect(screen.getByTestId('display-name')).toHaveTextContent('bar@baz'); - }); -}); diff --git a/src/components/display-name.tsx b/src/components/display-name.tsx deleted file mode 100644 index bb6c8816b..000000000 --- a/src/components/display-name.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; - -import HoverRefWrapper from 'soapbox/components/hover-ref-wrapper'; -import { useSoapboxConfig } from 'soapbox/hooks'; - -import { getAcct } from '../utils/accounts'; - -import { HStack, Text } from './ui'; -import VerificationBadge from './verification-badge'; - -import type { Account } from 'soapbox/schemas'; - -interface IDisplayName { - account: Pick; - withSuffix?: boolean; - children?: React.ReactNode; -} - -const DisplayName: React.FC = ({ account, children, withSuffix = true }) => { - const { displayFqn = false } = useSoapboxConfig(); - const { verified } = account; - - const displayName = ( - - - - {verified && } - - ); - - const suffix = (@{getAcct(account, displayFqn)}); - - return ( - - - {displayName} - - {withSuffix && suffix} - {children} - - ); -}; - -export default DisplayName; diff --git a/src/components/pullable.tsx b/src/components/pullable.tsx deleted file mode 100644 index e92a76ea2..000000000 --- a/src/components/pullable.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; - -import PullToRefresh from './pull-to-refresh'; - -interface IPullable { - children: React.ReactNode; -} - -/** - * Pullable: - * Basic "pull to refresh" without the refresh. - * Just visual feedback. - */ -const Pullable: React.FC = ({ children }) =>( - - {children} - -); - -export default Pullable; diff --git a/src/components/validation-checkmark.test.tsx b/src/components/validation-checkmark.test.tsx deleted file mode 100644 index fd0d4b765..000000000 --- a/src/components/validation-checkmark.test.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; - -import { render, screen } from 'soapbox/jest/test-helpers'; - -import ValidationCheckmark from './validation-checkmark'; - -describe('', () => { - it('renders text', () => { - const text = 'some validation'; - render(); - - expect(screen.getByTestId('validation-checkmark')).toHaveTextContent(text); - }); - - it('uses a green check when valid', () => { - const text = 'some validation'; - render(); - - expect(screen.getByTestId('svg-icon-loader')).toHaveClass('text-success-500'); - expect(screen.getByTestId('svg-icon-loader')).not.toHaveClass('text-gray-400'); - }); - - it('uses a gray check when valid', () => { - const text = 'some validation'; - render(); - - expect(screen.getByTestId('svg-icon-loader')).toHaveClass('text-gray-400'); - expect(screen.getByTestId('svg-icon-loader')).not.toHaveClass('text-success-500'); - }); -}); diff --git a/src/components/validation-checkmark.tsx b/src/components/validation-checkmark.tsx deleted file mode 100644 index cb4e06816..000000000 --- a/src/components/validation-checkmark.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -import { HStack, Icon, Text } from 'soapbox/components/ui'; - -interface IValidationCheckmark { - isValid: boolean; - text: string; -} - -const ValidationCheckmark = ({ isValid, text }: IValidationCheckmark) => { - return ( - - - - {text} - - ); -}; - -export default ValidationCheckmark; diff --git a/src/features/groups/components/discover/group-grid-item.test.tsx b/src/features/groups/components/discover/group-grid-item.test.tsx deleted file mode 100644 index 054335dbe..000000000 --- a/src/features/groups/components/discover/group-grid-item.test.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; - -import { buildGroup } from 'soapbox/jest/factory'; -import { render, screen } from 'soapbox/jest/test-helpers'; - -import GroupGridItem from './group-grid-item'; - -describe(' { - it('should render correctly', () => { - const group = buildGroup({ - display_name: 'group name here', - locked: false, - members_count: 6, - }); - render(); - - expect(screen.getByTestId('group-grid-item')).toHaveTextContent(group.display_name); - expect(screen.getByTestId('group-grid-item')).toHaveTextContent('Public'); - expect(screen.getByTestId('group-grid-item')).toHaveTextContent('6 members'); - }); -}); \ No newline at end of file diff --git a/src/features/groups/components/discover/group-grid-item.tsx b/src/features/groups/components/discover/group-grid-item.tsx deleted file mode 100644 index 900e5bdef..000000000 --- a/src/features/groups/components/discover/group-grid-item.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import React, { forwardRef } from 'react'; -import { Link } from 'react-router-dom'; - -import GroupAvatar from 'soapbox/components/groups/group-avatar'; -import { HStack, Stack, Text } from 'soapbox/components/ui'; -import GroupActionButton from 'soapbox/features/group/components/group-action-button'; -import GroupHeaderImage from 'soapbox/features/group/components/group-header-image'; -import GroupMemberCount from 'soapbox/features/group/components/group-member-count'; -import GroupPrivacy from 'soapbox/features/group/components/group-privacy'; - -import type { Group } from 'soapbox/schemas'; - -interface IGroup { - group: Group; - width?: number; -} - -const GroupGridItem = forwardRef((props: IGroup, ref: React.ForwardedRef) => { - const { group, width = 'auto' } = props; - - return ( -
- - - - -
- - - - - - - - - - - - - - - - - - -
- ); -}); - -export default GroupGridItem; \ No newline at end of file diff --git a/src/features/groups/components/discover/layout-buttons.test.tsx b/src/features/groups/components/discover/layout-buttons.test.tsx deleted file mode 100644 index a372d8058..000000000 --- a/src/features/groups/components/discover/layout-buttons.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import userEvent from '@testing-library/user-event'; -import React from 'react'; - -import { render, screen, within } from 'soapbox/jest/test-helpers'; - -import LayoutButtons, { GroupLayout } from './layout-buttons'; - -describe(' { - describe('when LIST view', () => { - it('should render correctly', async () => { - const onSelectFn = vi.fn(); - const user = userEvent.setup(); - - render(); - - expect(within(screen.getByTestId('layout-list-action')).getByTestId('svg-icon-loader')).toHaveClass('text-primary-600'); - expect(within(screen.getByTestId('layout-grid-action')).getByTestId('svg-icon-loader')).not.toHaveClass('text-primary-600'); - - await user.click(screen.getByTestId('layout-grid-action')); - expect(onSelectFn).toHaveBeenCalled(); - }); - }); - - describe('when GRID view', () => { - it('should render correctly', async () => { - const onSelectFn = vi.fn(); - const user = userEvent.setup(); - - render(); - - expect(within(screen.getByTestId('layout-list-action')).getByTestId('svg-icon-loader')).not.toHaveClass('text-primary-600'); - expect(within(screen.getByTestId('layout-grid-action')).getByTestId('svg-icon-loader')).toHaveClass('text-primary-600'); - - await user.click(screen.getByTestId('layout-grid-action')); - expect(onSelectFn).toHaveBeenCalled(); - }); - }); -}); \ No newline at end of file diff --git a/src/features/groups/components/discover/layout-buttons.tsx b/src/features/groups/components/discover/layout-buttons.tsx deleted file mode 100644 index fce0ad711..000000000 --- a/src/features/groups/components/discover/layout-buttons.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -import { HStack, Icon } from 'soapbox/components/ui'; - -enum GroupLayout { - LIST = 'LIST', - GRID = 'GRID' -} - -interface ILayoutButtons { - layout: GroupLayout; - onSelect(layout: GroupLayout): void; -} - -const LayoutButtons = ({ layout, onSelect }: ILayoutButtons) => ( - - - - - -); - -export { LayoutButtons as default, GroupLayout }; \ No newline at end of file diff --git a/src/features/groups/components/tab-bar.tsx b/src/features/groups/components/tab-bar.tsx deleted file mode 100644 index 4d358db9c..000000000 --- a/src/features/groups/components/tab-bar.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React, { useMemo } from 'react'; -import { useHistory } from 'react-router-dom'; - -import { Tabs } from 'soapbox/components/ui'; - -import type { Item } from 'soapbox/components/ui/tabs/tabs'; - -export enum TabItems { - MY_GROUPS = 'MY_GROUPS', - FIND_GROUPS = 'FIND_GROUPS' -} - -interface ITabBar { - activeTab: TabItems; -} - -const TabBar = ({ activeTab }: ITabBar) => { - const history = useHistory(); - - const tabItems: Item[] = useMemo(() => ([ - { - text: 'My Groups', - action: () => history.push('/groups'), - name: TabItems.MY_GROUPS, - }, - { - text: 'Find Groups', - action: () => history.push('/groups/discover'), - name: TabItems.FIND_GROUPS, - }, - ]), []); - - return ( - - ); -}; - -export default TabBar; \ No newline at end of file diff --git a/src/features/mutes/components/group-list-item.tsx b/src/features/mutes/components/group-list-item.tsx deleted file mode 100644 index e71b10f4d..000000000 --- a/src/features/mutes/components/group-list-item.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; - -import GroupAvatar from 'soapbox/components/groups/group-avatar'; -import { HStack, Text } from 'soapbox/components/ui'; -import { type Group } from 'soapbox/schemas'; - -interface IGroupListItem { - group: Group; - onUnmute(): void; -} - -const GroupListItem = ({ group, onUnmute }: IGroupListItem) => ( - - - - - -); - -export default GroupListItem; \ No newline at end of file diff --git a/src/features/placeholder/components/placeholder-group-discover.tsx b/src/features/placeholder/components/placeholder-group-discover.tsx deleted file mode 100644 index 468cb5481..000000000 --- a/src/features/placeholder/components/placeholder-group-discover.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; - -import { HStack, Stack, Text } from 'soapbox/components/ui'; - -import { generateText, randomIntFromInterval } from '../utils'; - -const PlaceholderGroupDiscover = () => { - const groupNameLength = randomIntFromInterval(12, 20); - - return ( - - - {/* Group Cover Image */} -
- - - {/* Group Avatar */} -
- - {/* Group Info */} - - {generateText(groupNameLength)} - - - {generateText(6)} - {generateText(6)} - - - - - - {/* Join Group Button */} -
- - ); -}; - -export default PlaceholderGroupDiscover; diff --git a/src/features/placeholder/components/placeholder-material-status.tsx b/src/features/placeholder/components/placeholder-material-status.tsx deleted file mode 100644 index e3b289d70..000000000 --- a/src/features/placeholder/components/placeholder-material-status.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; - -import PlaceholderStatus from './placeholder-status'; - -/** Fake material status to display while data is loading. */ -const PlaceholderMaterialStatus: React.FC = () => { - return ( -
-
- -
-
- ); -}; - -export default PlaceholderMaterialStatus; diff --git a/src/styles/application.scss b/src/styles/application.scss index f0a17c975..b23e1095a 100644 --- a/src/styles/application.scss +++ b/src/styles/application.scss @@ -18,7 +18,6 @@ @import 'components/detailed-status'; @import 'components/media-gallery'; @import 'components/notification'; -@import 'components/display-name'; @import 'components/columns'; @import 'components/search'; @import 'components/video-player'; diff --git a/src/styles/components/display-name.scss b/src/styles/components/display-name.scss deleted file mode 100644 index fca752408..000000000 --- a/src/styles/components/display-name.scss +++ /dev/null @@ -1,18 +0,0 @@ -.display-name { - display: block; - max-width: 100%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - position: relative; - - bdi { - min-width: 0; - } - - &__account { - position: relative; - font-weight: 600; - font-size: 14px; - } -} diff --git a/src/utils/phone.ts b/src/utils/phone.ts deleted file mode 100644 index 8fde39f12..000000000 --- a/src/utils/phone.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** List of supported E164 country codes. */ -const COUNTRY_CODES = [ - '1', - '351', - '44', - '55', -] as const; - -/** Supported E164 country code. */ -type CountryCode = typeof COUNTRY_CODES[number]; - -/** Check whether a given value is a country code. */ -const isCountryCode = (value: any): value is CountryCode => COUNTRY_CODES.includes(value); - -export { - COUNTRY_CODES, - CountryCode, - isCountryCode, -};