aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/store/rootReducer.ts
blob: 962a9d7edd9438fa3dbeb96bbc1c6ef5c92bb24c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * SonarQube
 * Copyright (C) 2009-2021 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
import { combineReducers } from 'redux';
import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReducer';
import { BranchLike } from '../types/branch-like';
import appState from './appState';
import branches, * as fromBranches from './branches';
import globalMessages, * as fromGlobalMessages from './globalMessages';
import languages, * as fromLanguages from './languages';
import metrics, * as fromMetrics from './metrics';
import users, * as fromUsers from './users';

export type Store = {
  appState: T.AppState;
  branches: fromBranches.State;
  globalMessages: fromGlobalMessages.State;
  languages: T.Languages;
  metrics: fromMetrics.State;
  users: fromUsers.State;

  // apps
  settingsApp: any;
};

export default combineReducers<Store>({
  appState,
  branches,
  globalMessages,
  languages,
  metrics,
  users,

  // apps
  settingsApp
});

export function getAppState(state: Store) {
  return state.appState;
}

export function getGlobalMessages(state: Store) {
  return fromGlobalMessages.getGlobalMessages(state.globalMessages);
}

export function getLanguages(state: Store) {
  return fromLanguages.getLanguages(state.languages);
}

export function getCurrentUserSetting(state: Store, key: T.CurrentUserSettingNames) {
  return fromUsers.getCurrentUserSetting(state.users, key);
}

export function getCurrentUser(state: Store) {
  return fromUsers.getCurrentUser(state.users);
}

export function getMetrics(state: Store) {
  return fromMetrics.getMetrics(state.metrics);
}

export function getMetricsKey(state: Store) {
  return fromMetrics.getMetricsKey(state.metrics);
}

export function getMetricByKey(state: Store, key: string) {
  return fromMetrics.getMetricByKey(state.metrics, key);
}

export function getGlobalSettingValue(state: Store, key: string) {
  return fromSettingsApp.getValue(state.settingsApp, key);
}

export function getSettingsAppDefinition(state: Store, key: string) {
  return fromSettingsApp.getDefinition(state.settingsApp, key);
}

export function getSettingsAppAllCategories(state: Store) {
  return fromSettingsApp.getAllCategories(state.settingsApp);
}

export function getSettingsAppDefaultCategory(state: Store) {
  return fromSettingsApp.getDefaultCategory(state.settingsApp);
}

export function getSettingsAppSettingsForCategory(
  state: Store,
  category: string,
  component?: string
) {
  return fromSettingsApp.getSettingsForCategory(state.settingsApp, category, component);
}

export function getSettingsAppChangedValue(state: Store, key: string) {
  return fromSettingsApp.getChangedValue(state.settingsApp, key);
}

export function isSettingsAppLoading(state: Store, key: string) {
  return fromSettingsApp.isLoading(state.settingsApp, key);
}

export function getSettingsAppValidationMessage(state: Store, key: string) {
  return fromSettingsApp.getValidationMessage(state.settingsApp, key);
}

export function getBranchStatusByBranchLike(
  state: Store,
  component: string,
  branchLike: BranchLike
) {
  return fromBranches.getBranchStatusByBranchLike(state.branches, component, branchLike);
}