accountPreferences.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import type {JsonFormObject} from 'sentry/components/forms/types';
  2. import languages from 'sentry/data/languages';
  3. import {timezoneOptions} from 'sentry/data/timezones';
  4. import {t} from 'sentry/locale';
  5. import {removeBodyTheme} from 'sentry/utils/removeBodyTheme';
  6. // Export route to make these forms searchable by label/help
  7. export const route = '/settings/account/details/';
  8. // Called before sending API request, these fields need to be sent as an
  9. // `options` object
  10. const transformOptions = (data: object) => ({options: data});
  11. const formGroups: JsonFormObject[] = [
  12. {
  13. // Form "section"/"panel"
  14. title: 'Preferences',
  15. fields: [
  16. {
  17. name: 'theme',
  18. type: 'select',
  19. label: t('Theme'),
  20. help: t(
  21. "Select your theme preference. It can be synced to your system's theme, always light mode, or always dark mode."
  22. ),
  23. options: [
  24. {value: 'light', label: t('Light')},
  25. {value: 'dark', label: t('Dark')},
  26. {value: 'system', label: t('Default to system')},
  27. ],
  28. getData: transformOptions,
  29. onChange: () => {
  30. removeBodyTheme();
  31. },
  32. },
  33. {
  34. name: 'language',
  35. type: 'select',
  36. label: t('Language'),
  37. options: languages.map(([value, label]) => ({value, label})),
  38. getData: transformOptions,
  39. },
  40. {
  41. name: 'timezone',
  42. type: 'select',
  43. label: t('Timezone'),
  44. options: timezoneOptions,
  45. getData: transformOptions,
  46. },
  47. {
  48. name: 'clock24Hours',
  49. type: 'boolean',
  50. label: t('Use a 24-hour clock'),
  51. getData: transformOptions,
  52. },
  53. {
  54. name: 'stacktraceOrder',
  55. type: 'select',
  56. required: false,
  57. options: [
  58. {value: -1, label: t('Default')},
  59. {value: 1, label: t('Oldest')},
  60. {value: 2, label: t('Newest')},
  61. ],
  62. label: t('Stack Trace Order'),
  63. help: t('Choose the default ordering of frames in stack traces'),
  64. getData: transformOptions,
  65. },
  66. {
  67. name: 'defaultIssueEvent',
  68. type: 'select',
  69. required: false,
  70. options: [
  71. {value: 'recommended', label: t('Recommended')},
  72. {value: 'latest', label: t('Latest')},
  73. {value: 'oldest', label: t('Oldest')},
  74. ],
  75. label: t('Default Issue Event'),
  76. help: t('Choose what event gets displayed by default'),
  77. getData: transformOptions,
  78. },
  79. ],
  80. },
  81. ];
  82. export default formGroups;