Skip to content

Commit

Permalink
Merge pull request #2804 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to ad95c98
  • Loading branch information
ClearlyClaire authored Aug 2, 2024
2 parents a9ffec4 + 096f622 commit a31ab56
Show file tree
Hide file tree
Showing 133 changed files with 1,410 additions and 817 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ GEM
pundit (2.3.2)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.0)
racc (1.8.1)
rack (2.2.9)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
Expand Down Expand Up @@ -698,7 +698,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.2)
rexml (3.3.4)
strscan
rotp (6.3.0)
rouge (4.2.1)
Expand Down Expand Up @@ -735,7 +735,7 @@ GEM
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 8)
rspec-support (3.13.1)
rubocop (1.65.0)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/api/v1/admin/domain_allows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Api::V1::Admin::DomainAllowsController < Api::BaseController
include AccountableConcern

LIMIT = 100
MAX_LIMIT = 500

before_action -> { authorize_if_got_token! :'admin:read', :'admin:read:domain_allows' }, only: [:index, :show]
before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:domain_allows' }, except: [:index, :show]
Expand Down Expand Up @@ -47,7 +48,7 @@ def destroy
private

def set_domain_allows
@domain_allows = DomainAllow.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
@domain_allows = DomainAllow.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT, MAX_LIMIT), params_slice(:max_id, :since_id, :min_id))
end

def set_domain_allow
Expand All @@ -67,7 +68,7 @@ def pagination_collection
end

def records_continue?
@domain_allows.size == limit_param(LIMIT)
@domain_allows.size == limit_param(LIMIT, MAX_LIMIT)
end

def resource_params
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/api/v1/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
include AccountableConcern

LIMIT = 100
MAX_LIMIT = 500

before_action -> { authorize_if_got_token! :'admin:read', :'admin:read:domain_blocks' }, only: [:index, :show]
before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:domain_blocks' }, except: [:index, :show]
Expand Down Expand Up @@ -59,7 +60,7 @@ def conflicts_with_existing_block?(domain_block, existing_domain_block)
end

def set_domain_blocks
@domain_blocks = DomainBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
@domain_blocks = DomainBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT, MAX_LIMIT), params_slice(:max_id, :since_id, :min_id))
end

def set_domain_block
Expand All @@ -83,7 +84,7 @@ def pagination_collection
end

def records_continue?
@domain_blocks.size == limit_param(LIMIT)
@domain_blocks.size == limit_param(LIMIT, MAX_LIMIT)
end

def resource_params
Expand Down
17 changes: 16 additions & 1 deletion app/controllers/api/v1/notifications/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Api::V1::Notifications::RequestsController < Api::BaseController
before_action -> { doorkeeper_authorize! :write, :'write:notifications' }, except: :index

before_action :require_user!
before_action :set_request, except: :index
before_action :set_request, only: [:show, :accept, :dismiss]
before_action :set_requests, only: [:accept_bulk, :dismiss_bulk]

after_action :insert_pagination_headers, only: :index

Expand All @@ -32,6 +33,16 @@ def dismiss
render_empty
end

def accept_bulk
@requests.each { |request| AcceptNotificationRequestService.new.call(request) }
render_empty
end

def dismiss_bulk
@requests.each(&:destroy!)
render_empty
end

private

def load_requests
Expand All @@ -53,6 +64,10 @@ def set_request
@request = NotificationRequest.where(account: current_account).find(params[:id])
end

def set_requests
@requests = NotificationRequest.where(account: current_account, id: Array(params[:id]).uniq.map(&:to_i))
end

def next_path
api_v1_notifications_requests_url pagination_params(max_id: pagination_max_id) unless @requests.empty?
end
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/auth/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController

layout 'auth'

before_action :set_body_classes
before_action :set_confirmation_user!, only: [:show, :confirm_captcha]
before_action :redirect_confirmed_user, if: :signed_in_confirmed_user?

Expand Down Expand Up @@ -73,10 +72,6 @@ def signed_in_confirmed_user?
user_signed_in? && current_user.confirmed? && current_user.unconfirmed_email.blank?
end

def set_body_classes
@body_classes = 'lighter'
end

def after_resending_confirmation_instructions_path_for(_resource_name)
if user_signed_in?
if current_user.confirmed? && current_user.approved?
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/auth/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
class Auth::PasswordsController < Devise::PasswordsController
skip_before_action :check_self_destruct!
before_action :redirect_invalid_reset_token, only: :edit, unless: :reset_password_token_is_valid?
before_action :set_body_classes

layout 'auth'

Expand All @@ -24,10 +23,6 @@ def redirect_invalid_reset_token
redirect_to new_password_path(resource_name)
end

def set_body_classes
@body_classes = 'lighter'
end

def reset_password_token_is_valid?
resource_class.with_reset_password_token(params[:reset_password_token]).present?
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def invite_code
private

