Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream 20231021 #159

Merged
merged 27 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e9dc30c
Fix duplicate github annotations for rspec failures (#27450)
ClearlyClaire Oct 18, 2023
091a21e
Add test coverage for `Mastodon::CLI::Accounts#prune` (#25204)
danielmbrasil Oct 18, 2023
63a2a4b
Fix `Performance/DeletePrefix` cop (#27448)
mjankowski Oct 18, 2023
4612576
New Crowdin Translations (automated) (#27454)
github-actions[bot] Oct 18, 2023
7c3fea7
Feature: Allow token introspection without read scope (#27142)
ThisIsMissEm Oct 18, 2023
a1b27d8
Fix `Naming/VariableNumber` cop (#27447)
mjankowski Oct 18, 2023
510845b
Only enable github-rspec for pull_request events (#27456)
ClearlyClaire Oct 18, 2023
10df97c
The `class` props should be `className` (#27462)
renchap Oct 19, 2023
f76e511
Consider shown and pending status in explore prompt calculation (#27466)
lambda Oct 19, 2023
1ffd5a9
New Crowdin Translations (automated) (#27465)
github-actions[bot] Oct 19, 2023
7bc8f03
Add test coverage for `Mastodon::CLI::Accounts#migrate` (#25284)
danielmbrasil Oct 19, 2023
bcd0171
Fix `Lint/UselessAssignment` cop (#27472)
mjankowski Oct 19, 2023
9f218c9
Refactor appeal partial to avoid brakeman XSS warning (#25880)
mjankowski Oct 19, 2023
126cd77
Do not display the navigation banner in the logo container (#27476)
renchap Oct 19, 2023
1b70d7e
Upgrade to react-router v5 (#25047)
renchap Oct 19, 2023
33bd8ec
Fix missing background behind dismissable banner in web UI (#27479)
Gargron Oct 20, 2023
284c719
New Crowdin Translations (automated) (#27480)
github-actions[bot] Oct 20, 2023
1368853
Fix processing LDSigned activities from actors with unknown public ke…
ClearlyClaire Oct 20, 2023
ab0fb81
Configure brakeman to ignore url safe preview card urls (#25883)
mjankowski Oct 20, 2023
f9eaaec
Merge remote-tracking branch 'parent/main' into upstream-20231021
kmycode Oct 21, 2023
b992e67
Merge branch 'kb_development' into upstream-20231021
kmycode Oct 22, 2023
9d45a44
Convert `<Button>` to Typescript (#27492)
renchap Oct 23, 2023
b021347
Validate allowed schemes on preview card URLs (#27485)
mjankowski Oct 23, 2023
70fd819
New Crowdin Translations (automated) (#27490)
github-actions[bot] Oct 23, 2023
0ad6617
Fix incorrect proptypes from react-router-v5 update (#27507)
ClearlyClaire Oct 23, 2023
46a1e62
Merge remote-tracking branch 'parent/main' into upstream-20231021
kmycode Oct 23, 2023
a16f982
Fix: kmyblueの独自ページのコンポーネント変更
kmycode Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ module.exports = {
},
// Common React utilities
{
pattern: '{classnames,react-helmet,react-router-dom}',
pattern: '{classnames,react-helmet,react-router,react-router-dom}',
group: 'external',
position: 'before',
},
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
BUNDLE_WITH: 'pam_authentication test'
CI_JOBS: ${{ matrix.ci_job }}/4
ES_ENABLED: false
GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}

strategy:
fail-fast: false
Expand Down
41 changes: 0 additions & 41 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,6 @@ Lint/UnusedBlockArgument:
- 'config/initializers/paperclip.rb'
- 'config/initializers/simple_form.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessAssignment:
Exclude:
- 'app/services/activitypub/process_status_update_service.rb'
- 'config/initializers/3_omniauth.rb'
- 'db/migrate/20190511134027_add_silenced_at_suspended_at_to_accounts.rb'
- 'db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb'
- 'spec/controllers/api/v1/favourites_controller_spec.rb'
- 'spec/controllers/concerns/account_controller_concern_spec.rb'
- 'spec/helpers/jsonld_helper_spec.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/domain_block_spec.rb'
- 'spec/models/status_spec.rb'
- 'spec/models/user_spec.rb'
- 'spec/models/webauthn_credentials_spec.rb'
- 'spec/services/account_search_service_spec.rb'
- 'spec/services/post_status_service_spec.rb'
- 'spec/services/precompute_feed_service_spec.rb'
- 'spec/services/resolve_url_service_spec.rb'
- 'spec/views/statuses/show.html.haml_spec.rb'

# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 144
Expand All @@ -86,26 +65,6 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 27

# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
# SupportedStyles: snake_case, normalcase, non_integer
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
Naming/VariableNumber:
Exclude:
- 'db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb'
- 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb'
- 'db/migrate/20190820003045_update_statuses_index.rb'
- 'db/migrate/20190823221802_add_local_index_to_statuses.rb'
- 'db/migrate/20200119112504_add_public_index_to_statuses.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/domain_block_spec.rb'
- 'spec/models/user_spec.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeMultiline.
Performance/DeletePrefix:
Exclude:
- 'app/models/featured_tag.rb'

Performance/MapMethodChain:
Exclude:
- 'app/models/feed.rb'
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/apps/credentials_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

class Api::V1::Apps::CredentialsController < Api::BaseController
before_action -> { doorkeeper_authorize! :read }

def show
render json: doorkeeper_token.application, serializer: REST::ApplicationSerializer, fields: %i(name website vapid_key)
return doorkeeper_render_error unless valid_doorkeeper_token?

render json: doorkeeper_token.application, serializer: REST::ApplicationSerializer, fields: %i(name website vapid_key client_id scopes)
end
end
19 changes: 19 additions & 0 deletions app/helpers/admin/disputes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Admin
module DisputesHelper
def strike_action_label(appeal)
t(key_for_action(appeal),
scope: 'admin.strikes.actions',
name: content_tag(:span, appeal.strike.account.username, class: 'username'),
target: content_tag(:span, appeal.account.username, class: 'target'))
.html_safe
end

private

def key_for_action(appeal)
AccountWarning.actions.slice(appeal.strike.action).keys.first
end
end
end
4 changes: 4 additions & 0 deletions app/helpers/formatting_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def linkify(text, options = {})
TextFormatter.new(text, options).to_s
end

def url_for_preview_card(preview_card)
preview_card.url
end

def extract_status_plain_text(status)
PlainTextFormatter.new(status.text, status.local?).to_s
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, fireEvent, screen } from '@testing-library/react';
import renderer from 'react-test-renderer';

import Button from '../button';
import { Button } from '../button';

describe('<Button />', () => {
it('renders a button element', () => {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VerifiedBadge } from 'mastodon/components/verified_badge';
import { me } from '../initial_state';

import { Avatar } from './avatar';
import Button from './button';
import { Button } from './button';
import { FollowersCounter } from './counters';
import { DisplayName } from './display_name';
import { IconButton } from './icon_button';
Expand Down
58 changes: 0 additions & 58 deletions app/javascript/mastodon/components/button.jsx

This file was deleted.

58 changes: 58 additions & 0 deletions app/javascript/mastodon/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useCallback } from 'react';

import classNames from 'classnames';

interface BaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
block?: boolean;
secondary?: boolean;
text?: JSX.Element;
}

interface PropsWithChildren extends BaseProps {
text?: never;
}

interface PropsWithText extends BaseProps {
text: JSX.Element;
children: never;
}

type Props = PropsWithText | PropsWithChildren;

export const Button: React.FC<Props> = ({
text,
type = 'button',
onClick,
disabled,
block,
secondary,
className,
title,
children,
...props
}) => {
const handleClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(
(e) => {
if (!disabled && onClick) {
onClick(e);
}
},
[disabled, onClick],
);

return (
<button
className={classNames('button', className, {
'button-secondary': secondary,
'button--block': block,
})}
disabled={disabled}
onClick={handleClick}
title={title}
type={type}
{...props}
>
{text ?? children}
</button>
);
};
21 changes: 11 additions & 10 deletions app/javascript/mastodon/components/column_back_button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@ import { createPortal } from 'react-dom';

import { FormattedMessage } from 'react-intl';

import { Icon } from 'mastodon/components/icon';
import { withRouter } from 'react-router-dom';

export default class ColumnBackButton extends PureComponent {
import { Icon } from 'mastodon/components/icon';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';

static contextTypes = {
router: PropTypes.object,
};
class ColumnBackButton extends PureComponent {

static propTypes = {
multiColumn: PropTypes.bool,
onClick: PropTypes.func,
...WithRouterPropTypes,
};

handleClick = () => {
const { router } = this.context;
const { onClick } = this.props;
const { onClick, history } = this.props;

if (onClick) {
onClick();
} else if (router.history.location?.state?.fromMastodon) {
router.history.goBack();
} else if (history.location?.state?.fromMastodon) {
history.goBack();
} else {
router.history.push('/');
history.push('/');
}
};

Expand Down Expand Up @@ -60,3 +59,5 @@ export default class ColumnBackButton extends PureComponent {
}

}

export default withRouter(ColumnBackButton);
21 changes: 11 additions & 10 deletions app/javascript/mastodon/components/column_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { createPortal } from 'react-dom';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';

import classNames from 'classnames';
import { withRouter } from 'react-router-dom';

import { Icon } from 'mastodon/components/icon';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';

const messages = defineMessages({
show: { id: 'column_header.show_settings', defaultMessage: 'Show settings' },
Expand All @@ -18,7 +20,6 @@ const messages = defineMessages({
class ColumnHeader extends PureComponent {

static contextTypes = {
router: PropTypes.object,
identity: PropTypes.object,
};

Expand All @@ -38,6 +39,7 @@ class ColumnHeader extends PureComponent {
onClick: PropTypes.func,
appendContent: PropTypes.node,
collapseIssues: PropTypes.bool,
...WithRouterPropTypes,
};

state = {
Expand All @@ -63,12 +65,12 @@ class ColumnHeader extends PureComponent {
};

handleBackClick = () => {
const { router } = this.context;
const { history } = this.props;

if (router.history.location?.state?.fromMastodon) {
router.history.goBack();
if (history.location?.state?.fromMastodon) {
history.goBack();
} else {
router.history.push('/');
history.push('/');
}
};

Expand All @@ -78,15 +80,14 @@ class ColumnHeader extends PureComponent {

handlePin = () => {
if (!this.props.pinned) {
this.context.router.history.replace('/');
this.props.history.replace('/');
}

this.props.onPin();
};

render () {
const { router } = this.context;
const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues, history } = this.props;
const { collapsed, animating } = this.state;

const wrapperClassName = classNames('column-header__wrapper', {
Expand Down Expand Up @@ -129,7 +130,7 @@ class ColumnHeader extends PureComponent {
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={this.handlePin}><Icon id='plus' /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
}

if (!pinned && ((multiColumn && router.history.location?.state?.fromMastodon) || showBackButton)) {
if (!pinned && ((multiColumn && history.location?.state?.fromMastodon) || showBackButton)) {
backButton = (
<button onClick={this.handleBackClick} className='column-header__back-button'>
<Icon id='chevron-left' className='column-back-button__icon' fixedWidth />
Expand Down Expand Up @@ -215,4 +216,4 @@ class ColumnHeader extends PureComponent {

}

export default injectIntl(ColumnHeader);
export default injectIntl(withRouter(ColumnHeader));
Loading