[Glitch] Add UI support for disabled live feeds

Port 2fa5dd6d1f to glitch-soc

Co-authored-by: diondiondion <mail@diondiondion.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire
2025-10-23 11:59:43 +02:00
parent deed31ba8c
commit b11bd2bdbb
6 changed files with 72 additions and 17 deletions

View File

@@ -10,7 +10,8 @@ import { connect } from 'react-redux';
import PeopleIcon from '@/material-icons/400-24px/group.svg?react'; import PeopleIcon from '@/material-icons/400-24px/group.svg?react';
import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner'; import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner';
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
import { domain } from 'flavours/glitch/initial_state'; import { domain, localLiveFeedAccess } from 'flavours/glitch/initial_state';
import { canViewFeed } from 'flavours/glitch/permissions';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import { connectCommunityStream } from '../../actions/streaming'; import { connectCommunityStream } from '../../actions/streaming';
@@ -123,8 +124,21 @@ class CommunityTimeline extends PureComponent {
render () { render () {
const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
const { signedIn, permissions } = this.props.identity;
const pinned = !!columnId; const pinned = !!columnId;
const emptyMessage = canViewFeed(signedIn, permissions, localLiveFeedAccess) ? (
<FormattedMessage
id='empty_column.community'
defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!'
/>
) : (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return ( return (
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}> <Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader <ColumnHeader
@@ -147,7 +161,7 @@ class CommunityTimeline extends PureComponent {
scrollKey={`community_timeline-${columnId}`} scrollKey={`community_timeline-${columnId}`}
timelineId={`community${onlyMedia ? ':media' : ''}`} timelineId={`community${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />} emptyMessage={emptyMessage}
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
regex={this.props.regex} regex={this.props.regex}
/> />

View File

@@ -14,7 +14,8 @@ import { connectPublicStream, connectCommunityStream } from 'flavours/glitch/act
import { expandPublicTimeline, expandCommunityTimeline } from 'flavours/glitch/actions/timelines'; import { expandPublicTimeline, expandCommunityTimeline } from 'flavours/glitch/actions/timelines';
import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner'; import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner';
import SettingText from 'flavours/glitch/components/setting_text'; import SettingText from 'flavours/glitch/components/setting_text';
import { localLiveFeedAccess, remoteLiveFeedAccess, me, domain } from 'flavours/glitch/initial_state'; import { localLiveFeedAccess, remoteLiveFeedAccess, domain } from 'flavours/glitch/initial_state';
import { canViewFeed } from 'flavours/glitch/permissions';
import { useAppDispatch, useAppSelector } from 'flavours/glitch/store'; import { useAppDispatch, useAppSelector } from 'flavours/glitch/store';
import Column from '../../components/column'; import Column from '../../components/column';
@@ -75,7 +76,7 @@ const ColumnSettings = () => {
const Firehose = ({ feedType, multiColumn }) => { const Firehose = ({ feedType, multiColumn }) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const intl = useIntl(); const intl = useIntl();
const { signedIn } = useIdentity(); const { signedIn, permissions } = useIdentity();
const columnRef = useRef(null); const columnRef = useRef(null);
const allowLocalOnly = useAppSelector((state) => state.getIn(['settings', 'firehose', 'allowLocalOnly'])); const allowLocalOnly = useAppSelector((state) => state.getIn(['settings', 'firehose', 'allowLocalOnly']));
@@ -177,6 +178,15 @@ const Firehose = ({ feedType, multiColumn }) => {
/> />
); );
const canViewSelectedFeed = canViewFeed(signedIn, permissions, feedType === 'community' ? localLiveFeedAccess : remoteLiveFeedAccess);
const disabledTimelineMessage = (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return ( return (
<Column bindToDocument={!multiColumn} ref={columnRef} label={intl.formatMessage(messages.title)}> <Column bindToDocument={!multiColumn} ref={columnRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader <ColumnHeader
@@ -191,7 +201,7 @@ const Firehose = ({ feedType, multiColumn }) => {
<ColumnSettings /> <ColumnSettings />
</ColumnHeader> </ColumnHeader>
{(signedIn || (localLiveFeedAccess === 'public' && remoteLiveFeedAccess === 'public')) && ( {(canViewFeed(signedIn, permissions, localLiveFeedAccess) && canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) && (
<div className='account__section-headline'> <div className='account__section-headline'>
<NavLink exact to='/public/local'> <NavLink exact to='/public/local'>
<FormattedMessage tagName='div' id='firehose.local' defaultMessage='This server' /> <FormattedMessage tagName='div' id='firehose.local' defaultMessage='This server' />
@@ -213,7 +223,7 @@ const Firehose = ({ feedType, multiColumn }) => {
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
trackScroll trackScroll
scrollKey='firehose' scrollKey='firehose'
emptyMessage={emptyMessage} emptyMessage={canViewSelectedFeed ? emptyMessage : disabledTimelineMessage}
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
regex={regex} regex={regex}
/> />

View File

@@ -47,6 +47,7 @@ import {
me, me,
} from 'flavours/glitch/initial_state'; } from 'flavours/glitch/initial_state';
import { transientSingleColumn } from 'flavours/glitch/is_mobile'; import { transientSingleColumn } from 'flavours/glitch/is_mobile';
import { canViewFeed } from 'flavours/glitch/permissions';
import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications'; import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications';
import { useAppSelector, useAppDispatch } from 'flavours/glitch/store'; import { useAppSelector, useAppDispatch } from 'flavours/glitch/store';
@@ -208,7 +209,7 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
multiColumn = false, multiColumn = false,
}) => { }) => {
const intl = useIntl(); const intl = useIntl();
const { signedIn, disabledAccountId } = useIdentity(); const { signedIn, permissions, disabledAccountId } = useIdentity();
const location = useLocation(); const location = useLocation();
const showSearch = useBreakpoint('full') && !multiColumn; const showSearch = useBreakpoint('full') && !multiColumn;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@@ -286,13 +287,12 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
/> />
)} )}
{(signedIn || {(canViewFeed(signedIn, permissions, localLiveFeedAccess) ||
localLiveFeedAccess === 'public' || canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) && (
remoteLiveFeedAccess === 'public') && (
<ColumnLink <ColumnLink
transparent transparent
to={ to={
signedIn || localLiveFeedAccess === 'public' canViewFeed(signedIn, permissions, localLiveFeedAccess)
? '/public/local' ? '/public/local'
: '/public/remote' : '/public/remote'
} }

View File

@@ -10,7 +10,8 @@ import { connect } from 'react-redux';
import PublicIcon from '@/material-icons/400-24px/public.svg?react'; import PublicIcon from '@/material-icons/400-24px/public.svg?react';
import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner'; import { DismissableBanner } from 'flavours/glitch/components/dismissable_banner';
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
import { domain } from 'flavours/glitch/initial_state'; import { domain, localLiveFeedAccess, remoteLiveFeedAccess } from 'flavours/glitch/initial_state';
import { canViewFeed } from 'flavours/glitch/permissions';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import { connectPublicStream } from '../../actions/streaming'; import { connectPublicStream } from '../../actions/streaming';
@@ -128,8 +129,21 @@ class PublicTimeline extends PureComponent {
render () { render () {
const { intl, columnId, hasUnread, multiColumn, onlyMedia, onlyRemote, allowLocalOnly } = this.props; const { intl, columnId, hasUnread, multiColumn, onlyMedia, onlyRemote, allowLocalOnly } = this.props;
const { signedIn, permissions } = this.props.identity;
const pinned = !!columnId; const pinned = !!columnId;
const emptyMessage = (canViewFeed(signedIn, permissions, localLiveFeedAccess) || canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) ? (
<FormattedMessage
id='empty_column.public'
defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up'
/>
) : (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return ( return (
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}> <Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader <ColumnHeader
@@ -152,7 +166,7 @@ class PublicTimeline extends PureComponent {
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
trackScroll={!pinned} trackScroll={!pinned}
scrollKey={`public_timeline-${columnId}`} scrollKey={`public_timeline-${columnId}`}
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />} emptyMessage={emptyMessage}
bindToDocument={!multiColumn} bindToDocument={!multiColumn}
regex={this.props.regex} regex={this.props.regex}
/> />

View File

@@ -35,10 +35,10 @@ interface InitialStateMeta {
single_user_mode: boolean; single_user_mode: boolean;
source_url: string; source_url: string;
streaming_api_base_url: string; streaming_api_base_url: string;
local_live_feed_access: 'public' | 'authenticated'; local_live_feed_access: 'public' | 'authenticated' | 'disabled';
remote_live_feed_access: 'public' | 'authenticated'; remote_live_feed_access: 'public' | 'authenticated' | 'disabled';
local_topic_feed_access: 'public' | 'authenticated'; local_topic_feed_access: 'public' | 'authenticated' | 'disabled';
remote_topic_feed_access: 'public' | 'authenticated'; remote_topic_feed_access: 'public' | 'authenticated' | 'disabled';
title: string; title: string;
show_trends: boolean; show_trends: boolean;
trends_as_landing_page: boolean; trends_as_landing_page: boolean;

View File

@@ -1,3 +1,4 @@
export const PEMRISSION_VIEW_FEEDS = 0x0000000000100000;
export const PERMISSION_INVITE_USERS = 0x0000000000010000; export const PERMISSION_INVITE_USERS = 0x0000000000010000;
export const PERMISSION_MANAGE_USERS = 0x0000000000000400; export const PERMISSION_MANAGE_USERS = 0x0000000000000400;
export const PERMISSION_MANAGE_TAXONOMIES = 0x0000000000000100; export const PERMISSION_MANAGE_TAXONOMIES = 0x0000000000000100;
@@ -22,3 +23,19 @@ export function canManageReports(permissions: number) {
(permissions & PERMISSION_MANAGE_REPORTS) === PERMISSION_MANAGE_REPORTS (permissions & PERMISSION_MANAGE_REPORTS) === PERMISSION_MANAGE_REPORTS
); );
} }
export const canViewFeed = (
signedIn: boolean,
permissions: number,
setting: 'public' | 'authenticated' | 'disabled' | undefined,
) => {
switch (setting) {
case 'public':
return true;
case 'authenticated':
return signedIn;
case 'disabled':
default:
return (permissions & PEMRISSION_VIEW_FEEDS) === PEMRISSION_VIEW_FEEDS;
}
};