def set_body_classes
@body_classes = %w(edit update).include?(action_name) ? 'admin' : 'lighter'
@body_classes = 'admin' if %w(edit update).include?(action_name)
end

def set_invite
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class Auth::SessionsController < Devise::SessionsController

include Auth::TwoFactorAuthenticationConcern

before_action :set_body_classes

content_security_policy only: :new do |p|
p.form_action(false)
end
Expand Down Expand Up @@ -103,10 +101,6 @@ def require_no_authentication

private

def set_body_classes
@body_classes = 'lighter'
end

def home_paths(resource)
paths = [about_path, '/explore']

Expand Down
5 changes: 0 additions & 5 deletions app/controllers/auth/setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Auth::SetupController < ApplicationController

before_action :authenticate_user!
before_action :require_unconfirmed_or_pending!
before_action :set_body_classes
before_action :set_user

skip_before_action :require_functional!
Expand Down Expand Up @@ -35,10 +34,6 @@ def set_user
@user = current_user
end

def set_body_classes
@body_classes = 'lighter'
end

def user_params
params.require(:user).permit(:email)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def authenticate_with_two_factor_via_otp(user)
def prompt_for_two_factor(user)
register_attempt_in_session(user)

@body_classes = 'lighter'
@webauthn_enabled = user.webauthn_enabled?
@scheme_type = if user.webauthn_enabled? && user_params[:otp_attempt].blank?
'webauthn'
Expand Down
1 change: 0 additions & 1 deletion app/controllers/concerns/challengable_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def require_challenge!
end

def render_challenge
@body_classes = 'lighter'
render 'auth/challenges/new', layout: 'auth'
end

Expand Down
5 changes: 0 additions & 5 deletions app/controllers/mail_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class MailSubscriptionsController < ApplicationController

skip_before_action :require_functional!

before_action :set_body_classes
before_action :set_user
before_action :set_type

Expand All @@ -25,10 +24,6 @@ def set_user
not_found unless @user
end

def set_body_classes
@body_classes = 'lighter'
end

def set_type
@type = email_type_from_param
end
Expand Down
14 changes: 13 additions & 1 deletion app/javascript/flavours/glitch/components/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface Props {
style?: React.CSSProperties;
inline?: boolean;
animate?: boolean;
counter?: number | string;
counterBorderColor?: string;
}

export const Avatar: React.FC<Props> = ({
Expand All @@ -19,6 +21,8 @@ export const Avatar: React.FC<Props> = ({
size = 20,
inline = false,
style: styleFromParent,
counter,
counterBorderColor,
}) => {
const { hovering, handleMouseEnter, handleMouseLeave } = useHovering(animate);

Expand All @@ -43,7 +47,15 @@ export const Avatar: React.FC<Props> = ({
style={style}
data-avatar-of={account && `@${account.get('acct')}`}
>
{src && <img src={src} alt={account?.get('acct')} />}
{src && <img src={src} alt='' />}
{counter && (
<div
className='account__avatar__counter'
style={{ borderColor: counterBorderColor }}
>
{counter}
</div>
)}
</div>
);
};
5 changes: 3 additions & 2 deletions app/javascript/flavours/glitch/components/dropdown_menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let id = 0;
class DropdownMenu extends PureComponent {

static propTypes = {
items: PropTypes.oneOfType([PropTypes.array, ImmutablePropTypes.list]).isRequired,
items: PropTypes.array.isRequired,
loading: PropTypes.bool,
scrollable: PropTypes.bool,
onClose: PropTypes.func.isRequired,
Expand All @@ -39,6 +39,7 @@ class DropdownMenu extends PureComponent {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
e.stopPropagation();
e.preventDefault();
}
};

Expand Down Expand Up @@ -164,7 +165,7 @@ class Dropdown extends PureComponent {
children: PropTypes.node,
icon: PropTypes.string,
iconComponent: PropTypes.func,
items: PropTypes.oneOfType([PropTypes.array, ImmutablePropTypes.list]),
items: PropTypes.array.isRequired,
loading: PropTypes.bool,
size: PropTypes.number,
title: PropTypes.string,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { PropsWithChildren } from 'react';
import { useCallback } from 'react';

import Toggle from 'react-toggle';

interface Props {
checked: boolean;
disabled?: boolean;
onChange: (checked: boolean) => void;
}

export const CheckboxWithLabel: React.FC<PropsWithChildren<Props>> = ({
checked,
disabled,
children,
onChange,
}) => {
const handleChange = useCallback(
({ target }: React.ChangeEvent<HTMLInputElement>) => {
onChange(target.checked);
},
[onChange],
);

return (
<label className='app-form__toggle'>
<div className='app-form__toggle__label'>{children}</div>

<div className='app-form__toggle__toggle'>
<div>
<Toggle
checked={checked}
onChange={handleChange}
disabled={disabled}
/>
</div>
</div>
</label>
);
};
Loading

0 comments on commit a31ab56

Please sign in to comment.