1
0

Remove timeline preview link from nav panel when not signed-in (#19320)

* Remove timeline preview link from nav panel when not signed-in

* Always enable server stats
This commit is contained in:
Yamagishi Kazutoshi 2022-10-09 10:49:51 +09:00 committed by GitHub
parent 45ebdb72ca
commit e82467ca41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 15 deletions

View File

@ -1,12 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { domain } from 'mastodon/initial_state'; import React from 'react';
import { fetchServer } from 'mastodon/actions/server'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Account from 'mastodon/containers/account_container'; import { fetchServer } from 'mastodon/actions/server';
import ShortNumber from 'mastodon/components/short_number'; import ShortNumber from 'mastodon/components/short_number';
import Skeleton from 'mastodon/components/skeleton'; import Skeleton from 'mastodon/components/skeleton';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl'; import Account from 'mastodon/containers/account_container';
import { domain } from 'mastodon/initial_state';
const messages = defineMessages({ const messages = defineMessages({
aboutActiveUsers: { id: 'server_banner.about_active_users', defaultMessage: 'People using this server during the last 30 days (Monthly Active Users)' }, aboutActiveUsers: { id: 'server_banner.about_active_users', defaultMessage: 'People using this server during the last 30 days (Monthly Active Users)' },

View File

@ -1,14 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { NavLink, Link } from 'react-router-dom'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { Link, NavLink } from 'react-router-dom';
import Icon from 'mastodon/components/icon'; import Icon from 'mastodon/components/icon';
import { showTrends } from 'mastodon/initial_state'; import Logo from 'mastodon/components/logo';
import NotificationsCounterIcon from './notifications_counter_icon'; import TrendsContainer from 'mastodon/features/getting_started/containers/trends_container';
import { showTrends, timelinePreview } from 'mastodon/initial_state';
import FollowRequestsNavLink from './follow_requests_nav_link'; import FollowRequestsNavLink from './follow_requests_nav_link';
import ListPanel from './list_panel'; import ListPanel from './list_panel';
import TrendsContainer from 'mastodon/features/getting_started/containers/trends_container'; import NotificationsCounterIcon from './notifications_counter_icon';
import Logo from 'mastodon/components/logo';
import SignInBanner from './sign_in_banner'; import SignInBanner from './sign_in_banner';
export default class NavigationPanel extends React.Component { export default class NavigationPanel extends React.Component {
@ -37,8 +37,12 @@ export default class NavigationPanel extends React.Component {
)} )}
<NavLink className='column-link column-link--transparent' to='/explore' data-preview-title-id='explore.title' data-preview-icon='hashtag'><Icon className='column-link__icon' id='hashtag' fixedWidth /><FormattedMessage id='explore.title' defaultMessage='Explore' /></NavLink> <NavLink className='column-link column-link--transparent' to='/explore' data-preview-title-id='explore.title' data-preview-icon='hashtag'><Icon className='column-link__icon' id='hashtag' fixedWidth /><FormattedMessage id='explore.title' defaultMessage='Explore' /></NavLink>
{signedIn || timelinePreview && (
<>
<NavLink className='column-link column-link--transparent' to='/public/local' data-preview-title-id='column.community' data-preview-icon='users' ><Icon className='column-link__icon' id='users' fixedWidth /><FormattedMessage id='tabs_bar.local_timeline' defaultMessage='Local' /></NavLink> <NavLink className='column-link column-link--transparent' to='/public/local' data-preview-title-id='column.community' data-preview-icon='users' ><Icon className='column-link__icon' id='users' fixedWidth /><FormattedMessage id='tabs_bar.local_timeline' defaultMessage='Local' /></NavLink>
<NavLink className='column-link column-link--transparent' exact to='/public' data-preview-title-id='column.public' data-preview-icon='globe' ><Icon className='column-link__icon' id='globe' fixedWidth /><FormattedMessage id='tabs_bar.federated_timeline' defaultMessage='Federated' /></NavLink> <NavLink className='column-link column-link--transparent' exact to='/public' data-preview-title-id='column.public' data-preview-icon='globe' ><Icon className='column-link__icon' id='globe' fixedWidth /><FormattedMessage id='tabs_bar.federated_timeline' defaultMessage='Federated' /></NavLink>
</>
)}
{!signedIn && ( {!signedIn && (
<div className='navigation-panel__sign-in-banner'> <div className='navigation-panel__sign-in-banner'>

View File

@ -1,7 +1,59 @@
// @ts-check
/**
* @typedef {[code: string, name: string, localName: string]} InitialStateLanguage
*/
/**
* @typedef InitialStateMeta
* @property {string} access_token
* @property {boolean=} advanced_layout
* @property {boolean} auto_play_gif
* @property {boolean} activity_api_enabled
* @property {string} admin
* @property {boolean=} boost_modal
* @property {boolean} crop_images
* @property {boolean=} delete_modal
* @property {boolean=} disable_swiping
* @property {boolean} display_media
* @property {string} domain
* @property {boolean=} expand_spoilers
* @property {boolean} limited_federation_mode
* @property {string} locale
* @property {string | null} mascot
* @property {string=} me
* @property {boolean} profile_directory
* @property {boolean} registrations_open
* @property {boolean} reduce_motion
* @property {string} repository
* @property {boolean} search_enabled
* @property {string} source_url
* @property {string} streaming_api_base_url
* @property {boolean} timeline_preview
* @property {string} title
* @property {boolean} trends
* @property {boolean} unfollow_modal
* @property {boolean} use_blurhash
* @property {boolean=} use_pending_items
* @property {string} version
*/
/**
* @typedef InitialState
* @property {InitialStateLanguage[]} languages
* @property {InitialStateMeta} meta
*/
const element = document.getElementById('initial-state'); const element = document.getElementById('initial-state');
/** @type {InitialState | undefined} */
const initialState = element && JSON.parse(element.textContent); const initialState = element && JSON.parse(element.textContent);
const getMeta = (prop) => initialState && initialState.meta && initialState.meta[prop]; /**
* @template {keyof InitialStateMeta} K
* @param {K} prop
* @returns {InitialStateMeta[K] | undefined}
*/
const getMeta = (prop) => initialState?.meta && initialState.meta[prop];
export const domain = getMeta('domain'); export const domain = getMeta('domain');
export const reduceMotion = getMeta('reduce_motion'); export const reduceMotion = getMeta('reduce_motion');
@ -27,6 +79,8 @@ export const showTrends = getMeta('trends');
export const title = getMeta('title'); export const title = getMeta('title');
export const cropImages = getMeta('crop_images'); export const cropImages = getMeta('crop_images');
export const disableSwiping = getMeta('disable_swiping'); export const disableSwiping = getMeta('disable_swiping');
export const languages = initialState && initialState.languages; export const timelinePreview = getMeta('timeline_preview');
export const activityApiEnabled = getMeta('activity_api_enabled');
export const languages = initialState?.languages;
export default initialState; export default initialState;

View File

@ -28,6 +28,8 @@ class InitialStateSerializer < ActiveModel::Serializer
profile_directory: Setting.profile_directory, profile_directory: Setting.profile_directory,
trends: Setting.trends, trends: Setting.trends,
registrations_open: Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode, registrations_open: Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode,
timeline_preview: Setting.timeline_preview,
activity_api_enabled: Setting.activity_api_enabled,
} }
if object.current_account if object.current_account