You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

343 lines
16 KiB

  1. // Package imports
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
  6. // Our imports
  7. import LocalSettingsPageItem from './item';
  8. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  9. const messages = defineMessages({
  10. layout_auto: { id: 'layout.auto', defaultMessage: 'Auto' },
  11. layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' },
  12. layout_mobile: { id: 'layout.single', defaultMessage: 'Mobile' },
  13. side_arm_none: { id: 'settings.side_arm.none', defaultMessage: 'None' },
  14. side_arm_keep: { id: 'settings.side_arm_reply_mode.keep', defaultMessage: 'Keep secondary toot button to set privacy' },
  15. side_arm_copy: { id: 'settings.side_arm_reply_mode.copy', defaultMessage: 'Copy privacy setting of the toot being replied to' },
  16. side_arm_restrict: { id: 'settings.side_arm_reply_mode.restrict', defaultMessage: 'Restrict privacy setting to that of the toot being replied to' },
  17. regexp: { id: 'settings.content_warnings.regexp', defaultMessage: 'Regular expression' },
  18. });
  19. @injectIntl
  20. export default class LocalSettingsPage extends React.PureComponent {
  21. static propTypes = {
  22. index : PropTypes.number,
  23. intl : PropTypes.object.isRequired,
  24. onChange : PropTypes.func.isRequired,
  25. settings : ImmutablePropTypes.map.isRequired,
  26. };
  27. pages = [
  28. ({ intl, onChange, settings }) => (
  29. <div className='glitch local-settings__page general'>
  30. <h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1>
  31. <LocalSettingsPageItem
  32. settings={settings}
  33. item={['show_reply_count']}
  34. id='mastodon-settings--reply-count'
  35. onChange={onChange}
  36. >
  37. <FormattedMessage id='settings.show_reply_counter' defaultMessage='Display an estimate of the reply count' />
  38. </LocalSettingsPageItem>
  39. <section>
  40. <h2><FormattedMessage id='settings.notifications_opts' defaultMessage='Notifications options' /></h2>
  41. <LocalSettingsPageItem
  42. settings={settings}
  43. item={['notifications', 'tab_badge']}
  44. id='mastodon-settings--notifications-tab_badge'
  45. onChange={onChange}
  46. >
  47. <FormattedMessage id='settings.notifications.tab_badge' defaultMessage="Unread notifications badge" />
  48. <span className='hint'><FormattedMessage id='settings.notifications.tab_badge.hint' defaultMessage="Display a badge for unread notifications in the column icons when the notifications column isn't open" /></span>
  49. </LocalSettingsPageItem>
  50. <LocalSettingsPageItem
  51. settings={settings}
  52. item={['notifications', 'favicon_badge']}
  53. id='mastodon-settings--notifications-favicon_badge'
  54. onChange={onChange}
  55. >
  56. <FormattedMessage id='settings.notifications.favicon_badge' defaultMessage='Unread notifications favicon badge' />
  57. <span className='hint'><FormattedMessage id='settings.notifications.favicon_badge.hint' defaultMessage="Add a badge for unread notifications to the favicon" /></span>
  58. </LocalSettingsPageItem>
  59. </section>
  60. <section>
  61. <h2><FormattedMessage id='settings.layout_opts' defaultMessage='Layout options' /></h2>
  62. <LocalSettingsPageItem
  63. settings={settings}
  64. item={['layout']}
  65. id='mastodon-settings--layout'
  66. options={[
  67. { value: 'auto', message: intl.formatMessage(messages.layout_auto) },
  68. { value: 'multiple', message: intl.formatMessage(messages.layout_desktop) },
  69. { value: 'single', message: intl.formatMessage(messages.layout_mobile) },
  70. ]}
  71. onChange={onChange}
  72. >
  73. <FormattedMessage id='settings.layout' defaultMessage='Layout:' />
  74. </LocalSettingsPageItem>
  75. <LocalSettingsPageItem
  76. settings={settings}
  77. item={['stretch']}
  78. id='mastodon-settings--stretch'
  79. onChange={onChange}
  80. >
  81. <FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
  82. <span className='hint'><FormattedMessage id='settings.wide_view_hint' defaultMessage='Stretches columns to better fill the available space.' /></span>
  83. </LocalSettingsPageItem>
  84. <LocalSettingsPageItem
  85. settings={settings}
  86. item={['navbar_under']}
  87. id='mastodon-settings--navbar_under'
  88. onChange={onChange}
  89. >
  90. <FormattedMessage id='settings.navbar_under' defaultMessage='Navbar at the bottom (Mobile only)' />
  91. </LocalSettingsPageItem>
  92. <LocalSettingsPageItem
  93. settings={settings}
  94. item={['swipe_to_change_columns']}
  95. id='mastodon-settings--swipe_to_change_columns'
  96. onChange={onChange}
  97. >
  98. <FormattedMessage id='settings.swipe_to_change_columns' defaultMessage='Allow swiping to change columns (Mobile only)' />
  99. </LocalSettingsPageItem>
  100. </section>
  101. </div>
  102. ),
  103. ({ intl, onChange, settings }) => (
  104. <div className='glitch local-settings__page compose_box_opts'>
  105. <h1><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h1>
  106. <LocalSettingsPageItem
  107. settings={settings}
  108. item={['always_show_spoilers_field']}
  109. id='mastodon-settings--always_show_spoilers_field'
  110. onChange={onChange}
  111. >
  112. <FormattedMessage id='settings.always_show_spoilers_field' defaultMessage='Always enable the Content Warning field' />
  113. </LocalSettingsPageItem>
  114. <LocalSettingsPageItem
  115. settings={settings}
  116. item={['preselect_on_reply']}
  117. id='mastodon-settings--preselect_on_reply'
  118. onChange={onChange}
  119. >
  120. <FormattedMessage id='settings.preselect_on_reply' defaultMessage='Pre-select usernames on reply' />
  121. <span className='hint'><FormattedMessage id='settings.preselect_on_reply_hint' defaultMessage='When replying to a conversation with multiple participants, pre-select usernames past the first' /></span>
  122. </LocalSettingsPageItem>
  123. <LocalSettingsPageItem
  124. settings={settings}
  125. item={['confirm_missing_media_description']}
  126. id='mastodon-settings--confirm_missing_media_description'
  127. onChange={onChange}
  128. >
  129. <FormattedMessage id='settings.confirm_missing_media_description' defaultMessage='Show confirmation dialog before sending toots lacking media descriptions' />
  130. </LocalSettingsPageItem>
  131. <LocalSettingsPageItem
  132. settings={settings}
  133. item={['confirm_before_clearing_draft']}
  134. id='mastodon-settings--confirm_before_clearing_draft'
  135. onChange={onChange}
  136. >
  137. <FormattedMessage id='settings.confirm_before_clearing_draft' defaultMessage='Show confirmation dialog before overwriting the message being composed' />
  138. </LocalSettingsPageItem>
  139. <LocalSettingsPageItem
  140. settings={settings}
  141. item={['side_arm']}
  142. id='mastodon-settings--side_arm'
  143. options={[
  144. { value: 'none', message: intl.formatMessage(messages.side_arm_none) },
  145. { value: 'direct', message: intl.formatMessage({ id: 'privacy.direct.short' }) },
  146. { value: 'private', message: intl.formatMessage({ id: 'privacy.private.short' }) },
  147. { value: 'unlisted', message: intl.formatMessage({ id: 'privacy.unlisted.short' }) },
  148. { value: 'public', message: intl.formatMessage({ id: 'privacy.public.short' }) },
  149. ]}
  150. onChange={onChange}
  151. >
  152. <FormattedMessage id='settings.side_arm' defaultMessage='Secondary toot button:' />
  153. </LocalSettingsPageItem>
  154. <LocalSettingsPageItem
  155. settings={settings}
  156. item={['side_arm_reply_mode']}
  157. id='mastodon-settings--side_arm_reply_mode'
  158. options={[
  159. { value: 'keep', message: intl.formatMessage(messages.side_arm_keep) },
  160. { value: 'copy', message: intl.formatMessage(messages.side_arm_copy) },
  161. { value: 'restrict', message: intl.formatMessage(messages.side_arm_restrict) },
  162. ]}
  163. onChange={onChange}
  164. >
  165. <FormattedMessage id='settings.side_arm_reply_mode' defaultMessage='When replying to a toot:' />
  166. </LocalSettingsPageItem>
  167. </div>
  168. ),
  169. ({ intl, onChange, settings }) => (
  170. <div className='glitch local-settings__page content_warnings'>
  171. <h1><FormattedMessage id='settings.content_warnings' defaultMessage='Content warnings' /></h1>
  172. <LocalSettingsPageItem
  173. settings={settings}
  174. item={['content_warnings', 'auto_unfold']}
  175. id='mastodon-settings--content_warnings-auto_unfold'
  176. onChange={onChange}
  177. >
  178. <FormattedMessage id='settings.enable_content_warnings_auto_unfold' defaultMessage='Automatically unfold content-warnings' />
  179. </LocalSettingsPageItem>
  180. <LocalSettingsPageItem
  181. settings={settings}
  182. item={['content_warnings', 'filter']}
  183. id='mastodon-settings--content_warnings-auto_unfold'
  184. onChange={onChange}
  185. dependsOn={[['content_warnings', 'auto_unfold']]}
  186. placeholder={intl.formatMessage(messages.regexp)}
  187. >
  188. <FormattedMessage id='settings.content_warnings_filter' defaultMessage='Content warnings to not automatically unfold:' />
  189. </LocalSettingsPageItem>
  190. </div>
  191. ),
  192. ({ onChange, settings }) => (
  193. <div className='glitch local-settings__page collapsed'>
  194. <h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
  195. <LocalSettingsPageItem
  196. settings={settings}
  197. item={['collapsed', 'enabled']}
  198. id='mastodon-settings--collapsed-enabled'
  199. onChange={onChange}
  200. >
  201. <FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
  202. </LocalSettingsPageItem>
  203. <LocalSettingsPageItem
  204. settings={settings}
  205. item={['collapsed', 'show_action_bar']}
  206. id='mastodon-settings--collapsed-show-action-bar'
  207. onChange={onChange}
  208. dependsOn={[['collapsed', 'enabled']]}
  209. >
  210. <FormattedMessage id='settings.show_action_bar' defaultMessage='Show action buttons in collapsed toots' />
  211. </LocalSettingsPageItem>
  212. <section>
  213. <h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
  214. <LocalSettingsPageItem
  215. settings={settings}
  216. item={['collapsed', 'auto', 'all']}
  217. id='mastodon-settings--collapsed-auto-all'
  218. onChange={onChange}
  219. dependsOn={[['collapsed', 'enabled']]}
  220. >
  221. <FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
  222. </LocalSettingsPageItem>
  223. <LocalSettingsPageItem
  224. settings={settings}
  225. item={['collapsed', 'auto', 'notifications']}
  226. id='mastodon-settings--collapsed-auto-notifications'
  227. onChange={onChange}
  228. dependsOn={[['collapsed', 'enabled']]}
  229. dependsOnNot={[['collapsed', 'auto', 'all']]}
  230. >
  231. <FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
  232. </LocalSettingsPageItem>
  233. <LocalSettingsPageItem
  234. settings={settings}
  235. item={['collapsed', 'auto', 'lengthy']}
  236. id='mastodon-settings--collapsed-auto-lengthy'
  237. onChange={onChange}
  238. dependsOn={[['collapsed', 'enabled']]}
  239. dependsOnNot={[['collapsed', 'auto', 'all']]}
  240. >
  241. <FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
  242. </LocalSettingsPageItem>
  243. <LocalSettingsPageItem
  244. settings={settings}
  245. item={['collapsed', 'auto', 'reblogs']}
  246. id='mastodon-settings--collapsed-auto-reblogs'
  247. onChange={onChange}
  248. dependsOn={[['collapsed', 'enabled']]}
  249. dependsOnNot={[['collapsed', 'auto', 'all']]}
  250. >
  251. <FormattedMessage id='settings.auto_collapse_reblogs' defaultMessage='Boosts' />
  252. </LocalSettingsPageItem>
  253. <LocalSettingsPageItem
  254. settings={settings}
  255. item={['collapsed', 'auto', 'replies']}
  256. id='mastodon-settings--collapsed-auto-replies'
  257. onChange={onChange}
  258. dependsOn={[['collapsed', 'enabled']]}
  259. dependsOnNot={[['collapsed', 'auto', 'all']]}
  260. >
  261. <FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
  262. </LocalSettingsPageItem>
  263. <LocalSettingsPageItem
  264. settings={settings}
  265. item={['collapsed', 'auto', 'media']}
  266. id='mastodon-settings--collapsed-auto-media'
  267. onChange={onChange}
  268. dependsOn={[['collapsed', 'enabled']]}
  269. dependsOnNot={[['collapsed', 'auto', 'all']]}
  270. >
  271. <FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
  272. </LocalSettingsPageItem>
  273. </section>
  274. <section>
  275. <h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
  276. <LocalSettingsPageItem
  277. settings={settings}
  278. item={['collapsed', 'backgrounds', 'user_backgrounds']}
  279. id='mastodon-settings--collapsed-user-backgrouns'
  280. onChange={onChange}
  281. dependsOn={[['collapsed', 'enabled']]}
  282. >
  283. <FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
  284. </LocalSettingsPageItem>
  285. <LocalSettingsPageItem
  286. settings={settings}
  287. item={['collapsed', 'backgrounds', 'preview_images']}
  288. id='mastodon-settings--collapsed-preview-images'
  289. onChange={onChange}
  290. dependsOn={[['collapsed', 'enabled']]}
  291. >
  292. <FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
  293. </LocalSettingsPageItem>
  294. </section>
  295. </div>
  296. ),
  297. ({ onChange, settings }) => (
  298. <div className='glitch local-settings__page media'>
  299. <h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
  300. <LocalSettingsPageItem
  301. settings={settings}
  302. item={['media', 'letterbox']}
  303. id='mastodon-settings--media-letterbox'
  304. onChange={onChange}
  305. >
  306. <FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
  307. <span className='hint'><FormattedMessage id='settings.media_letterbox_hint' defaultMessage='Scale down and letterbox media to fill the image containers instead of stretching and cropping them' /></span>
  308. </LocalSettingsPageItem>
  309. <LocalSettingsPageItem
  310. settings={settings}
  311. item={['media', 'fullwidth']}
  312. id='mastodon-settings--media-fullwidth'
  313. onChange={onChange}
  314. >
  315. <FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
  316. </LocalSettingsPageItem>
  317. <LocalSettingsPageItem
  318. settings={settings}
  319. item={['inline_preview_cards']}
  320. id='mastodon-settings--inline-preview-cards'
  321. onChange={onChange}
  322. >
  323. <FormattedMessage id='settings.inline_preview_cards' defaultMessage='Inline preview cards for external links' />
  324. </LocalSettingsPageItem>
  325. </div>
  326. ),
  327. ];
  328. render () {
  329. const { pages } = this;
  330. const { index, intl, onChange, settings } = this.props;
  331. const CurrentPage = pages[index] || pages[0];
  332. return <CurrentPage intl={intl} onChange={onChange} settings={settings} />;
  333. }
  334. }