|
|
@@ -1,16 +1,20 @@
|
|
|
import { ThunkAction } from 'redux-thunk';
|
|
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
|
-import { StoreState, Team, TeamGroup, TeamMember } from 'app/types';
|
|
|
+import { StoreState, Team, TeamGroup, TeamMember, OrganizationPreferences } from 'app/types';
|
|
|
import { updateNavIndex, UpdateNavIndexAction } from 'app/core/actions';
|
|
|
import { buildNavModel } from './navModel';
|
|
|
|
|
|
export enum ActionTypes {
|
|
|
LoadTeams = 'LOAD_TEAMS',
|
|
|
LoadTeam = 'LOAD_TEAM',
|
|
|
+ LoadTeamPreferences = 'LOAD_TEAM_PREFERENCES',
|
|
|
SetSearchQuery = 'SET_TEAM_SEARCH_QUERY',
|
|
|
SetSearchMemberQuery = 'SET_TEAM_MEMBER_SEARCH_QUERY',
|
|
|
LoadTeamMembers = 'TEAM_MEMBERS_LOADED',
|
|
|
LoadTeamGroups = 'TEAM_GROUPS_LOADED',
|
|
|
+ SetTeamTheme = 'SET_TEAM_THEME',
|
|
|
+ SetTeamHomeDashboard = 'SET_TEAM_HOME_DASHBOARD',
|
|
|
+ SetTeamTimezone = 'SET_TEAM_TIMEZONE',
|
|
|
}
|
|
|
|
|
|
export interface LoadTeamsAction {
|
|
|
@@ -23,6 +27,11 @@ export interface LoadTeamAction {
|
|
|
payload: Team;
|
|
|
}
|
|
|
|
|
|
+export interface LoadTeamPreferencesAction {
|
|
|
+ type: ActionTypes.LoadTeamPreferences;
|
|
|
+ payload: OrganizationPreferences;
|
|
|
+}
|
|
|
+
|
|
|
export interface LoadTeamMembersAction {
|
|
|
type: ActionTypes.LoadTeamMembers;
|
|
|
payload: TeamMember[];
|
|
|
@@ -43,13 +52,32 @@ export interface SetSearchMemberQueryAction {
|
|
|
payload: string;
|
|
|
}
|
|
|
|
|
|
+export interface SetTeamThemeAction {
|
|
|
+ type: ActionTypes.SetTeamTheme;
|
|
|
+ payload: string;
|
|
|
+}
|
|
|
+
|
|
|
+export interface SetTeamHomeDashboardAction {
|
|
|
+ type: ActionTypes.SetTeamHomeDashboard;
|
|
|
+ payload: number;
|
|
|
+}
|
|
|
+
|
|
|
+export interface SetTeamTimezoneAction {
|
|
|
+ type: ActionTypes.SetTeamTimezone;
|
|
|
+ payload: string;
|
|
|
+}
|
|
|
+
|
|
|
export type Action =
|
|
|
| LoadTeamsAction
|
|
|
| SetSearchQueryAction
|
|
|
| LoadTeamAction
|
|
|
+ | LoadTeamPreferencesAction
|
|
|
| LoadTeamMembersAction
|
|
|
| SetSearchMemberQueryAction
|
|
|
- | LoadTeamGroupsAction;
|
|
|
+ | LoadTeamGroupsAction
|
|
|
+ | SetTeamThemeAction
|
|
|
+ | SetTeamHomeDashboardAction
|
|
|
+ | SetTeamTimezoneAction;
|
|
|
|
|
|
type ThunkResult<R> = ThunkAction<R, StoreState, undefined, Action | UpdateNavIndexAction>;
|
|
|
|
|
|
@@ -73,6 +101,11 @@ const teamGroupsLoaded = (teamGroups: TeamGroup[]): LoadTeamGroupsAction => ({
|
|
|
payload: teamGroups,
|
|
|
});
|
|
|
|
|
|
+const teamPreferencesLoaded = (preferences: OrganizationPreferences): LoadTeamPreferencesAction => ({
|
|
|
+ type: ActionTypes.LoadTeamPreferences,
|
|
|
+ payload: preferences,
|
|
|
+});
|
|
|
+
|
|
|
export const setSearchMemberQuery = (searchQuery: string): SetSearchMemberQueryAction => ({
|
|
|
type: ActionTypes.SetSearchMemberQuery,
|
|
|
payload: searchQuery,
|
|
|
@@ -83,6 +116,21 @@ export const setSearchQuery = (searchQuery: string): SetSearchQueryAction => ({
|
|
|
payload: searchQuery,
|
|
|
});
|
|
|
|
|
|
+export const setTeamTheme = (theme: string) => ({
|
|
|
+ type: ActionTypes.SetTeamTheme,
|
|
|
+ payload: theme,
|
|
|
+});
|
|
|
+
|
|
|
+export const setTeamHomeDashboard = (id: number) => ({
|
|
|
+ type: ActionTypes.SetTeamHomeDashboard,
|
|
|
+ payload: id,
|
|
|
+});
|
|
|
+
|
|
|
+export const setTeamTimezone = (timezone: string) => ({
|
|
|
+ type: ActionTypes.SetTeamTimezone,
|
|
|
+ payload: timezone,
|
|
|
+});
|
|
|
+
|
|
|
export function loadTeams(): ThunkResult<void> {
|
|
|
return async dispatch => {
|
|
|
const response = await getBackendSrv().get('/api/teams/search', { perpage: 1000, page: 1 });
|
|
|
@@ -160,3 +208,21 @@ export function deleteTeam(id: number): ThunkResult<void> {
|
|
|
dispatch(loadTeams());
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+export function loadTeamPreferences(): ThunkResult<void> {
|
|
|
+ return async (dispatch, getStore) => {
|
|
|
+ const team = getStore().team.team;
|
|
|
+ const response = await getBackendSrv().get(`/api/teams/${team.id}/preferences`);
|
|
|
+ dispatch(teamPreferencesLoaded(response));
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+export function updateTeamPreferences() {
|
|
|
+ return async (dispatch, getStore) => {
|
|
|
+ const team = getStore().team.team;
|
|
|
+ const preferences = getStore().team.preferences;
|
|
|
+
|
|
|
+ await getBackendSrv().put(`/api/teams/${team.id}/preferences`, preferences);
|
|
|
+ window.location.reload();
|
|
|
+ };
|
|
|
+}
|