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.

175 lines
6.9 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. </div>
  50. ),
  51. ({ onChange, settings }) => (
  52. <div className='glitch local-settings__page collapsed'>
  53. <h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
  54. <LocalSettingsPageItem
  55. settings={settings}
  56. item={['collapsed', 'enabled']}
  57. id='mastodon-settings--collapsed-enabled'
  58. onChange={onChange}
  59. >
  60. <FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
  61. </LocalSettingsPageItem>
  62. <section>
  63. <h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
  64. <LocalSettingsPageItem
  65. settings={settings}
  66. item={['collapsed', 'auto', 'all']}
  67. id='mastodon-settings--collapsed-auto-all'
  68. onChange={onChange}
  69. dependsOn={[['collapsed', 'enabled']]}
  70. >
  71. <FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
  72. </LocalSettingsPageItem>
  73. <LocalSettingsPageItem
  74. settings={settings}
  75. item={['collapsed', 'auto', 'notifications']}
  76. id='mastodon-settings--collapsed-auto-notifications'
  77. onChange={onChange}
  78. dependsOn={[['collapsed', 'enabled']]}
  79. dependsOnNot={[['collapsed', 'auto', 'all']]}
  80. >
  81. <FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
  82. </LocalSettingsPageItem>
  83. <LocalSettingsPageItem
  84. settings={settings}
  85. item={['collapsed', 'auto', 'lengthy']}
  86. id='mastodon-settings--collapsed-auto-lengthy'
  87. onChange={onChange}
  88. dependsOn={[['collapsed', 'enabled']]}
  89. dependsOnNot={[['collapsed', 'auto', 'all']]}
  90. >
  91. <FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
  92. </LocalSettingsPageItem>
  93. <LocalSettingsPageItem
  94. settings={settings}
  95. item={['collapsed', 'auto', 'replies']}
  96. id='mastodon-settings--collapsed-auto-replies'
  97. onChange={onChange}
  98. dependsOn={[['collapsed', 'enabled']]}
  99. dependsOnNot={[['collapsed', 'auto', 'all']]}
  100. >
  101. <FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
  102. </LocalSettingsPageItem>
  103. <LocalSettingsPageItem
  104. settings={settings}
  105. item={['collapsed', 'auto', 'media']}
  106. id='mastodon-settings--collapsed-auto-media'
  107. onChange={onChange}
  108. dependsOn={[['collapsed', 'enabled']]}
  109. dependsOnNot={[['collapsed', 'auto', 'all']]}
  110. >
  111. <FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
  112. </LocalSettingsPageItem>
  113. </section>
  114. <section>
  115. <h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
  116. <LocalSettingsPageItem
  117. settings={settings}
  118. item={['collapsed', 'backgrounds', 'user_backgrounds']}
  119. id='mastodon-settings--collapsed-user-backgrouns'
  120. onChange={onChange}
  121. dependsOn={[['collapsed', 'enabled']]}
  122. >
  123. <FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
  124. </LocalSettingsPageItem>
  125. <LocalSettingsPageItem
  126. settings={settings}
  127. item={['collapsed', 'backgrounds', 'preview_images']}
  128. id='mastodon-settings--collapsed-preview-images'
  129. onChange={onChange}
  130. dependsOn={[['collapsed', 'enabled']]}
  131. >
  132. <FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
  133. </LocalSettingsPageItem>
  134. </section>
  135. </div>
  136. ),
  137. ({ onChange, settings }) => (
  138. <div className='glitch local-settings__page media'>
  139. <h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
  140. <LocalSettingsPageItem
  141. settings={settings}
  142. item={['media', 'letterbox']}
  143. id='mastodon-settings--media-letterbox'
  144. onChange={onChange}
  145. >
  146. <FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
  147. </LocalSettingsPageItem>
  148. <LocalSettingsPageItem
  149. settings={settings}
  150. item={['media', 'fullwidth']}
  151. id='mastodon-settings--media-fullwidth'
  152. onChange={onChange}
  153. >
  154. <FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
  155. </LocalSettingsPageItem>
  156. </div>
  157. ),
  158. ];
  159. render () {
  160. const { pages } = this;
  161. const { index, intl, onChange, settings } = this.props;
  162. const CurrentPage = pages[index] || pages[0];
  163. return <CurrentPage intl={intl} onChange={onChange} settings={settings} />;
  164. }
  165. }