Skip to content

Commit 0896481

Browse files
committed
migrate preferences action types to co-located .types file
1 parent 24f63d5 commit 0896481

File tree

3 files changed

+135
-116
lines changed

3 files changed

+135
-116
lines changed

client/modules/IDE/actions/preferences.ts

Lines changed: 18 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,121 +2,24 @@ import i18next from 'i18next';
22
import { UpdatePreferencesRequestBody } from '../../../../common/types';
33
import { apiClient } from '../../../utils/apiClient';
44
import * as ActionTypes from '../../../constants';
5-
import type { PreferencesState } from '../reducers/preferences';
6-
import type { RootState } from '../../../reducers';
7-
8-
// Value Definitions:
9-
export type SetPreferencesTabValue = PreferencesState['tabIndex'];
10-
export type SetFontSizeValue = PreferencesState['fontSize'];
11-
export type SetLineNumbersValue = PreferencesState['lineNumbers'];
12-
export type SetAutocloseBracketsQuotesValue = PreferencesState['autocloseBracketsQuotes'];
13-
export type SetAutocompleteHinterValue = PreferencesState['autocompleteHinter'];
14-
export type SetAutosaveValue = PreferencesState['autosave'];
15-
export type SetLinewrapValue = PreferencesState['linewrap'];
16-
export type SetLintWarningValue = PreferencesState['lintWarning'];
17-
export type SetTextOutputValue = PreferencesState['textOutput'];
18-
export type SetGridOutputValue = PreferencesState['gridOutput'];
19-
export type SetThemeValue = PreferencesState['theme'];
20-
export type SetAutorefreshValue = PreferencesState['autorefresh'];
21-
export type SetLanguageValue = PreferencesState['language'];
22-
export type SetAllAccessibleOutputValue =
23-
| SetTextOutputValue
24-
| SetGridOutputValue;
25-
26-
// Action Definitions:
27-
export type OpenPreferencesAction = {
28-
type: typeof ActionTypes.OPEN_PREFERENCES;
29-
};
30-
export type SetPreferencesAction = {
31-
type: typeof ActionTypes.SET_PREFERENCES;
32-
preferences: PreferencesState;
33-
};
34-
export type SetErrorAction = {
35-
type: typeof ActionTypes.ERROR;
36-
error: unknown;
37-
};
38-
39-
export type SetPreferencesTabAction = {
40-
type: typeof ActionTypes.SET_PREFERENCES_TAB;
41-
value: SetPreferencesTabValue;
42-
};
43-
export type SetFontSizeAction = {
44-
type: typeof ActionTypes.SET_FONT_SIZE;
45-
value: SetFontSizeValue;
46-
};
47-
export type SetLineNumbersAction = {
48-
type: typeof ActionTypes.SET_LINE_NUMBERS;
49-
value: SetLineNumbersValue;
50-
};
51-
export type SetAutocloseBracketsQuotesAction = {
52-
type: typeof ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES;
53-
value: SetAutocloseBracketsQuotesValue;
54-
};
55-
export type SetAutocompleteHinterAction = {
56-
type: typeof ActionTypes.SET_AUTOCOMPLETE_HINTER;
57-
value: SetAutocompleteHinterValue;
58-
};
59-
export type SetAutosaveAction = {
60-
type: typeof ActionTypes.SET_AUTOSAVE;
61-
value: SetAutosaveValue;
62-
};
63-
export type SetLinewrapAction = {
64-
type: typeof ActionTypes.SET_LINEWRAP;
65-
value: SetLinewrapValue;
66-
};
67-
export type SetLintWarningAction = {
68-
type: typeof ActionTypes.SET_LINT_WARNING;
69-
value: SetLintWarningValue;
70-
};
71-
export type SetTextOutputAction = {
72-
type: typeof ActionTypes.SET_TEXT_OUTPUT;
73-
value: SetTextOutputValue;
74-
};
75-
export type SetGridOutputAction = {
76-
type: typeof ActionTypes.SET_GRID_OUTPUT;
77-
value: SetGridOutputValue;
78-
};
79-
export type SetThemeAction = {
80-
type: typeof ActionTypes.SET_THEME;
81-
value: SetThemeValue;
82-
};
83-
export type SetAutorefreshAction = {
84-
type: typeof ActionTypes.SET_AUTOREFRESH;
85-
value: SetAutorefreshValue;
86-
};
87-
export type SetLanguageAction = {
88-
type: typeof ActionTypes.SET_LANGUAGE;
89-
language: SetLanguageValue;
90-
};
91-
92-
export type PreferencesAction =
93-
| OpenPreferencesAction
94-
| SetPreferencesAction
95-
| SetErrorAction
96-
| SetPreferencesTabAction
97-
| SetFontSizeAction
98-
| SetLineNumbersAction
99-
| SetAutocloseBracketsQuotesAction
100-
| SetAutocompleteHinterAction
101-
| SetAutosaveAction
102-
| SetLinewrapAction
103-
| SetLintWarningAction
104-
| SetTextOutputAction
105-
| SetGridOutputAction
106-
| SetThemeAction
107-
| SetAutorefreshAction
108-
| SetLanguageAction;
109-
110-
export type UpdatePreferencesDispatch = (
111-
action: PreferencesAction | PreferencesThunk
112-
) => void;
113-
114-
export type PreferencesThunk = (
115-
dispatch: UpdatePreferencesDispatch,
116-
getState: GetRootState
117-
) => void;
118-
119-
export type GetRootState = () => RootState;
5+
import type {
6+
UpdatePreferencesDispatch,
7+
SetPreferencesTabValue,
8+
SetFontSizeValue,
9+
GetRootState,
10+
SetLineNumbersValue,
11+
SetAutocloseBracketsQuotesValue,
12+
SetAutocompleteHinterValue,
13+
SetAutosaveValue,
14+
SetLinewrapValue,
15+
SetLintWarningValue,
16+
SetTextOutputValue,
17+
SetAllAccessibleOutputValue,
18+
SetAutorefreshValue,
19+
SetGridOutputValue,
20+
SetLanguageValue,
21+
SetThemeValue
22+
} from './preferences.types';
12023

