Compare commits

...

11 Commits

Author SHA1 Message Date
scarf
22aa4f2443
Merge 1fa95e13cd into 8b34daf254 2025-05-03 11:04:44 +00:00
Jonny Saunders
8b34daf254
Fix: Use strings not symbols to access totalItems in interaction collections (#34594)
Some checks failed
Check i18n / check-i18n (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
Check formatting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Ruby Testing / test (.ruby-version) (push) Has been cancelled
Ruby Testing / test (3.2) (push) Has been cancelled
Ruby Testing / test (3.3) (push) Has been cancelled
Ruby Testing / Libvips tests (.ruby-version) (push) Has been cancelled
Ruby Testing / Libvips tests (3.2) (push) Has been cancelled
Ruby Testing / Libvips tests (3.3) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.2) (push) Has been cancelled
Ruby Testing / End to End testing (3.3) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Bundler Audit / security (push) Has been cancelled
2025-05-03 10:37:06 +00:00
scarf
1fa95e13cd
refactor: Badge 2025-03-27 02:10:09 +09:00
scarf
733c1171b1
refactor: ComposeContainer 2025-03-27 02:05:26 +09:00
scarf
4c12edbdb4
refactor: column test 2025-03-27 02:02:49 +09:00
scarf
98e87c38a4
refactor: AdminComponent 2025-03-27 01:58:56 +09:00
scarf
70085dd2ed
refactor: ClearColumnButton 2025-03-27 01:58:33 +09:00
scarf
a97ee55650
refactor: GrantPermissionButton 2025-03-27 01:52:48 +09:00
scarf
85e89dfc16
refactor: ColumnSubheading 2025-03-27 01:52:48 +09:00
scarf
aafe85acaa
refactor: Compose 2025-03-27 01:50:24 +09:00
scarf
d4980feed6
refactor: DrawerLoading 2025-03-27 01:50:10 +09:00
15 changed files with 140 additions and 114 deletions

View File

@ -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 = <PersonIcon />, label, domain, roleId }) => (
<div className='account-role' data-account-role-id={roleId}>
{icon}
{label}
{domain && <span className='account-role__domain'>{domain}</span>}
</div>
);
Badge.propTypes = {
icon: PropTypes.node,
label: PropTypes.node,
domain: PropTypes.node,
roleId: PropTypes.string
};
export const GroupBadge = () => (
<Badge icon={<GroupsIcon />} label={<FormattedMessage id='account.badges.group' defaultMessage='Group' />} />
);
export const AutomatedBadge = () => (
<Badge icon={<SmartToyIcon />} label={<FormattedMessage id='account.badges.bot' defaultMessage='Automated' />} />
);

View File

@ -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<BadgeProps> = ({
icon = <PersonIcon />,
label,
domain,
roleId,
}) => (
<div className='account-role' data-account-role-id={roleId}>
{icon}
{label}
{domain && <span className='account-role__domain'>{domain}</span>}
</div>
);
export const GroupBadge = () => (
<Badge
icon={<GroupsIcon />}
label={
<FormattedMessage id='account.badges.group' defaultMessage='Group' />
}
/>
);
export const AutomatedBadge = () => (
<Badge
icon={<SmartToyIcon />}
label={
<FormattedMessage id='account.badges.bot' defaultMessage='Automated' />
}
/>
);

View File

@ -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 (
<IntlProvider>
{children}
</IntlProvider>
);
}
}

View File

@ -0,0 +1,17 @@
import React, { ReactNode } from 'react';
import { IntlProvider } from 'mastodon/locales';
interface Props {
children: ReactNode;
}
const AdminComponent: React.FC<Props> = ({ children }) => {
return (
<IntlProvider>
{children}
</IntlProvider>
);
};
export default AdminComponent;

View File

@ -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 (
<button className='text-btn column-header__setting-btn' tabIndex={0} onClick={this.props.onClick}><Icon id='eraser' icon={DeleteForeverIcon} /> <FormattedMessage id='notifications.clear' defaultMessage='Clear notifications' /></button>
);
}
}

View File

@ -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<HTMLButtonElement>;
}
const ClearColumnButton: React.FC<Props> = ({ onClick }) => {
return (
<button
className='text-btn column-header__setting-btn'
tabIndex={0}
onClick={onClick}
>
<Icon id='eraser' icon={DeleteForeverIcon} />{' '}
<FormattedMessage
id='notifications.clear'
defaultMessage='Clear notifications'
/>
</button>
);
};
export default ClearColumnButton;

View File

@ -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 (
<button className='text-btn column-header__permission-btn' tabIndex={0} onClick={this.props.onClick}>
<FormattedMessage id='notifications.grant_permission' defaultMessage='Grant permission.' />
</button>
);
}
}

View File

@ -0,0 +1,23 @@
import { MouseEventHandler } from 'react';
import { FormattedMessage } from 'react-intl';
interface Props {
onClick: MouseEventHandler<HTMLButtonElement>;
}
const GrantPermissionButton: React.FC<Props> = ({ onClick }) => {
return (
<button
className='text-btn column-header__permission-btn'
tabIndex={0}
onClick={onClick}
>
<FormattedMessage
id='notifications.grant_permission'
defaultMessage='Grant permission.'
/>
</button>
);
};
export default GrantPermissionButton;

View File

@ -9,17 +9,29 @@ describe('<Column />', () => {
it('runs the scroll animation if the column contains scrollable content', () => {
const scrollToMock = jest.fn();
const { container } = render(
<Column heading='notifications' icon='notifications' iconComponent={fakeIcon}>
<Column
heading='notifications'
icon='notifications'
iconComponent={fakeIcon}
>
<div className='scrollable' />
</Column>,
);
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(<Column heading='notifications' icon='notifications' iconComponent={fakeIcon} />);
render(
<Column
heading='notifications'
icon='notifications'
iconComponent={fakeIcon}
/>,
);
fireEvent.click(screen.getByText('notifications'));
});
});

View File

@ -1,15 +0,0 @@
import PropTypes from 'prop-types';
const ColumnSubheading = ({ text }) => {
return (
<div className='column-subheading'>
{text}
</div>
);
};
ColumnSubheading.propTypes = {
text: PropTypes.string.isRequired,
};
export default ColumnSubheading;

View File

@ -0,0 +1,11 @@
import React from 'react';
interface Props {
text: string;
}
const ColumnSubheading: React.FC<Props> = ({ text }) => {
return <div className='column-subheading'>{text}</div>;
};
export default ColumnSubheading;

View File

@ -95,11 +95,11 @@ class ActivityPub::Parser::StatusParser
end
def favourites_count
@object.dig(:likes, :totalItems)
@object.dig('likes', 'totalItems')
end
def reblogs_count
@object.dig(:shares, :totalItems)
@object.dig('shares', 'totalItems')
end
def quote_policy