Conflicts: - `app/controllers/auth/setup_controller.rb`: Upstream removed a method close to a glitch-soc theming-related method. Removed the method like upstream did.th-downstream
commit
5c962d77bb
@ -0,0 +1,72 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Admin::Trends::Links::PreviewCardProvidersController < Api::BaseController
|
||||||
|
include Authorization
|
||||||
|
|
||||||
|
LIMIT = 100
|
||||||
|
|
||||||
|
before_action -> { authorize_if_got_token! :'admin:read' }, only: :index
|
||||||
|
before_action -> { authorize_if_got_token! :'admin:write' }, except: :index
|
||||||
|
before_action :set_providers, only: :index
|
||||||
|
|
||||||
|
after_action :verify_authorized
|
||||||
|
after_action :insert_pagination_headers, only: :index
|
||||||
|
|
||||||
|
PAGINATION_PARAMS = %i(limit).freeze
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize :preview_card_provider, :index?
|
||||||
|
|
||||||
|
render json: @providers, each_serializer: REST::Admin::Trends::Links::PreviewCardProviderSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
def approve
|
||||||
|
authorize :preview_card_provider, :review?
|
||||||
|
|
||||||
|
provider = PreviewCardProvider.find(params[:id])
|
||||||
|
provider.update(trendable: true, reviewed_at: Time.now.utc)
|
||||||
|
render json: provider, serializer: REST::Admin::Trends::Links::PreviewCardProviderSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject
|
||||||
|
authorize :preview_card_provider, :review?
|
||||||
|
|
||||||
|
provider = PreviewCardProvider.find(params[:id])
|
||||||
|
provider.update(trendable: false, reviewed_at: Time.now.utc)
|
||||||
|
render json: provider, serializer: REST::Admin::Trends::Links::PreviewCardProviderSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_providers
|
||||||
|
@providers = PreviewCardProvider.all.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
|
end
|
||||||
|
|
||||||
|
def insert_pagination_headers
|
||||||
|
set_pagination_headers(next_path, prev_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def next_path
|
||||||
|
api_v1_admin_trends_links_preview_card_providers_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
|
end
|
||||||
|
|
||||||
|
def prev_path
|
||||||
|
api_v1_admin_trends_links_preview_card_providers_url(pagination_params(min_id: pagination_since_id)) unless @providers.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def pagination_max_id
|
||||||
|
@providers.last.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def pagination_since_id
|
||||||
|
@providers.first.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def records_continue?
|
||||||
|
@providers.size == limit_param(LIMIT)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pagination_params(core_params)
|
||||||
|
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params)
|
||||||
|
end
|
||||||
|
end
|
@ -1,76 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ShortNumber from 'mastodon/components/short_number';
|
|
||||||
import TransitionMotion from 'react-motion/lib/TransitionMotion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import { reduceMotion } from 'mastodon/initial_state';
|
|
||||||
|
|
||||||
const obfuscatedCount = count => {
|
|
||||||
if (count < 0) {
|
|
||||||
return 0;
|
|
||||||
} else if (count <= 1) {
|
|
||||||
return count;
|
|
||||||
} else {
|
|
||||||
return '1+';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class AnimatedNumber extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
obfuscate: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
direction: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
|
||||||
if (nextProps.value > this.props.value) {
|
|
||||||
this.setState({ direction: 1 });
|
|
||||||
} else if (nextProps.value < this.props.value) {
|
|
||||||
this.setState({ direction: -1 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
willEnter = () => {
|
|
||||||
const { direction } = this.state;
|
|
||||||
|
|
||||||
return { y: -1 * direction };
|
|
||||||
};
|
|
||||||
|
|
||||||
willLeave = () => {
|
|
||||||
const { direction } = this.state;
|
|
||||||
|
|
||||||
return { y: spring(1 * direction, { damping: 35, stiffness: 400 }) };
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { value, obfuscate } = this.props;
|
|
||||||
const { direction } = this.state;
|
|
||||||
|
|
||||||
if (reduceMotion) {
|
|
||||||
return obfuscate ? obfuscatedCount(value) : <ShortNumber value={value} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = [{
|
|
||||||
key: `${value}`,
|
|
||||||
data: value,
|
|
||||||
style: { y: spring(0, { damping: 35, stiffness: 400 }) },
|
|
||||||
}];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TransitionMotion styles={styles} willEnter={this.willEnter} willLeave={this.willLeave}>
|
|
||||||
{items => (
|
|
||||||
<span className='animated-number'>
|
|
||||||
{items.map(({ key, data, style }) => (
|
|
||||||
<span key={key} style={{ position: (direction * style.y) > 0 ? 'absolute' : 'static', transform: `translateY(${style.y * 100}%)` }}>{obfuscate ? obfuscatedCount(data) : <ShortNumber value={data} />}</span>
|
|
||||||
))}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</TransitionMotion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,58 @@
|
|||||||
|
import React, { useCallback, useState } from 'react';
|
||||||
|
import ShortNumber from './short_number';
|
||||||
|
import { TransitionMotion, spring } from 'react-motion';
|
||||||
|
import { reduceMotion } from '../initial_state';
|
||||||
|
|
||||||
|
const obfuscatedCount = (count: number) => {
|
||||||
|
if (count < 0) {
|
||||||
|
return 0;
|
||||||
|
} else if (count <= 1) {
|
||||||
|
return count;
|
||||||
|
} else {
|
||||||
|
return '1+';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value: number;
|
||||||
|
obfuscate?: boolean;
|
||||||
|
}
|
||||||
|
export const AnimatedNumber: React.FC<Props> = ({
|
||||||
|
value,
|
||||||
|
obfuscate,
|
||||||
|
})=> {
|
||||||
|
const [previousValue, setPreviousValue] = useState(value);
|
||||||
|
const [direction, setDirection] = useState<1|-1>(1);
|
||||||
|
|
||||||
|
if (previousValue !== value) {
|
||||||
|
setPreviousValue(value);
|
||||||
|
setDirection(value > previousValue ? 1 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const willEnter = useCallback(() => ({ y: -1 * direction }), [direction]);
|
||||||
|
const willLeave = useCallback(() => ({ y: spring(1 * direction, { damping: 35, stiffness: 400 }) }), [direction]);
|
||||||
|
|
||||||
|
if (reduceMotion) {
|
||||||
|
return obfuscate ? <>{obfuscatedCount(value)}</> : <ShortNumber value={value} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = [{
|
||||||
|
key: `${value}`,
|
||||||
|
data: value,
|
||||||
|
style: { y: spring(0, { damping: 35, stiffness: 400 }) },
|
||||||
|
}];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TransitionMotion styles={styles} willEnter={willEnter} willLeave={willLeave}>
|
||||||
|
{items => (
|
||||||
|
<span className='animated-number'>
|
||||||
|
{items.map(({ key, data, style }) => (
|
||||||
|
<span key={key} style={{ position: (direction * style.y) > 0 ? 'absolute' : 'static', transform: `translateY(${style.y * 100}%)` }}>{obfuscate ? obfuscatedCount(data) : <ShortNumber value={data} />}</span>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</TransitionMotion>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AnimatedNumber;
|
@ -1,51 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { autoPlayGif } from '../initial_state';
|
|
||||||
import Avatar from './avatar';
|
|
||||||
|
|
||||||
export default class AvatarOverlay extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
|
||||||
friend: ImmutablePropTypes.map.isRequired,
|
|
||||||
animate: PropTypes.bool,
|
|
||||||
size: PropTypes.number,
|
|
||||||
baseSize: PropTypes.number,
|
|
||||||
overlaySize: PropTypes.number,
|
|
||||||
};
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
animate: autoPlayGif,
|
|
||||||
size: 46,
|
|
||||||
baseSize: 36,
|
|
||||||
overlaySize: 24,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
hovering: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleMouseEnter = () => {
|
|
||||||
if (this.props.animate) return;
|
|
||||||
this.setState({ hovering: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
handleMouseLeave = () => {
|
|
||||||
if (this.props.animate) return;
|
|
||||||
this.setState({ hovering: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { account, friend, animate, size, baseSize, overlaySize } = this.props;
|
|
||||||
const { hovering } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='account__avatar-overlay' style={{ width: size, height: size }}>
|
|
||||||
<div className='account__avatar-overlay-base'><Avatar animate={hovering || animate} account={account} size={baseSize} /></div>
|
|
||||||
<div className='account__avatar-overlay-overlay'><Avatar animate={hovering || animate} account={friend} size={overlaySize} /></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,51 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import type { Account } from '../../types/resources';
|
||||||
|
import { useHovering } from '../../hooks/useHovering';
|
||||||
|
import { autoPlayGif } from '../initial_state';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
account: Account;
|
||||||
|
friend: Account;
|
||||||
|
size?: number;
|
||||||
|
baseSize?: number;
|
||||||
|
overlaySize?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AvatarOverlay: React.FC<Props> = ({
|
||||||
|
account,
|
||||||
|
friend,
|
||||||
|
size = 46,
|
||||||
|
baseSize = 36,
|
||||||
|
overlaySize = 24,
|
||||||
|
}) => {
|
||||||
|
const { hovering, handleMouseEnter, handleMouseLeave } = useHovering(autoPlayGif);
|
||||||
|
const accountSrc = hovering ? account?.get('avatar') : account?.get('avatar_static');
|
||||||
|
const friendSrc = hovering ? friend?.get('avatar') : friend?.get('avatar_static');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className='account__avatar-overlay' style={{ width: size, height: size }}
|
||||||
|
onMouseEnter={handleMouseEnter}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
|
>
|
||||||
|
<div className='account__avatar-overlay-base'>
|
||||||
|
<div
|
||||||
|
className='account__avatar'
|
||||||
|
style={{ width: `${baseSize}px`, height: `${baseSize}px` }}
|
||||||
|
>
|
||||||
|
{accountSrc && <img src={accountSrc} alt={account?.get('acct')} />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='account__avatar-overlay-overlay'>
|
||||||
|
<div
|
||||||
|
className='account__avatar'
|
||||||
|
style={{ width: `${overlaySize}px`, height: `${overlaySize}px` }}
|
||||||
|
>
|
||||||
|
{friendSrc && <img src={friendSrc} alt={friend?.get('acct')} />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AvatarOverlay;
|
@ -1,76 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
export default class GIFV extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
src: PropTypes.string.isRequired,
|
|
||||||
alt: PropTypes.string,
|
|
||||||
lang: PropTypes.string,
|
|
||||||
width: PropTypes.number,
|
|
||||||
height: PropTypes.number,
|
|
||||||
onClick: PropTypes.func,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
loading: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleLoadedData = () => {
|
|
||||||
this.setState({ loading: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
|
||||||
if (nextProps.src !== this.props.src) {
|
|
||||||
this.setState({ loading: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = e => {
|
|
||||||
const { onClick } = this.props;
|
|
||||||
|
|
||||||
if (onClick) {
|
|
||||||
e.stopPropagation();
|
|
||||||
onClick();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { src, width, height, alt, lang } = this.props;
|
|
||||||
const { loading } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='gifv' style={{ position: 'relative' }}>
|
|
||||||
{loading && (
|
|
||||||
<canvas
|
|
||||||
width={width}
|
|
||||||
height={height}
|
|
||||||
role='button'
|
|
||||||
tabIndex={0}
|
|
||||||
aria-label={alt}
|
|
||||||
title={alt}
|
|
||||||
lang={lang}
|
|
||||||
onClick={this.handleClick}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<video
|
|
||||||
src={src}
|
|
||||||
role='button'
|
|
||||||
tabIndex={0}
|
|
||||||
aria-label={alt}
|
|
||||||
title={alt}
|
|
||||||
lang={lang}
|
|
||||||
muted
|
|
||||||
loop
|
|
||||||
autoPlay
|
|
||||||
playsInline
|
|
||||||
onClick={this.handleClick}
|
|
||||||
onLoadedData={this.handleLoadedData}
|
|
||||||
style={{ position: loading ? 'absolute' : 'static', top: 0, left: 0 }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,68 @@
|
|||||||
|
import React, { useCallback, useState } from 'react';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
src: string;
|
||||||
|
key: string;
|
||||||
|
alt?: string;
|
||||||
|
lang?: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GIFV: React.FC<Props> = ({
|
||||||
|
src,
|
||||||
|
alt,
|
||||||
|
lang,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
onClick,
|
||||||
|
})=> {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
const handleLoadedData: React.ReactEventHandler<HTMLVideoElement> = useCallback(() => {
|
||||||
|
setLoading(false);
|
||||||
|
}, [setLoading]);
|
||||||
|
|
||||||
|
const handleClick: React.MouseEventHandler = useCallback((e) => {
|
||||||
|
if (onClick) {
|
||||||
|
e.stopPropagation();
|
||||||
|
onClick();
|
||||||
|
}
|
||||||
|
}, [onClick]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='gifv' style={{ position: 'relative' }}>
|
||||||
|
{loading && (
|
||||||
|
<canvas
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
role='button'
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={alt}
|
||||||
|
title={alt}
|
||||||
|
lang={lang}
|
||||||
|
onClick={handleClick}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<video
|
||||||
|
src={src}
|
||||||
|
role='button'
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={alt}
|
||||||
|
title={alt}
|
||||||
|
lang={lang}
|
||||||
|
muted
|
||||||
|
loop
|
||||||
|
autoPlay
|
||||||
|
playsInline
|
||||||
|
onClick={handleClick}
|
||||||
|
onLoadedData={handleLoadedData}
|
||||||
|
style={{ position: loading ? 'absolute' : 'static', top: 0, left: 0 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GIFV;
|
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::Admin::Trends::LinkSerializer < REST::Trends::LinkSerializer
|
||||||
|
attributes :id, :requires_review
|
||||||
|
|
||||||
|
def requires_review
|
||||||
|
object.requires_review?
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::Admin::Trends::Links::PreviewCardProviderSerializer < ActiveModel::Serializer
|
||||||
|
attributes :id, :domain, :trendable, :reviewed_at,
|
||||||
|
:requested_review_at, :requires_review
|
||||||
|
|
||||||
|
def requires_review
|
||||||
|
object.requires_review?
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::Admin::Trends::StatusSerializer < REST::StatusSerializer
|
||||||
|
attributes :requires_review
|
||||||
|
|
||||||
|
def requires_review
|
||||||
|
object.requires_review?
|
||||||
|
end
|
||||||
|
end
|
@ -1,20 +1,22 @@
|
|||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('auth.setup.title')
|
= t('auth.setup.title')
|
||||||
|
|
||||||
- if missing_email?
|
= simple_form_for(@user, url: auth_setup_path) do |f|
|
||||||
= simple_form_for(@user, url: auth_setup_path) do |f|
|
= render 'auth/shared/progress', stage: 'confirm'
|
||||||
= render 'shared/error_messages', object: @user
|
|
||||||
|
|
||||||
.fields-group
|
%h1.title= t('auth.setup.title')
|
||||||
%p.hint= t('auth.setup.email_below_hint_html')
|
%p.lead= t('auth.setup.email_settings_hint_html', email: content_tag(:strong, @user.email))
|
||||||
|
|
||||||
.fields-group
|
= render 'shared/error_messages', object: @user
|
||||||
= f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }
|
|
||||||
|
|
||||||
.actions
|
%p.lead
|
||||||
= f.submit t('admin.accounts.change_email.label'), class: 'button'
|
%strong= t('auth.setup.link_not_received')
|
||||||
- else
|
%p.lead= t('auth.setup.email_below_hint_html')
|
||||||
.simple_form
|
|
||||||
%p.hint= t('auth.setup.email_settings_hint_html', email: content_tag(:strong, @user.email))
|
.fields-group
|
||||||
|
= f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }
|
||||||
|
|
||||||
|
.actions
|
||||||
|
= f.submit t('auth.resend_confirmation'), class: 'button'
|
||||||
|
|
||||||
.form-footer= render 'auth/shared/links'
|
.form-footer= render 'auth/shared/links'
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
- progress_index = { rules: 0, details: 1, confirm: 2 }[stage.to_sym]
|
||||||
|
|
||||||
|
%ol.progress-tracker
|
||||||
|
%li{ class: progress_index.positive? ? 'completed' : 'active' }
|
||||||
|
.circle
|
||||||
|
- if progress_index.positive?
|
||||||
|
= check_icon
|
||||||
|
.label= t('auth.progress.rules')
|
||||||
|
%li.separator{ class: progress_index.positive? ? 'completed' : nil }
|
||||||
|
%li{ class: [progress_index > 1 && 'completed', progress_index == 1 && 'active'] }
|
||||||
|
.circle
|
||||||
|
- if progress_index > 1
|
||||||
|
= check_icon
|
||||||
|
.label= t('auth.progress.details')
|
||||||
|
%li.separator{ class: progress_index > 1 ? 'completed' : nil }
|
||||||
|
%li{ class: [progress_index > 2 && 'completed', progress_index == 2 && 'active'] }
|
||||||
|
.circle
|
||||||
|
- if progress_index > 2
|
||||||
|
= check_icon
|
||||||
|
.label= t('auth.progress.confirm')
|
||||||
|
- if approved_registrations?
|
||||||
|
%li.separator{ class: progress_index > 2 ? 'completed' : nil }
|
||||||
|
%li
|
||||||
|
.circle
|
||||||
|
.label= t('auth.progress.review')
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue