preferences.tsx 647 B

123456789101112131415161718192021222324
  1. import Cookies from 'js-cookie';
  2. import PreferenceStore from 'sentry/stores/preferencesStore';
  3. const SIDEBAR_COOKIE_KEY = 'sidebar_collapsed';
  4. const COOKIE_ENABLED = '1';
  5. const COOKIE_DISABLED = '0';
  6. export function hideSidebar() {
  7. PreferenceStore.hideSidebar();
  8. Cookies.set(SIDEBAR_COOKIE_KEY, COOKIE_ENABLED);
  9. }
  10. export function showSidebar() {
  11. PreferenceStore.showSidebar();
  12. Cookies.set(SIDEBAR_COOKIE_KEY, COOKIE_DISABLED);
  13. }
  14. export function loadPreferencesState() {
  15. // Set initial "collapsed" state to true or false
  16. PreferenceStore.loadInitialState({
  17. collapsed: Cookies.get(SIDEBAR_COOKIE_KEY) === COOKIE_ENABLED,
  18. });
  19. }