From caabfbcdd56bdced7c5c1d38e00f488adffe7c60 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Thu, 14 Jul 2016 10:08:36 -0400
Subject: PLT-2992 Added the ability to use different themes for each team
 (#3411)

* Cleaned up user_settings_theme.jsx and import_theme_modal.jsx

* Made ImportThemeModal use a callback to return the theme to the user settings modal instead of saving it directly

* Moved user theme from model to preferences

* Added serverside API to delete preferences TODO update package with client stuff

* Changed constants.jsx so that Preferences and ActionTypes can be imported on their own

* Updated ThemeProps migration code to properly rename solarized code themes

* Fixed warnings thrown by AppDispatcher

* Added clientside UI to support team-specific themes

* Removed debugging code from test

* Fixed setting a user's theme when they haven't set their theme before
---
 webapp/utils/constants.jsx | 235 +++++++++++++++++++++++----------------------
 1 file changed, 121 insertions(+), 114 deletions(-)

(limited to 'webapp/utils/constants.jsx')

diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index df9cb3ba4..d780efe30 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -33,100 +33,125 @@ import mattermostDarkThemeImage from 'images/themes/mattermost_dark.png';
 import mattermostThemeImage from 'images/themes/mattermost.png';
 import windows10ThemeImage from 'images/themes/windows_dark.png';
 
-export default {
-    ActionTypes: keyMirror({
-        RECEIVED_ERROR: null,
-
-        CLICK_CHANNEL: null,
-        CREATE_CHANNEL: null,
-        LEAVE_CHANNEL: null,
-        CREATE_POST: null,
-        CREATE_COMMENT: null,
-        POST_DELETED: null,
-        REMOVE_POST: null,
-
-        RECEIVED_CHANNELS: null,
-        RECEIVED_CHANNEL: null,
-        RECEIVED_MORE_CHANNELS: null,
-        RECEIVED_CHANNEL_EXTRA_INFO: null,
-
-        FOCUS_POST: null,
-        RECEIVED_POSTS: null,
-        RECEIVED_FOCUSED_POST: null,
-        RECEIVED_POST: null,
-        RECEIVED_EDIT_POST: null,
-        RECEIVED_SEARCH: null,
-        RECEIVED_SEARCH_TERM: null,
-        RECEIVED_POST_SELECTED: null,
-        RECEIVED_MENTION_DATA: null,
-        RECEIVED_ADD_MENTION: null,
-
-        RECEIVED_PROFILES_FOR_DM_LIST: null,
-        RECEIVED_PROFILES: null,
-        RECEIVED_DIRECT_PROFILES: null,
-        RECEIVED_ME: null,
-        RECEIVED_SESSIONS: null,
-        RECEIVED_AUDITS: null,
-        RECEIVED_TEAMS: null,
-        RECEIVED_STATUSES: null,
-        RECEIVED_PREFERENCE: null,
-        RECEIVED_PREFERENCES: null,
-        RECEIVED_FILE_INFO: null,
-        RECEIVED_ANALYTICS: null,
-
-        RECEIVED_INCOMING_WEBHOOKS: null,
-        RECEIVED_INCOMING_WEBHOOK: null,
-        REMOVED_INCOMING_WEBHOOK: null,
-        RECEIVED_OUTGOING_WEBHOOKS: null,
-        RECEIVED_OUTGOING_WEBHOOK: null,
-        UPDATED_OUTGOING_WEBHOOK: null,
-        REMOVED_OUTGOING_WEBHOOK: null,
-        RECEIVED_COMMANDS: null,
-        RECEIVED_COMMAND: null,
-        UPDATED_COMMAND: null,
-        REMOVED_COMMAND: null,
-
-        RECEIVED_CUSTOM_EMOJIS: null,
-        RECEIVED_CUSTOM_EMOJI: null,
-        UPDATED_CUSTOM_EMOJI: null,
-        REMOVED_CUSTOM_EMOJI: null,
-
-        RECEIVED_MSG: null,
-
-        RECEIVED_MY_TEAM: null,
-        CREATED_TEAM: null,
-
-        RECEIVED_CONFIG: null,
-        RECEIVED_LOGS: null,
-        RECEIVED_SERVER_AUDITS: null,
-        RECEIVED_SERVER_COMPLIANCE_REPORTS: null,
-        RECEIVED_ALL_TEAMS: null,
-        RECEIVED_ALL_TEAM_LISTINGS: null,
-        RECEIVED_TEAM_MEMBERS: null,
-        RECEIVED_MEMBERS_FOR_TEAM: null,
-
-        RECEIVED_LOCALE: null,
-
-        SHOW_SEARCH: null,
-
-        USER_TYPING: null,
-
-        TOGGLE_IMPORT_THEME_MODAL: null,
-        TOGGLE_INVITE_MEMBER_MODAL: null,
-        TOGGLE_LEAVE_TEAM_MODAL: null,
-        TOGGLE_DELETE_POST_MODAL: null,
-        TOGGLE_GET_POST_LINK_MODAL: null,
-        TOGGLE_GET_TEAM_INVITE_LINK_MODAL: null,
-        TOGGLE_REGISTER_APP_MODAL: null,
-        TOGGLE_GET_PUBLIC_LINK_MODAL: null,
-
-        SUGGESTION_PRETEXT_CHANGED: null,
-        SUGGESTION_RECEIVED_SUGGESTIONS: null,
-        SUGGESTION_CLEAR_SUGGESTIONS: null,
-        SUGGESTION_COMPLETE_WORD: null,
-        SUGGESTION_SELECT_NEXT: null,
-        SUGGESTION_SELECT_PREVIOUS: null
-    }),
+export const Preferences = {
+    CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show',
+    CATEGORY_DISPLAY_SETTINGS: 'display_settings',
+    DISPLAY_PREFER_NICKNAME: 'nickname_full_name',
+    DISPLAY_PREFER_FULL_NAME: 'full_name',
+    CATEGORY_ADVANCED_SETTINGS: 'advanced_settings',
+    TUTORIAL_STEP: 'tutorial_step',
+    CHANNEL_DISPLAY_MODE: 'channel_display_mode',
+    CHANNEL_DISPLAY_MODE_CENTERED: 'centered',
+    CHANNEL_DISPLAY_MODE_FULL_SCREEN: 'full',
+    CHANNEL_DISPLAY_MODE_DEFAULT: 'centered',
+    MESSAGE_DISPLAY: 'message_display',
+    MESSAGE_DISPLAY_CLEAN: 'clean',
+    MESSAGE_DISPLAY_COMPACT: 'compact',
+    MESSAGE_DISPLAY_DEFAULT: 'clean',
+    COLLAPSE_DISPLAY: 'collapse_previews',
+    COLLAPSE_DISPLAY_DEFAULT: 'false',
+    USE_MILITARY_TIME: 'use_military_time',
+    CATEGORY_THEME: 'theme'
+};
+
+export const ActionTypes = keyMirror({
+    RECEIVED_ERROR: null,
+
+    CLICK_CHANNEL: null,
+    CREATE_CHANNEL: null,
+    LEAVE_CHANNEL: null,
+    CREATE_POST: null,
+    CREATE_COMMENT: null,
+    POST_DELETED: null,
+    REMOVE_POST: null,
+
+    RECEIVED_CHANNELS: null,
+    RECEIVED_CHANNEL: null,
+    RECEIVED_MORE_CHANNELS: null,
+    RECEIVED_CHANNEL_EXTRA_INFO: null,
+
+    FOCUS_POST: null,
+    RECEIVED_POSTS: null,
+    RECEIVED_FOCUSED_POST: null,
+    RECEIVED_POST: null,
+    RECEIVED_EDIT_POST: null,
+    RECEIVED_SEARCH: null,
+    RECEIVED_SEARCH_TERM: null,
+    RECEIVED_POST_SELECTED: null,
+    RECEIVED_MENTION_DATA: null,
+    RECEIVED_ADD_MENTION: null,
+
+    RECEIVED_PROFILES_FOR_DM_LIST: null,
+    RECEIVED_PROFILES: null,
+    RECEIVED_DIRECT_PROFILES: null,
+    RECEIVED_ME: null,
+    RECEIVED_SESSIONS: null,
+    RECEIVED_AUDITS: null,
+    RECEIVED_TEAMS: null,
+    RECEIVED_STATUSES: null,
+    RECEIVED_PREFERENCE: null,
+    RECEIVED_PREFERENCES: null,
+    DELETED_PREFERENCES: null,
+    RECEIVED_FILE_INFO: null,
+    RECEIVED_ANALYTICS: null,
+
+    RECEIVED_INCOMING_WEBHOOKS: null,
+    RECEIVED_INCOMING_WEBHOOK: null,
+    REMOVED_INCOMING_WEBHOOK: null,
+    RECEIVED_OUTGOING_WEBHOOKS: null,
+    RECEIVED_OUTGOING_WEBHOOK: null,
+    UPDATED_OUTGOING_WEBHOOK: null,
+    REMOVED_OUTGOING_WEBHOOK: null,
+    RECEIVED_COMMANDS: null,
+    RECEIVED_COMMAND: null,
+    UPDATED_COMMAND: null,
+    REMOVED_COMMAND: null,
+
+    RECEIVED_CUSTOM_EMOJIS: null,
+    RECEIVED_CUSTOM_EMOJI: null,
+    UPDATED_CUSTOM_EMOJI: null,
+    REMOVED_CUSTOM_EMOJI: null,
+
+    RECEIVED_MSG: null,
+
+    RECEIVED_MY_TEAM: null,
+    CREATED_TEAM: null,
+
+    RECEIVED_CONFIG: null,
+    RECEIVED_LOGS: null,
+    RECEIVED_SERVER_AUDITS: null,
+    RECEIVED_SERVER_COMPLIANCE_REPORTS: null,
+    RECEIVED_ALL_TEAMS: null,
+    RECEIVED_ALL_TEAM_LISTINGS: null,
+    RECEIVED_TEAM_MEMBERS: null,
+    RECEIVED_MEMBERS_FOR_TEAM: null,
+
+    RECEIVED_LOCALE: null,
+
+    SHOW_SEARCH: null,
+
+    USER_TYPING: null,
+
+    TOGGLE_IMPORT_THEME_MODAL: null,
+    TOGGLE_INVITE_MEMBER_MODAL: null,
+    TOGGLE_LEAVE_TEAM_MODAL: null,
+    TOGGLE_DELETE_POST_MODAL: null,
+    TOGGLE_GET_POST_LINK_MODAL: null,
+    TOGGLE_GET_TEAM_INVITE_LINK_MODAL: null,
+    TOGGLE_REGISTER_APP_MODAL: null,
+    TOGGLE_GET_PUBLIC_LINK_MODAL: null,
+
+    SUGGESTION_PRETEXT_CHANGED: null,
+    SUGGESTION_RECEIVED_SUGGESTIONS: null,
+    SUGGESTION_CLEAR_SUGGESTIONS: null,
+    SUGGESTION_COMPLETE_WORD: null,
+    SUGGESTION_SELECT_NEXT: null,
+    SUGGESTION_SELECT_PREVIOUS: null
+});
+
+export const Constants = {
+    Preferences,
+    ActionTypes,
 
     PayloadSources: keyMirror({
         SERVER_ACTION: null,
@@ -174,7 +199,6 @@ export default {
         FULLNAME: 'fullname',
         NICKNAME: 'nickname',
         EMAIL: 'email',
-        THEME: 'theme',
         LANGUAGE: 'language'
     },
 
@@ -551,25 +575,6 @@ export default {
         Ubuntu: 'font--ubuntu'
     },
     DEFAULT_FONT: 'Open Sans',
-    Preferences: {
-        CATEGORY_DIRECT_CHANNEL_SHOW: 'direct_channel_show',
-        CATEGORY_DISPLAY_SETTINGS: 'display_settings',
-        DISPLAY_PREFER_NICKNAME: 'nickname_full_name',
-        DISPLAY_PREFER_FULL_NAME: 'full_name',
-        CATEGORY_ADVANCED_SETTINGS: 'advanced_settings',
-        TUTORIAL_STEP: 'tutorial_step',
-        CHANNEL_DISPLAY_MODE: 'channel_display_mode',
-        CHANNEL_DISPLAY_MODE_CENTERED: 'centered',
-        CHANNEL_DISPLAY_MODE_FULL_SCREEN: 'full',
-        CHANNEL_DISPLAY_MODE_DEFAULT: 'full',
-        MESSAGE_DISPLAY: 'message_display',
-        MESSAGE_DISPLAY_CLEAN: 'clean',
-        MESSAGE_DISPLAY_COMPACT: 'compact',
-        MESSAGE_DISPLAY_DEFAULT: 'clean',
-        COLLAPSE_DISPLAY: 'collapse_previews',
-        COLLAPSE_DISPLAY_DEFAULT: 'false',
-        USE_MILITARY_TIME: 'use_military_time'
-    },
     TutorialSteps: {
         INTRO_SCREENS: 0,
         POST_POPOVER: 1,
@@ -779,3 +784,5 @@ export default {
     PERMISSIONS_TEAM_ADMIN: 'team_admin',
     PERMISSIONS_SYSTEM_ADMIN: 'system_admin'
 };
+
+export default Constants;
-- 
cgit v1.2.3-1-g7c22

