mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
add gallery timeline and link in panel
This commit is contained in:
parent
01f4fc4c43
commit
4b62c4447f
@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
import SettingToggle from '../../notifications/components/setting_toggle';
|
||||||
|
|
||||||
|
export default @injectIntl
|
||||||
|
class ColumnSettings extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
columnId: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { settings, onChange } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className='column-settings__row'>
|
||||||
|
<SettingToggle settings={settings} settingPath={['other', 'onlyMedia']} onChange={onChange} label={<FormattedMessage id='community.column_settings.media_only' defaultMessage='Media only' />} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ColumnSettings from '../components/column_settings';
|
||||||
|
import { changeSetting } from '../../../actions/settings';
|
||||||
|
import { changeColumnParams } from '../../../actions/columns';
|
||||||
|
|
||||||
|
const mapStateToProps = (state, { columnId }) => {
|
||||||
|
const uuid = columnId;
|
||||||
|
const columns = state.getIn(['settings', 'columns']);
|
||||||
|
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||||
|
|
||||||
|
return {
|
||||||
|
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch, { columnId }) => {
|
||||||
|
return {
|
||||||
|
onChange (key, checked) {
|
||||||
|
if (columnId) {
|
||||||
|
dispatch(changeColumnParams(columnId, key, checked));
|
||||||
|
} else {
|
||||||
|
dispatch(changeSetting(['community', ...key], checked));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|
139
app/javascript/mastodon/features/gallery_timeline/index.js
Normal file
139
app/javascript/mastodon/features/gallery_timeline/index.js
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import StatusListContainer from '../ui/containers/status_list_container';
|
||||||
|
import Column from '../../components/column';
|
||||||
|
import ColumnHeader from '../../components/column_header';
|
||||||
|
import { expandCommunityTimeline } from '../../actions/timelines';
|
||||||
|
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
||||||
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
import { connectCommunityStream } from '../../actions/streaming';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
title: { id: 'column.community', defaultMessage: 'Local timeline' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStateToProps = (state, { columnId }) => {
|
||||||
|
const uuid = columnId;
|
||||||
|
const columns = state.getIn(['settings', 'columns']);
|
||||||
|
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||||
|
const onlyMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']);
|
||||||
|
const timelineState = state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasUnread: !!timelineState && timelineState.get('unread') > 0,
|
||||||
|
onlyMedia,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default @connect(mapStateToProps)
|
||||||
|
@injectIntl
|
||||||
|
class GalleryTimeline extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
onlyMedia: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
dispatch: PropTypes.func.isRequired,
|
||||||
|
shouldUpdateScroll: PropTypes.func,
|
||||||
|
columnId: PropTypes.string,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
hasUnread: PropTypes.bool,
|
||||||
|
multiColumn: PropTypes.bool,
|
||||||
|
onlyMedia: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
handlePin = () => {
|
||||||
|
const { columnId, dispatch } = this.props;
|
||||||
|
|
||||||
|
const onlyMedia = true;
|
||||||
|
|
||||||
|
if (columnId) {
|
||||||
|
dispatch(removeColumn(columnId));
|
||||||
|
} else {
|
||||||
|
dispatch(addColumn('COMMUNITY', { other: { onlyMedia } }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMove = (dir) => {
|
||||||
|
const { columnId, dispatch } = this.props;
|
||||||
|
dispatch(moveColumn(columnId, dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleHeaderClick = () => {
|
||||||
|
this.column.scrollTop();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
const { dispatch, onlyMedia } = this.props;
|
||||||
|
|
||||||
|
dispatch(expandCommunityTimeline({ onlyMedia }));
|
||||||
|
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate (prevProps) {
|
||||||
|
if (prevProps.onlyMedia !== this.props.onlyMedia) {
|
||||||
|
const { dispatch, onlyMedia } = this.props;
|
||||||
|
|
||||||
|
this.disconnect();
|
||||||
|
dispatch(expandCommunityTimeline({ onlyMedia }));
|
||||||
|
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
if (this.disconnect) {
|
||||||
|
this.disconnect();
|
||||||
|
this.disconnect = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = c => {
|
||||||
|
this.column = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLoadMore = maxId => {
|
||||||
|
const { dispatch, onlyMedia } = this.props;
|
||||||
|
|
||||||
|
dispatch(expandCommunityTimeline({ maxId, onlyMedia }));
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { intl, shouldUpdateScroll, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
|
||||||
|
const pinned = !!columnId;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
|
||||||
|
<ColumnHeader
|
||||||
|
icon='paint-brush'
|
||||||
|
active={hasUnread}
|
||||||
|
title={"GALLERIIIIIIE"}
|
||||||
|
onPin={this.handlePin}
|
||||||
|
onMove={this.handleMove}
|
||||||
|
onClick={this.handleHeaderClick}
|
||||||
|
pinned={pinned}
|
||||||
|
multiColumn={multiColumn}
|
||||||
|
>
|
||||||
|
<ColumnSettingsContainer columnId={columnId} />
|
||||||
|
</ColumnHeader>
|
||||||
|
|
||||||
|
<StatusListContainer
|
||||||
|
trackScroll={!pinned}
|
||||||
|
scrollKey={`community_timeline-${columnId}`}
|
||||||
|
timelineId={`community${onlyMedia ? ':media' : ''}`}
|
||||||
|
onLoadMore={this.handleLoadMore}
|
||||||
|
emptyMessage={<FormattedMessage id='empty_column.gallery' defaultMessage='The Gallery timeline is empty. Write something publicly to get the ball rolling!' />}
|
||||||
|
shouldUpdateScroll={shouldUpdateScroll}
|
||||||
|
bindToDocument={!multiColumn}
|
||||||
|
/>
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export default class GalleryTk extends React.PureComponent {
|
||||||
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='messaging-container'>
|
||||||
|
<h1 >La page de gallerie</h1 >
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -52,7 +52,21 @@ const NavigationPanel = () => (
|
|||||||
id='tabs_bar.federated_timeline'
|
id='tabs_bar.federated_timeline'
|
||||||
defaultMessage='Federated'
|
defaultMessage='Federated'
|
||||||
/></NavLink >
|
/></NavLink >
|
||||||
|
<NavLink
|
||||||
|
className='column-link column-link--transparent'
|
||||||
|
exact
|
||||||
|
to='/timelines/gallery-bliss'
|
||||||
|
data-preview-title-id='column.gallery'
|
||||||
|
data-preview-icon='art'
|
||||||
|
><Icon
|
||||||
|
className='column-link__icon'
|
||||||
|
id='paint-brush'
|
||||||
|
fixedWidth
|
||||||
|
/> <FormattedMessage
|
||||||
|
id='tabs_bar.gallery_timeline'
|
||||||
|
defaultMessage='Gallery'
|
||||||
|
/>
|
||||||
|
</NavLink >
|
||||||
</div >
|
</div >
|
||||||
<div className='spacer' />
|
<div className='spacer' />
|
||||||
<NavLink
|
<NavLink
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
KeyboardShortcuts,
|
KeyboardShortcuts,
|
||||||
PublicTimeline,
|
PublicTimeline,
|
||||||
CommunityTimeline,
|
CommunityTimeline,
|
||||||
|
GalleryTimeline,
|
||||||
AccountTimeline,
|
AccountTimeline,
|
||||||
AccountGallery,
|
AccountGallery,
|
||||||
HomeTimeline,
|
HomeTimeline,
|
||||||
@ -59,6 +60,7 @@ import { previewState as previewVideoState } from './components/video_modal';
|
|||||||
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
||||||
// Without this it ends up in ~8 very commonly used bundles.
|
// Without this it ends up in ~8 very commonly used bundles.
|
||||||
import '../../components/status';
|
import '../../components/status';
|
||||||
|
import GalleryTk from './components/bliss/gallery-tk';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
beforeUnload: { id: 'ui.beforeunload', defaultMessage: 'Your draft will be lost if you leave Mastodon.' },
|
beforeUnload: { id: 'ui.beforeunload', defaultMessage: 'Your draft will be lost if you leave Mastodon.' },
|
||||||
@ -159,6 +161,7 @@ class SwitchingColumnsArea extends React.PureComponent {
|
|||||||
<WrappedRoute path='/timelines/public' exact component={PublicTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/timelines/public' exact component={PublicTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
<WrappedRoute path='/timelines/public/local' exact component={CommunityTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/timelines/public/local' exact component={CommunityTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
<WrappedRoute path='/timelines/direct' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/timelines/direct' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
|
<WrappedRoute path='/timelines/gallery-bliss' component={GalleryTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
<WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
<WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ export function PublicTimeline () {
|
|||||||
export function CommunityTimeline () {
|
export function CommunityTimeline () {
|
||||||
return import(/* webpackChunkName: "features/community_timeline" */'../../community_timeline');
|
return import(/* webpackChunkName: "features/community_timeline" */'../../community_timeline');
|
||||||
}
|
}
|
||||||
|
export function GalleryTimeline () {
|
||||||
|
return import(/* webpackChunkName: "features/gallery_timeline" */'../../gallery_timeline');
|
||||||
|
}
|
||||||
|
|
||||||
export function HashtagTimeline () {
|
export function HashtagTimeline () {
|
||||||
return import(/* webpackChunkName: "features/hashtag_timeline" */'../../hashtag_timeline');
|
return import(/* webpackChunkName: "features/hashtag_timeline" */'../../hashtag_timeline');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user