From d4980feed6fe520c3e6d1fef3e447489c0a10fa2 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:50:10 +0900 Subject: [PATCH 1/9] refactor: DrawerLoading --- .../ui/components/{drawer_loading.jsx => drawer_loading.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/javascript/mastodon/features/ui/components/{drawer_loading.jsx => drawer_loading.tsx} (100%) diff --git a/app/javascript/mastodon/features/ui/components/drawer_loading.jsx b/app/javascript/mastodon/features/ui/components/drawer_loading.tsx similarity index 100% rename from app/javascript/mastodon/features/ui/components/drawer_loading.jsx rename to app/javascript/mastodon/features/ui/components/drawer_loading.tsx From aafe85acaa5d5302b697a67283e22bfcf731df1c Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:50:24 +0900 Subject: [PATCH 2/9] refactor: Compose --- .../mastodon/features/standalone/compose/{index.jsx => index.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/javascript/mastodon/features/standalone/compose/{index.jsx => index.tsx} (100%) diff --git a/app/javascript/mastodon/features/standalone/compose/index.jsx b/app/javascript/mastodon/features/standalone/compose/index.tsx similarity index 100% rename from app/javascript/mastodon/features/standalone/compose/index.jsx rename to app/javascript/mastodon/features/standalone/compose/index.tsx From 85e89dfc165a5c422d5f6225ee585224543072f0 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:50:38 +0900 Subject: [PATCH 3/9] refactor: ColumnSubheading --- .../features/ui/components/column_subheading.jsx | 15 --------------- .../features/ui/components/column_subheading.tsx | 11 +++++++++++ 2 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 app/javascript/mastodon/features/ui/components/column_subheading.jsx create mode 100644 app/javascript/mastodon/features/ui/components/column_subheading.tsx diff --git a/app/javascript/mastodon/features/ui/components/column_subheading.jsx b/app/javascript/mastodon/features/ui/components/column_subheading.jsx deleted file mode 100644 index e970a0bfdd..0000000000 --- a/app/javascript/mastodon/features/ui/components/column_subheading.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import PropTypes from 'prop-types'; - -const ColumnSubheading = ({ text }) => { - return ( -
- {text} -
- ); -}; - -ColumnSubheading.propTypes = { - text: PropTypes.string.isRequired, -}; - -export default ColumnSubheading; diff --git a/app/javascript/mastodon/features/ui/components/column_subheading.tsx b/app/javascript/mastodon/features/ui/components/column_subheading.tsx new file mode 100644 index 0000000000..655cfe1da9 --- /dev/null +++ b/app/javascript/mastodon/features/ui/components/column_subheading.tsx @@ -0,0 +1,11 @@ +import React from 'react'; + +interface Props { + text: string; +} + +const ColumnSubheading: React.FC = ({ text }) => { + return
{text}
; +}; + +export default ColumnSubheading; From a97ee55650ba15442d13c96212c7f0a7c165299b Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:51:13 +0900 Subject: [PATCH 4/9] refactor: GrantPermissionButton --- .../components/grant_permission_button.jsx | 20 ---------------- .../components/grant_permission_button.tsx | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 20 deletions(-) delete mode 100644 app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx create mode 100644 app/javascript/mastodon/features/notifications/components/grant_permission_button.tsx diff --git a/app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx b/app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx deleted file mode 100644 index cd46d878bb..0000000000 --- a/app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; - -import { FormattedMessage } from 'react-intl'; - -export default class GrantPermissionButton extends PureComponent { - - static propTypes = { - onClick: PropTypes.func.isRequired, - }; - - render () { - return ( - - ); - } - -} diff --git a/app/javascript/mastodon/features/notifications/components/grant_permission_button.tsx b/app/javascript/mastodon/features/notifications/components/grant_permission_button.tsx new file mode 100644 index 0000000000..3e160cb0d0 --- /dev/null +++ b/app/javascript/mastodon/features/notifications/components/grant_permission_button.tsx @@ -0,0 +1,23 @@ +import { MouseEventHandler } from 'react'; +import { FormattedMessage } from 'react-intl'; + +interface Props { + onClick: MouseEventHandler; +} + +const GrantPermissionButton: React.FC = ({ onClick }) => { + return ( + + ); +}; + +export default GrantPermissionButton; From 70085dd2ed3e05ab79cbdf887877c71a95abf2e1 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:58:33 +0900 Subject: [PATCH 5/9] refactor: ClearColumnButton --- .../components/clear_column_button.jsx | 21 --------------- .../components/clear_column_button.tsx | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) delete mode 100644 app/javascript/mastodon/features/notifications/components/clear_column_button.jsx create mode 100644 app/javascript/mastodon/features/notifications/components/clear_column_button.tsx diff --git a/app/javascript/mastodon/features/notifications/components/clear_column_button.jsx b/app/javascript/mastodon/features/notifications/components/clear_column_button.jsx deleted file mode 100644 index 73eaecba59..0000000000 --- a/app/javascript/mastodon/features/notifications/components/clear_column_button.jsx +++ /dev/null @@ -1,21 +0,0 @@ -import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; - -import { FormattedMessage } from 'react-intl'; - -import DeleteForeverIcon from '@/material-icons/400-24px/delete_forever.svg?react'; -import { Icon } from 'mastodon/components/icon'; - -export default class ClearColumnButton extends PureComponent { - - static propTypes = { - onClick: PropTypes.func.isRequired, - }; - - render () { - return ( - - ); - } - -} diff --git a/app/javascript/mastodon/features/notifications/components/clear_column_button.tsx b/app/javascript/mastodon/features/notifications/components/clear_column_button.tsx new file mode 100644 index 0000000000..bdfa9f4bf5 --- /dev/null +++ b/app/javascript/mastodon/features/notifications/components/clear_column_button.tsx @@ -0,0 +1,27 @@ +import React, { MouseEventHandler } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import DeleteForeverIcon from '@/material-icons/400-24px/delete_forever.svg?react'; +import { Icon } from 'mastodon/components/icon'; + +interface Props { + onClick?: MouseEventHandler; +} + +const ClearColumnButton: React.FC = ({ onClick }) => { + return ( + + ); +}; + +export default ClearColumnButton; From 98e87c38a4a5592b6be1563e717fb9559aea326d Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 01:58:56 +0900 Subject: [PATCH 6/9] refactor: AdminComponent --- .../mastodon/containers/admin_component.jsx | 22 ------------------- .../mastodon/containers/admin_component.tsx | 17 ++++++++++++++ 2 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 app/javascript/mastodon/containers/admin_component.jsx create mode 100644 app/javascript/mastodon/containers/admin_component.tsx diff --git a/app/javascript/mastodon/containers/admin_component.jsx b/app/javascript/mastodon/containers/admin_component.jsx deleted file mode 100644 index 7400111293..0000000000 --- a/app/javascript/mastodon/containers/admin_component.jsx +++ /dev/null @@ -1,22 +0,0 @@ -import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; - -import { IntlProvider } from 'mastodon/locales'; - -export default class AdminComponent extends PureComponent { - - static propTypes = { - children: PropTypes.node.isRequired, - }; - - render () { - const { children } = this.props; - - return ( - - {children} - - ); - } - -} diff --git a/app/javascript/mastodon/containers/admin_component.tsx b/app/javascript/mastodon/containers/admin_component.tsx new file mode 100644 index 0000000000..5beaf45b34 --- /dev/null +++ b/app/javascript/mastodon/containers/admin_component.tsx @@ -0,0 +1,17 @@ +import React, { ReactNode } from 'react'; + +import { IntlProvider } from 'mastodon/locales'; + +interface Props { + children: ReactNode; +} + +const AdminComponent: React.FC = ({ children }) => { + return ( + + {children} + + ); +}; + +export default AdminComponent; From 4c12edbdb4967a29f87b76c5e5ee13d5b0892a4b Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 02:02:49 +0900 Subject: [PATCH 7/9] refactor: column test --- .../{column-test.jsx => column-test.tsx} | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) rename app/javascript/mastodon/features/ui/components/__tests__/{column-test.jsx => column-test.tsx} (64%) diff --git a/app/javascript/mastodon/features/ui/components/__tests__/column-test.jsx b/app/javascript/mastodon/features/ui/components/__tests__/column-test.tsx similarity index 64% rename from app/javascript/mastodon/features/ui/components/__tests__/column-test.jsx rename to app/javascript/mastodon/features/ui/components/__tests__/column-test.tsx index ca74fa2dc4..93f07c7d8b 100644 --- a/app/javascript/mastodon/features/ui/components/__tests__/column-test.jsx +++ b/app/javascript/mastodon/features/ui/components/__tests__/column-test.tsx @@ -9,17 +9,29 @@ describe('', () => { it('runs the scroll animation if the column contains scrollable content', () => { const scrollToMock = jest.fn(); const { container } = render( - +
, ); - container.querySelector('.scrollable').scrollTo = scrollToMock; + const scrollable = container.querySelector('.scrollable'); + if (scrollable?.scrollTo) scrollable.scrollTo = scrollToMock; + fireEvent.click(screen.getByText('notifications')); expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); }); it('does not try to scroll if there is no scrollable content', () => { - render(); + render( + , + ); fireEvent.click(screen.getByText('notifications')); }); }); From 733c1171b11ac773830715c8ca2e28f79b32f6b8 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 02:05:26 +0900 Subject: [PATCH 8/9] refactor: ComposeContainer --- .../containers/{compose_container.jsx => compose_container.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/javascript/mastodon/containers/{compose_container.jsx => compose_container.tsx} (100%) diff --git a/app/javascript/mastodon/containers/compose_container.jsx b/app/javascript/mastodon/containers/compose_container.tsx similarity index 100% rename from app/javascript/mastodon/containers/compose_container.jsx rename to app/javascript/mastodon/containers/compose_container.tsx From 1fa95e13cdc50c7a8ffb1e985aeef956d987f285 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 27 Mar 2025 02:10:09 +0900 Subject: [PATCH 9/9] refactor: Badge --- app/javascript/mastodon/components/badge.jsx | 31 -------------- app/javascript/mastodon/components/badge.tsx | 45 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 31 deletions(-) delete mode 100644 app/javascript/mastodon/components/badge.jsx create mode 100644 app/javascript/mastodon/components/badge.tsx diff --git a/app/javascript/mastodon/components/badge.jsx b/app/javascript/mastodon/components/badge.jsx deleted file mode 100644 index 2a335d7f50..0000000000 --- a/app/javascript/mastodon/components/badge.jsx +++ /dev/null @@ -1,31 +0,0 @@ -import PropTypes from 'prop-types'; - -import { FormattedMessage } from 'react-intl'; - -import GroupsIcon from '@/material-icons/400-24px/group.svg?react'; -import PersonIcon from '@/material-icons/400-24px/person.svg?react'; -import SmartToyIcon from '@/material-icons/400-24px/smart_toy.svg?react'; - - -export const Badge = ({ icon = , label, domain, roleId }) => ( -
- {icon} - {label} - {domain && {domain}} -
-); - -Badge.propTypes = { - icon: PropTypes.node, - label: PropTypes.node, - domain: PropTypes.node, - roleId: PropTypes.string -}; - -export const GroupBadge = () => ( - } label={} /> -); - -export const AutomatedBadge = () => ( - } label={} /> -); diff --git a/app/javascript/mastodon/components/badge.tsx b/app/javascript/mastodon/components/badge.tsx new file mode 100644 index 0000000000..dd588f799a --- /dev/null +++ b/app/javascript/mastodon/components/badge.tsx @@ -0,0 +1,45 @@ +import type { FC, ReactNode } from 'react'; + +import { FormattedMessage } from 'react-intl'; + +import GroupsIcon from '@/material-icons/400-24px/group.svg?react'; +import PersonIcon from '@/material-icons/400-24px/person.svg?react'; +import SmartToyIcon from '@/material-icons/400-24px/smart_toy.svg?react'; + +interface BadgeProps { + icon?: ReactNode; + label?: ReactNode; + domain?: ReactNode; + roleId?: string; +} + +export const Badge: FC = ({ + icon = , + label, + domain, + roleId, +}) => ( +
+ {icon} + {label} + {domain && {domain}} +
+); + +export const GroupBadge = () => ( + } + label={ + + } + /> +); + +export const AutomatedBadge = () => ( + } + label={ + + } + /> +);