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.

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