diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-11-19 11:41:06 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2018-11-30 11:20:35 +0100 |
commit | 50c708c1b62796cba971ed6579cb72373261e857 (patch) | |
tree | 0462dcd0c342845ac4a7a1923c0da0c1097a9588 /server/sonar-web/src/main/js/store | |
parent | 0a52c5067d46ce684231b8f61ea9f72d4d89fc22 (diff) | |
download | sonarqube-50c708c1b62796cba971ed6579cb72373261e857.tar.gz sonarqube-50c708c1b62796cba971ed6579cb72373261e857.zip |
Rewrite remaining of the settings page to TS
Diffstat (limited to 'server/sonar-web/src/main/js/store')
-rw-r--r-- | server/sonar-web/src/main/js/store/appState.ts | 30 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/store/globalMessages.ts | 4 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/store/rootReducer.ts | 4 |
3 files changed, 21 insertions, 17 deletions
diff --git a/server/sonar-web/src/main/js/store/appState.ts b/server/sonar-web/src/main/js/store/appState.ts index 19a5e546944..89f31e98e12 100644 --- a/server/sonar-web/src/main/js/store/appState.ts +++ b/server/sonar-web/src/main/js/store/appState.ts @@ -21,21 +21,27 @@ import { ActionType } from './utils/actions'; import { Extension, AppState } from '../app/types'; import { EditionKey } from '../apps/marketplace/utils'; -type Action = - | ActionType<typeof setAppState, 'SET_APP_STATE'> - | ActionType<typeof setAdminPages, 'SET_ADMIN_PAGES'> - | ActionType<typeof requireAuthorization, 'REQUIRE_AUTHORIZATION'>; +export const enum Actions { + SetAppState = 'SET_APP_STATE', + SetAdminPages = 'SET_ADMIN_PAGES', + RequireAuthorization = 'REQUIRE_AUTHORIZATION' +} + +export type Action = + | ActionType<typeof setAppState, Actions.SetAppState> + | ActionType<typeof setAdminPages, Actions.SetAdminPages> + | ActionType<typeof requireAuthorization, Actions.RequireAuthorization>; export function setAppState(appState: AppState) { - return { type: 'SET_APP_STATE', appState }; + return { type: Actions.SetAppState, appState }; } export function setAdminPages(adminPages: Extension[]) { - return { type: 'SET_ADMIN_PAGES', adminPages }; + return { type: Actions.SetAdminPages, adminPages }; } export function requireAuthorization() { - return { type: 'REQUIRE_AUTHORIZATION' }; + return { type: Actions.RequireAuthorization }; } const defaultValue: AppState = { @@ -46,21 +52,19 @@ const defaultValue: AppState = { organizationsEnabled: false, productionDatabase: true, qualifiers: [], + settings: {}, version: '' }; export default function(state: AppState = defaultValue, action: Action): AppState { - if (action.type === 'SET_APP_STATE') { + if (action.type === Actions.SetAppState) { return { ...state, ...action.appState }; } - - if (action.type === 'SET_ADMIN_PAGES') { + if (action.type === Actions.SetAdminPages) { return { ...state, adminPages: action.adminPages }; } - - if (action.type === 'REQUIRE_AUTHORIZATION') { + if (action.type === Actions.RequireAuthorization) { return { ...state, authorizationError: true }; } - return state; } diff --git a/server/sonar-web/src/main/js/store/globalMessages.ts b/server/sonar-web/src/main/js/store/globalMessages.ts index eabb58635a8..b1059021a6d 100644 --- a/server/sonar-web/src/main/js/store/globalMessages.ts +++ b/server/sonar-web/src/main/js/store/globalMessages.ts @@ -41,8 +41,8 @@ export function closeGlobalMessage(id: string) { return { type: 'CLOSE_GLOBAL_MESSAGE', id }; } -export function closeAllGlobalMessages(id: string) { - return { type: 'CLOSE_ALL_GLOBAL_MESSAGES', id }; +export function closeAllGlobalMessages() { + return { type: 'CLOSE_ALL_GLOBAL_MESSAGES' }; } type Action = diff --git a/server/sonar-web/src/main/js/store/rootReducer.ts b/server/sonar-web/src/main/js/store/rootReducer.ts index 3d3bcfacec7..336fe056b6b 100644 --- a/server/sonar-web/src/main/js/store/rootReducer.ts +++ b/server/sonar-web/src/main/js/store/rootReducer.ts @@ -109,9 +109,9 @@ export function getSettingsAppDefaultCategory(state: Store) { export function getSettingsAppSettingsForCategory( state: Store, category: string, - componentKey: string + component?: string ) { - return fromSettingsApp.getSettingsForCategory(state.settingsApp, category, componentKey); + return fromSettingsApp.getSettingsForCategory(state.settingsApp, category, component); } export function getSettingsAppChangedValue(state: Store, key: string) { |