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
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
8e810bc2eb
Коммит
caabfbcdd5
@@ -54,6 +54,16 @@ class PreferenceStoreClass extends EventEmitter {
|
||||
return parseInt(this.preferences.get(key), 10);
|
||||
}
|
||||
|
||||
getObject(category, name, defaultValue = null) {
|
||||
const key = this.getKey(category, name);
|
||||
|
||||
if (!this.preferences.has(key)) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return JSON.parse(this.preferences.get(key));
|
||||
}
|
||||
|
||||
getCategory(category) {
|
||||
const prefix = category + '--';
|
||||
|
||||
@@ -78,6 +88,10 @@ class PreferenceStoreClass extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
deletePreference(preference) {
|
||||
this.preferences.delete(this.getKey(preference.category, preference.name));
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.preferences.clear();
|
||||
}
|
||||
@@ -94,6 +108,18 @@ class PreferenceStoreClass extends EventEmitter {
|
||||
this.removeListener(CHANGE_EVENT, callback);
|
||||
}
|
||||
|
||||
getTheme(teamId) {
|
||||
if (this.preferences.has(this.getKey(Constants.Preferences.CATEGORY_THEME, teamId))) {
|
||||
return this.getObject(Constants.Preferences.CATEGORY_THEME, teamId);
|
||||
}
|
||||
|
||||
if (this.preferences.has(this.getKey(Constants.Preferences.CATEGORY_THEME, ''))) {
|
||||
return this.getObject(Constants.Preferences.CATEGORY_THEME, '');
|
||||
}
|
||||
|
||||
return Constants.THEMES.default;
|
||||
}
|
||||
|
||||
handleEventPayload(payload) {
|
||||
const action = payload.action;
|
||||
|
||||
@@ -108,6 +134,12 @@ class PreferenceStoreClass extends EventEmitter {
|
||||
this.setPreferencesFromServer(action.preferences);
|
||||
this.emitChange();
|
||||
break;
|
||||
case ActionTypes.DELETED_PREFERENCES:
|
||||
for (const preference of action.preferences) {
|
||||
this.deletePreference(preference);
|
||||
}
|
||||
this.emitChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user