Skip to content

Commit 73a27f8

Browse files
committed
[#941] Add ' Autoclose brackets, quotes ' option ( with default value set to off ) in the General Settings tab of Preferences
1 parent 835ec3c commit 73a27f8

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-2
lines changed

client/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const SET_PREFERENCES = 'SET_PREFERENCES';
7474
export const SET_TEXT_OUTPUT = 'SET_TEXT_OUTPUT';
7575
export const SET_GRID_OUTPUT = 'SET_GRID_OUTPUT';
7676
export const SET_SOUND_OUTPUT = 'SET_SOUND_OUTPUT';
77+
export const SET_AUTOCLOSE_BRACKETS_QUOTES = 'SET_AUTOCLOSE_BRACKETS_QUOTES';
7778

7879
export const OPEN_PROJECT_OPTIONS = 'OPEN_PROJECT_OPTIONS';
7980
export const CLOSE_PROJECT_OPTIONS = 'CLOSE_PROJECT_OPTIONS';

client/modules/IDE/actions/preferences.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ export function setLineNumbers(value) {
5151
};
5252
}
5353

54+
export function setAutocloseBracketsQuotes(value) {
55+
return (dispatch, getState) => {
56+
dispatch({
57+
type: ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES,
58+
value
59+
});
60+
const state = getState();
61+
if (state.user.authenticated) {
62+
const formParams = {
63+
preferences: {
64+
autocloseBracketsQuotes: value
65+
}
66+
};
67+
updatePreferences(formParams, dispatch);
68+
}
69+
};
70+
}
71+
5472
export function setAutosave(value) {
5573
return (dispatch, getState) => {
5674
dispatch({

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,33 @@ class Preferences extends React.Component {
202202
<label htmlFor="autosave-off" className="preference__option">{this.props.t('Preferences.Off')}</label>
203203
</div>
204204
</div>
205+
<div className="preference">
206+
<h4 className="preference__title">{this.props.t('Preferences.AutocloseBracketsQuotes')}</h4>
207+
<div className="preference__options">
208+
<input
209+
type="radio"
210+
onChange={() => this.props.setAutocloseBracketsQuotes(true)}
211+
aria-label={this.props.t('Preferences.AutocloseBracketsQuotesOnARIA')}
212+
name="autoclosebracketsquotes"
213+
id="autoclosebracketsquotes-on"
214+
className="preference__radio-button"
215+
value="On"
216+
checked={this.props.autocloseBracketsQuotes}
217+
/>
218+
<label htmlFor="autoclosebracketsquotes-on" className="preference__option">{this.props.t('Preferences.On')}</label>
219+
<input
220+
type="radio"
221+
onChange={() => this.props.setAutocloseBracketsQuotes(false)}
222+
aria-label={this.props.t('Preferences.AutocloseBracketsQuotesOffARIA')}
223+
name="autoclosebracketsquotes"
224+
id="autoclosebracketsquotes-off"
225+
className="preference__radio-button"
226+
value="Off"
227+
checked={!this.props.autocloseBracketsQuotes}
228+
/>
229+
<label htmlFor="autoclosebracketsquotes-off" className="preference__option">{this.props.t('Preferences.Off')}</label>
230+
</div>
231+
</div>
205232
<div className="preference">
206233
<h4 className="preference__title">{this.props.t('Preferences.WordWrap')}</h4>
207234
<div className="preference__options">
@@ -361,6 +388,8 @@ Preferences.propTypes = {
361388
setLintWarning: PropTypes.func.isRequired,
362389
theme: PropTypes.string.isRequired,
363390
setTheme: PropTypes.func.isRequired,
391+
autocloseBracketsQuotes: PropTypes.bool.isRequired,
392+
setAutocloseBracketsQuotes: PropTypes.func.isRequired,
364393
t: PropTypes.func.isRequired,
365394
};
366395

client/modules/IDE/pages/IDEView.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ class IDEView extends React.Component {
286286
setSoundOutput={this.props.setSoundOutput}
287287
theme={this.props.preferences.theme}
288288
setTheme={this.props.setTheme}
289+
autocloseBracketsQuotes={this.props.preferences.autocloseBracketsQuotes}
290+
setAutocloseBracketsQuotes={this.props.setAutocloseBracketsQuotes}
289291
/>
290292
</Overlay>
291293
)}
@@ -534,9 +536,11 @@ IDEView.propTypes = {
534536
soundOutput: PropTypes.bool.isRequired,
535537
theme: PropTypes.string.isRequired,
536538
autorefresh: PropTypes.bool.isRequired,
537-
language: PropTypes.string.isRequired
539+
language: PropTypes.string.isRequired,
540+
autocloseBracketsQuotes: PropTypes.bool.isRequired
538541
}).isRequired,
539542
closePreferences: PropTypes.func.isRequired,
543+
setAutocloseBracketsQuotes: PropTypes.func.isRequired,
540544
setFontSize: PropTypes.func.isRequired,
541545
setAutosave: PropTypes.func.isRequired,
542546
setLineNumbers: PropTypes.func.isRequired,

client/modules/IDE/reducers/preferences.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const initialState = {
1212
soundOutput: false,
1313
theme: 'light',
1414
autorefresh: false,
15-
language: 'en-US'
15+
language: 'en-US',
16+
autocloseBracketsQuotes: false
1617
};
1718

1819
const preferences = (state = initialState, action) => {
@@ -41,6 +42,8 @@ const preferences = (state = initialState, action) => {
4142
return Object.assign({}, state, { lineNumbers: action.value });
4243
case ActionTypes.SET_LANGUAGE:
4344
return Object.assign({}, state, { language: action.language });
45+
case ActionTypes.SET_AUTOCLOSE_BRACKETS_QUOTES:
46+
return Object.assign({}, state, { autocloseBracketsQuotes: action.value });
4447
default:
4548
return state;
4649
}

translations/locales/en-US/translations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
"AutosaveOnARIA": "autosave on",
134134
"Off": "Off",
135135
"AutosaveOffARIA": "autosave off",
136+
"AutocloseBracketsQuotes": "Autoclose brackets, quotes",
137+
"AutocloseBracketsQuotesOnARIA": "autoclose brackets, quotes on",
138+
"AutocloseBracketsQuotesOffARIA": "autoclose brackets, quotes off",
136139
"WordWrap": "Word Wrap",
137140
"LineWrapOnARIA": "linewrap on",
138141
"LineWrapOffARIA": "linewrap off",

0 commit comments

Comments
 (0)