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.

209 lines
8.7 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. });
  15. @injectIntl
  16. export default class LocalSettingsPage extends React.PureComponent {
  17. static propTypes = {
  18. index : PropTypes.number,
  19. intl : PropTypes.object.isRequired,
  20. onChange : PropTypes.func.isRequired,
  21. settings : ImmutablePropTypes.map.isRequired,
  22. };
  23. pages = [
  24. ({ intl, onChange, settings }) => (
  25. <div className='glitch local-settings__page general'>
  26. <h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1>
  27. <LocalSettingsPageItem
  28. settings={settings}
  29. item={['layout']}
  30. id='mastodon-settings--layout'
  31. options={[
  32. { value: 'auto', message: intl.formatMessage(messages.layout_auto) },
  33. { value: 'multiple', message: intl.formatMessage(messages.layout_desktop) },
  34. { value: 'single', message: intl.formatMessage(messages.layout_mobile) },
  35. ]}
  36. onChange={onChange}
  37. >
  38. <FormattedMessage id='settings.layout' defaultMessage='Layout:' />
  39. </LocalSettingsPageItem>
  40. <LocalSettingsPageItem
  41. settings={settings}
  42. item={['stretch']}
  43. id='mastodon-settings--stretch'
  44. onChange={onChange}
  45. >
  46. <FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
  47. </LocalSettingsPageItem>
  48. <LocalSettingsPageItem
  49. settings={settings}
  50. item={['navbar_under']}
  51. id='mastodon-settings--navbar_under'
  52. onChange={onChange}
  53. >
  54. <FormattedMessage id='settings.navbar_under' defaultMessage='Navbar at the bottom (Mobile only)' />
  55. </LocalSettingsPageItem>
  56. <section>
  57. <h2><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h2>
  58. <LocalSettingsPageItem
  59. settings={settings}
  60. item={['side_arm']}
  61. id='mastodon-settings--side_arm'
  62. options={[
  63. { value: 'none', message: intl.formatMessage(messages.side_arm_none) },
  64. { value: 'direct', message: intl.formatMessage({ id: 'privacy.direct.short' }) },
  65. { value: 'private', message: intl.formatMessage({ id: 'privacy.private.short' }) },
  66. { value: 'unlisted', message: intl.formatMessage({ id: 'privacy.unlisted.short' }) },
  67. { value: 'public', message: intl.formatMessage({ id: 'privacy.public.short' }) },
  68. ]}
  69. onChange={onChange}
  70. >
  71. <FormattedMessage id='settings.side_arm' defaultMessage='Secondary toot button:' />
  72. </LocalSettingsPageItem>
  73. </section>
  74. </div>
  75. ),
  76. ({ onChange, settings }) => (
  77. <div className='glitch local-settings__page collapsed'>
  78. <h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
  79. <LocalSettingsPageItem
  80. settings={settings}
  81. item={['collapsed', 'enabled']}
  82. id='mastodon-settings--collapsed-enabled'
  83. onChange={onChange}
  84. >
  85. <FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
  86. </LocalSettingsPageItem>
  87. <section>
  88. <h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
  89. <LocalSettingsPageItem
  90. settings={settings}
  91. item={['collapsed', 'auto', 'all']}
  92. id='mastodon-settings--collapsed-auto-all'
  93. onChange={onChange}
  94. dependsOn={[['collapsed', 'enabled']]}
  95. >
  96. <FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
  97. </LocalSettingsPageItem>
  98. <LocalSettingsPageItem
  99. settings={settings}
  100. item={['collapsed', 'auto', 'notifications']}
  101. id='mastodon-settings--collapsed-auto-notifications'
  102. onChange={onChange}
  103. dependsOn={[['collapsed', 'enabled']]}
  104. dependsOnNot={[['collapsed', 'auto', 'all']]}
  105. >
  106. <FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
  107. </LocalSettingsPageItem>
  108. <LocalSettingsPageItem
  109. settings={settings}
  110. item={['collapsed', 'auto', 'lengthy']}
  111. id='mastodon-settings--collapsed-auto-lengthy'
  112. onChange={onChange}
  113. dependsOn={[['collapsed', 'enabled']]}
  114. dependsOnNot={[['collapsed', 'auto', 'all']]}
  115. >
  116. <FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
  117. </LocalSettingsPageItem>
  118. <LocalSettingsPageItem
  119. settings={settings}
  120. item={['collapsed', 'auto', 'reblogs']}
  121. id='mastodon-settings--collapsed-auto-reblogs'
  122. onChange={onChange}
  123. dependsOn={[['collapsed', 'enabled']]}
  124. dependsOnNot={[['collapsed', 'auto', 'all']]}
  125. >
  126. <FormattedMessage id='settings.auto_collapse_reblogs' defaultMessage='Boosts' />
  127. </LocalSettingsPageItem>
  128. <LocalSettingsPageItem
  129. settings={settings}
  130. item={['collapsed', 'auto', 'replies']}
  131. id='mastodon-settings--collapsed-auto-replies'
  132. onChange={onChange}
  133. dependsOn={[['collapsed', 'enabled']]}
  134. dependsOnNot={[['collapsed', 'auto', 'all']]}
  135. >
  136. <FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
  137. </LocalSettingsPageItem>
  138. <LocalSettingsPageItem
  139. settings={settings}
  140. item={['collapsed', 'auto', 'media']}
  141. id='mastodon-settings--collapsed-auto-media'
  142. onChange={onChange}
  143. dependsOn={[['collapsed', 'enabled']]}
  144. dependsOnNot={[['collapsed', 'auto', 'all']]}
  145. >
  146. <FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
  147. </LocalSettingsPageItem>
  148. </section>
  149. <section>
  150. <h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
  151. <LocalSettingsPageItem
  152. settings={settings}
  153. item={['collapsed', 'backgrounds', 'user_backgrounds']}
  154. id='mastodon-settings--collapsed-user-backgrouns'
  155. onChange={onChange}
  156. dependsOn={[['collapsed', 'enabled']]}
  157. >
  158. <FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
  159. </LocalSettingsPageItem>
  160. <LocalSettingsPageItem
  161. settings={settings}
  162. item={['collapsed', 'backgrounds', 'preview_images']}
  163. id='mastodon-settings--collapsed-preview-images'
  164. onChange={onChange}
  165. dependsOn={[['collapsed', 'enabled']]}
  166. >
  167. <FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
  168. </LocalSettingsPageItem>
  169. </section>
  170. </div>
  171. ),
  172. ({ onChange, settings }) => (
  173. <div className='glitch local-settings__page media'>
  174. <h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
  175. <LocalSettingsPageItem
  176. settings={settings}
  177. item={['media', 'letterbox']}
  178. id='mastodon-settings--media-letterbox'
  179. onChange={onChange}
  180. >
  181. <FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
  182. </LocalSettingsPageItem>
  183. <LocalSettingsPageItem
  184. settings={settings}
  185. item={['media', 'fullwidth']}
  186. id='mastodon-settings--media-fullwidth'
  187. onChange={onChange}
  188. >
  189. <FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
  190. </LocalSettingsPageItem>
  191. </div>
  192. ),
  193. ];
  194. render () {
  195. const { pages } = this;
  196. const { index, intl, onChange, settings } = this.props;
  197. const CurrentPage = pages[index] || pages[0];
  198. return <CurrentPage intl={intl} onChange={onChange} settings={settings} />;
  199. }
  200. }