kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Merge branch 'prevent-engagement' into 'develop'
Prevent engagement on statuses current "in review" See merge request soapbox-pub/soapbox!1877environments/review-develop-3zknud/deployments/1340
commit
fc67cf5c90
|
@ -0,0 +1,42 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { render, screen, rootState } from '../../jest/test-helpers';
|
||||||
|
import { normalizeStatus, normalizeAccount } from '../../normalizers';
|
||||||
|
import Status from '../status';
|
||||||
|
|
||||||
|
import type { ReducerStatus } from 'soapbox/reducers/statuses';
|
||||||
|
|
||||||
|
const account = normalizeAccount({
|
||||||
|
id: '1',
|
||||||
|
acct: 'alex',
|
||||||
|
});
|
||||||
|
|
||||||
|
const status = normalizeStatus({
|
||||||
|
id: '1',
|
||||||
|
account,
|
||||||
|
content: 'hello world',
|
||||||
|
contentHtml: 'hello world',
|
||||||
|
}) as ReducerStatus;
|
||||||
|
|
||||||
|
describe('<Status />', () => {
|
||||||
|
const state = rootState.setIn(['accounts', '1'], account);
|
||||||
|
|
||||||
|
it('renders content', () => {
|
||||||
|
render(<Status status={status} />, undefined, state);
|
||||||
|
screen.getByText(/hello world/i);
|
||||||
|
expect(screen.getByTestId('status')).toHaveTextContent(/hello world/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('the Status Action Bar', () => {
|
||||||
|
it('is rendered', () => {
|
||||||
|
render(<Status status={status} />, undefined, state);
|
||||||
|
expect(screen.getByTestId('status-action-bar')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is not rendered if status is under review', () => {
|
||||||
|
const inReviewStatus = normalizeStatus({ ...status, visibility: 'self' });
|
||||||
|
render(<Status status={inReviewStatus as ReducerStatus} />, undefined, state);
|
||||||
|
expect(screen.queryAllByTestId('status-action-bar')).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -552,6 +552,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
data-testid='status-action-bar'
|
||||||
className={classNames('flex flex-row', {
|
className={classNames('flex flex-row', {
|
||||||
'justify-between': space === 'expand',
|
'justify-between': space === 'expand',
|
||||||
'space-x-2': space === 'compact',
|
'space-x-2': space === 'compact',
|
||||||
|
|
|
@ -296,7 +296,7 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
|
|
||||||
const accountAction = props.accountAction || reblogElement;
|
const accountAction = props.accountAction || reblogElement;
|
||||||
|
|
||||||
const inReview = actualStatus.visibility === 'self';
|
const isUnderReview = actualStatus.visibility === 'self';
|
||||||
const isSensitive = actualStatus.hidden;
|
const isSensitive = actualStatus.hidden;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -354,11 +354,11 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
<Stack
|
<Stack
|
||||||
className={
|
className={
|
||||||
classNames('relative', {
|
classNames('relative', {
|
||||||
'min-h-[220px]': inReview || isSensitive,
|
'min-h-[220px]': isUnderReview || isSensitive,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(inReview || isSensitive) && (
|
{(isUnderReview || isSensitive) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
|
@ -392,7 +392,7 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{!hideActionBar && (
|
{(!hideActionBar && !isUnderReview) && (
|
||||||
<div className='pt-4'>
|
<div className='pt-4'>
|
||||||
<StatusActionBar status={actualStatus} withDismiss={withDismiss} />
|
<StatusActionBar status={actualStatus} withDismiss={withDismiss} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -134,6 +134,7 @@ const Thread: React.FC<IThread> = (props) => {
|
||||||
const me = useAppSelector(state => state.me);
|
const me = useAppSelector(state => state.me);
|
||||||
const status = useAppSelector(state => getStatus(state, { id: props.params.statusId }));
|
const status = useAppSelector(state => getStatus(state, { id: props.params.statusId }));
|
||||||
const displayMedia = settings.get('displayMedia') as DisplayMedia;
|
const displayMedia = settings.get('displayMedia') as DisplayMedia;
|
||||||
|
const isUnderReview = status?.visibility === 'self';
|
||||||
|
|
||||||
const { ancestorsIds, descendantsIds } = useAppSelector(state => {
|
const { ancestorsIds, descendantsIds } = useAppSelector(state => {
|
||||||
let ancestorsIds = ImmutableOrderedSet<string>();
|
let ancestorsIds = ImmutableOrderedSet<string>();
|
||||||
|
@ -412,7 +413,7 @@ const Thread: React.FC<IThread> = (props) => {
|
||||||
if (next && status) {
|
if (next && status) {
|
||||||
dispatch(fetchNext(status.id, next)).then(({ next }) => {
|
dispatch(fetchNext(status.id, next)).then(({ next }) => {
|
||||||
setNext(next);
|
setNext(next);
|
||||||
}).catch(() => {});
|
}).catch(() => { });
|
||||||
}
|
}
|
||||||
}, 300, { leading: true }), [next, status]);
|
}, 300, { leading: true }), [next, status]);
|
||||||
|
|
||||||
|
@ -475,6 +476,8 @@ const Thread: React.FC<IThread> = (props) => {
|
||||||
onOpenCompareHistoryModal={handleOpenCompareHistoryModal}
|
onOpenCompareHistoryModal={handleOpenCompareHistoryModal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{!isUnderReview ? (
|
||||||
|
<>
|
||||||
<hr className='mb-2 border-t-2 dark:border-primary-800' />
|
<hr className='mb-2 border-t-2 dark:border-primary-800' />
|
||||||
|
|
||||||
<StatusActionBar
|
<StatusActionBar
|
||||||
|
@ -483,6 +486,8 @@ const Thread: React.FC<IThread> = (props) => {
|
||||||
space='expand'
|
space='expand'
|
||||||
withLabels
|
withLabels
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</HotKeys>
|
</HotKeys>
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue