about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/community_timeline/components
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-12-18 18:52:37 +0100
committerThibG <thib@sitedethib.com>2018-12-18 21:39:35 +0100
commit82b01a6c9f13ab63818da3bfb8ee9cfcfda0cdd6 (patch)
tree35f67570b4c006f4a27cb322cbea863da293b4f0 /app/javascript/flavours/glitch/features/community_timeline/components
parent9fc7ad7b9ce663a9daff9fdd4d934c101f6e38c0 (diff)
[Glitch] Put "Media Only" option in column settings instead of content area headline
Port 4f42238c294f92dbd87db3d83f9514344fcd1f8a to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/features/community_timeline/components')
-rw-r--r--app/javascript/flavours/glitch/features/community_timeline/components/column_settings.js6
-rw-r--r--app/javascript/flavours/glitch/features/community_timeline/components/section_headline.js59
2 files changed, 6 insertions, 59 deletions
diff --git a/app/javascript/flavours/glitch/features/community_timeline/components/column_settings.js b/app/javascript/flavours/glitch/features/community_timeline/components/column_settings.js
index aad5f3976..96db003ce 100644
--- a/app/javascript/flavours/glitch/features/community_timeline/components/column_settings.js
+++ b/app/javascript/flavours/glitch/features/community_timeline/components/column_settings.js
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
 import ImmutablePropTypes from 'react-immutable-proptypes';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import SettingText from 'flavours/glitch/components/setting_text';
+import SettingToggle from 'flavours/glitch/features/notifications/components/setting_toggle';
 
 const messages = defineMessages({
   filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' },
@@ -16,6 +17,7 @@ export default class ColumnSettings extends React.PureComponent {
     settings: ImmutablePropTypes.map.isRequired,
     onChange: PropTypes.func.isRequired,
     intl: PropTypes.object.isRequired,
+    columnId: PropTypes.string,
   };
 
   render () {
@@ -23,6 +25,10 @@ export default class ColumnSettings extends React.PureComponent {
 
     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>
+
         <span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
 
         <div className='column-settings__row'>
diff --git a/app/javascript/flavours/glitch/features/community_timeline/components/section_headline.js b/app/javascript/flavours/glitch/features/community_timeline/components/section_headline.js
deleted file mode 100644
index 8c0c68cdc..000000000
--- a/app/javascript/flavours/glitch/features/community_timeline/components/section_headline.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import PropTypes from 'prop-types';
-import React, { Component, Fragment } from 'react';
-import { FormattedMessage } from 'react-intl';
-import { NavLink } from 'react-router-dom';
-
-export default class SectionHeadline extends Component {
-
-  static propTypes = {
-    timelineId: PropTypes.string.isRequired,
-    to: PropTypes.string.isRequired,
-    pinned: PropTypes.bool.isRequired,
-    onlyMedia: PropTypes.bool.isRequired,
-    onClick: PropTypes.func,
-  };
-
-  shouldComponentUpdate (nextProps) {
-    return (
-      this.props.onlyMedia !== nextProps.onlyMedia ||
-      this.props.pinned !== nextProps.pinned ||
-      this.props.to !== nextProps.to ||
-      this.props.timelineId !== nextProps.timelineId
-    );
-  }
-
-  handleClick = e => {
-    const { onClick } = this.props;
-
-    if (typeof onClick === 'function') {
-      e.preventDefault();
-
-      onClick.call(this, e);
-    }
-  }
-
-  render () {
-    const { timelineId, to, pinned, onlyMedia } = this.props;
-
-    return (
-      <div className={`${timelineId}-timeline__section-headline`}>
-        {pinned ? (
-          <Fragment>
-            <a href={to} className={!onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
-              <FormattedMessage id='timeline.posts' defaultMessage='Toots' />
-            </a>
-            <a href={`${to}/media`} className={onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
-              <FormattedMessage id='timeline.media' defaultMessage='Media' />
-            </a>
-          </Fragment>
-        ) : (
-          <Fragment>
-            <NavLink exact to={to}><FormattedMessage id='timeline.posts' defaultMessage='Toots' /></NavLink>
-            <NavLink exact to={`${to}/media`}><FormattedMessage id='timeline.media' defaultMessage='Media' /></NavLink>
-          </Fragment>
-        )}
-      </div>
-    );
-  }
-
-}