12124
function updatePreferences(
12225
formParams: UpdatePreferencesRequestBody,
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import * as ActionTypes from '../../../constants';
2+
import type { PreferencesState } from '../reducers/preferences';
3+
import type { RootState } from '../../../reducers';
4+
5+
// Value Definitions:
6+
export type SetPreferencesTabValue = PreferencesState['tabIndex'];
7+
export type SetFontSizeValue = PreferencesState['fontSize'];
8+
export type SetLineNumbersValue = PreferencesState['lineNumbers'];
9+
export type SetAutocloseBracketsQuotesValue = PreferencesState['autocloseBracketsQuotes'];
10+
export type SetAutocompleteHinterValue = PreferencesState['autocompleteHinter'];
11+
export type SetAutosaveValue = PreferencesState['autosave'];
12+
export type SetLinewrapValue = PreferencesState['linewrap'];
13+
export type SetLintWarningValue = PreferencesState['lintWarning'];
14+
export type SetTextOutputValue = PreferencesState['textOutput'];
15+
export type SetGridOutputValue = PreferencesState['gridOutput'];
16+
export type SetThemeValue = PreferencesState['theme'];
17+
export type SetAutorefreshValue = PreferencesState['autorefresh'];
18+
export type SetLanguageValue = PreferencesState['language'];
19+
export type SetAllAccessibleOutputValue =
20+
| SetTextOutputValue
21+
| SetGridOutputValue;
22+
23+
// Action Definitions:
24+
export type OpenPreferencesAction = {
25+
type: typeof ActionTypes.OPEN_PREFERENCES;
26+
};
27+
export type SetPreferencesAction = {
28+
type: typeof ActionTypes.SET_PREFERENCES;
29+
preferences: PreferencesState;
30+
};
31+
export type SetErrorAction = {
32+
type: typeof ActionTypes.ERROR;
33+
error: unknown;
34+
};
35+
36+
export type SetPreferencesTabAction = {
37+
type: typeof ActionTypes.SET_PREFERENCES_TAB;
38+
value: SetPreferencesTabValue;
39+
};
40+
export type SetFontSizeAction = {
41+
type: typeof ActionTypes.SET_FONT_SIZE;
42+
value: SetFontSizeValue;
43+
};
44+
export type SetLineNumbersAction = {
45+
type: typeof ActionTypes.SET_LINE_NUMBERS;
46+
value: SetLineNumbersValue;
47+
};
48+
export type SetAutocloseBracketsQuotesAction = {
49+
type: typeof ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES;
50+
value: SetAutocloseBracketsQuotesValue;
51+
};
52+
export type SetAutocompleteHinterAction = {
53+
type: typeof ActionTypes.SET_AUTOCOMPLETE_HINTER;
54+
value: SetAutocompleteHinterValue;
55+
};
56+
export type SetAutosaveAction = {
57+
type: typeof ActionTypes.SET_AUTOSAVE;
58+
value: SetAutosaveValue;
59+
};
60+
export type SetLinewrapAction = {
61+
type: typeof ActionTypes.SET_LINEWRAP;
62+
value: SetLinewrapValue;
63+
};
64+
export type SetLintWarningAction = {
65+
type: typeof ActionTypes.SET_LINT_WARNING;
66+
value: SetLintWarningValue;
67+
};
68+
export type SetTextOutputAction = {
69+
type: typeof ActionTypes.SET_TEXT_OUTPUT;
70+
value: SetTextOutputValue;
71+
};
72+
export type SetGridOutputAction = {
73+
type: typeof ActionTypes.SET_GRID_OUTPUT;
74+
value: SetGridOutputValue;
75+
};
76+
export type SetThemeAction = {
77+
type: typeof ActionTypes.SET_THEME;
78+
value: SetThemeValue;
79+
};
80+
export type SetAutorefreshAction = {
81+
type: typeof ActionTypes.SET_AUTOREFRESH;
82+
value: SetAutorefreshValue;
83+
};
84+
export type SetLanguageAction = {
85+
type: typeof ActionTypes.SET_LANGUAGE;
86+
language: SetLanguageValue;
87+
};
88+
89+
export type PreferencesAction =
90+
| OpenPreferencesAction
91+
| SetPreferencesAction
92+
| SetErrorAction
93+
| SetPreferencesTabAction
94+
| SetFontSizeAction
95+
| SetLineNumbersAction
96+
| SetAutocloseBracketsQuotesAction
97+
| SetAutocompleteHinterAction
98+
| SetAutosaveAction
99+
| SetLinewrapAction
100+
| SetLintWarningAction
101+
| SetTextOutputAction
102+
| SetGridOutputAction
103+
| SetThemeAction
104+
| SetAutorefreshAction
105+
| SetLanguageAction;
106+
107+
export type UpdatePreferencesDispatch = (
108+
action: PreferencesAction | PreferencesThunk
109+
) => void;
110+
111+
export type PreferencesThunk = (
112+
dispatch: UpdatePreferencesDispatch,
113+
getState: GetRootState
114+
) => void;
115+
116+
export type GetRootState = () => RootState;

client/modules/IDE/reducers/preferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from '../../../../common/types';
55
import * as ActionTypes from '../../../constants';
66
import i18n from '../../../i18n';
7-
import type { PreferencesAction } from '../actions/preferences';
7+
import type { PreferencesAction } from '../actions/preferences.types';
88

99
export interface PreferencesState
1010
extends Omit<Preferences, 'indentationAmount' | 'isTabIndent'> {

0 commit comments

Comments
 (0)