fix but failed
This commit is contained in:
parent
03cf265eff
commit
e2fb33bdc5
20 changed files with 74 additions and 98 deletions
|
@ -29,6 +29,7 @@
|
||||||
"id-length": "off",
|
"id-length": "off",
|
||||||
"indent": ["error", 2],
|
"indent": ["error", 2],
|
||||||
"jsx-quotes": ["error", "prefer-single"],
|
"jsx-quotes": ["error", "prefer-single"],
|
||||||
|
"max-classes-per-file": "off",
|
||||||
"max-params": ["error", 5],
|
"max-params": ["error", 5],
|
||||||
"max-statements": ["error", 15],
|
"max-statements": ["error", 15],
|
||||||
"multiline-comment-style": "off",
|
"multiline-comment-style": "off",
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default class BackgroundComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity, max-lines-per-function
|
||||||
exec(operation, tab) {
|
exec(operation, tab) {
|
||||||
let tabState = this.store.getState().tab;
|
let tabState = this.store.getState().tab;
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.FIND_SET_KEYWORD:
|
case actions.FIND_SET_KEYWORD:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keyword: action.keyword,
|
keyword: action.keyword, };
|
||||||
});
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,8 @@ const defaultState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
setting: settingReducer(state.setting, action),
|
setting: settingReducer(state.setting, action),
|
||||||
find: findReducer(state.find, action),
|
find: findReducer(state.find, action),
|
||||||
tab: tabReducer(state.tab, action),
|
tab: tabReducer(state.tab, action), };
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,8 @@ export default function reducer(state = defaultState, action = {}) {
|
||||||
};
|
};
|
||||||
case actions.SETTING_SET_PROPERTY:
|
case actions.SETTING_SET_PROPERTY:
|
||||||
return {
|
return {
|
||||||
value: Object.assign({}, state.value, {
|
value: { ...state.value,
|
||||||
properties: Object.assign({}, state.value.properties,
|
properties: { ...state.value.properties, [action.name]: action.value }}
|
||||||
{ [action.name]: action.value })
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -51,68 +51,61 @@ const nextConsoleText = (completions, group, item, defaults) => {
|
||||||
return completions[group].items[item].content;
|
return completions[group].items[item].content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-lines-per-function
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.CONSOLE_HIDE:
|
case actions.CONSOLE_HIDE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
mode: '',
|
mode: '', };
|
||||||
});
|
|
||||||
case actions.CONSOLE_SHOW_COMMAND:
|
case actions.CONSOLE_SHOW_COMMAND:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
mode: 'command',
|
mode: 'command',
|
||||||
consoleText: action.text,
|
consoleText: action.text,
|
||||||
completions: []
|
completions: []};
|
||||||
});
|
|
||||||
case actions.CONSOLE_SHOW_FIND:
|
case actions.CONSOLE_SHOW_FIND:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
mode: 'find',
|
mode: 'find',
|
||||||
consoleText: '',
|
consoleText: '',
|
||||||
completions: []
|
completions: []};
|
||||||
});
|
|
||||||
case actions.CONSOLE_SHOW_ERROR:
|
case actions.CONSOLE_SHOW_ERROR:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
mode: 'error',
|
mode: 'error',
|
||||||
messageText: action.text,
|
messageText: action.text, };
|
||||||
});
|
|
||||||
case actions.CONSOLE_SHOW_INFO:
|
case actions.CONSOLE_SHOW_INFO:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
mode: 'info',
|
mode: 'info',
|
||||||
messageText: action.text,
|
messageText: action.text, };
|
||||||
});
|
|
||||||
case actions.CONSOLE_HIDE_COMMAND:
|
case actions.CONSOLE_HIDE_COMMAND:
|
||||||
return Object.assign({}, state, {
|
return {
|
||||||
|
...state,
|
||||||
mode: state.mode === 'command' || state.mode === 'find' ? '' : state.mode,
|
mode: state.mode === 'command' || state.mode === 'find' ? '' : state.mode,
|
||||||
});
|
};
|
||||||
case actions.CONSOLE_SET_CONSOLE_TEXT:
|
case actions.CONSOLE_SET_CONSOLE_TEXT:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
consoleText: action.consoleText,
|
consoleText: action.consoleText, };
|
||||||
});
|
|
||||||
case actions.CONSOLE_SET_COMPLETIONS:
|
case actions.CONSOLE_SET_COMPLETIONS:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
completions: action.completions,
|
completions: action.completions,
|
||||||
completionSource: action.completionSource,
|
completionSource: action.completionSource,
|
||||||
groupSelection: -1,
|
groupSelection: -1,
|
||||||
itemSelection: -1,
|
itemSelection: -1, };
|
||||||
});
|
|
||||||
case actions.CONSOLE_COMPLETION_NEXT: {
|
case actions.CONSOLE_COMPLETION_NEXT: {
|
||||||
let next = nextSelection(state);
|
let next = nextSelection(state);
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
groupSelection: next[0],
|
groupSelection: next[0],
|
||||||
itemSelection: next[1],
|
itemSelection: next[1],
|
||||||
consoleText: nextConsoleText(
|
consoleText: nextConsoleText(
|
||||||
state.completions, next[0], next[1],
|
state.completions, next[0], next[1],
|
||||||
state.completionSource),
|
state.completionSource), };
|
||||||
});
|
|
||||||
}
|
}
|
||||||
case actions.CONSOLE_COMPLETION_PREV: {
|
case actions.CONSOLE_COMPLETION_PREV: {
|
||||||
let next = prevSelection(state);
|
let next = prevSelection(state);
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
groupSelection: next[0],
|
groupSelection: next[0],
|
||||||
itemSelection: next[1],
|
itemSelection: next[1],
|
||||||
consoleText: nextConsoleText(
|
consoleText: nextConsoleText(
|
||||||
state.completions, next[0], next[1],
|
state.completions, next[0], next[1],
|
||||||
state.completionSource),
|
state.completionSource), };
|
||||||
});
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import * as consoleFrames from 'content/console-frames';
|
||||||
import * as addonActions from './addon';
|
import * as addonActions from './addon';
|
||||||
import * as properties from 'shared/settings/properties';
|
import * as properties from 'shared/settings/properties';
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity, max-lines-per-function
|
||||||
const exec = (operation, repeat, settings) => {
|
const exec = (operation, repeat, settings) => {
|
||||||
let smoothscroll = settings.properties.smoothscroll ||
|
let smoothscroll = settings.properties.smoothscroll ||
|
||||||
properties.defaults.smoothscroll;
|
properties.defaults.smoothscroll;
|
||||||
|
|
|
@ -10,7 +10,7 @@ const reservedKeymaps = {
|
||||||
const set = (value) => {
|
const set = (value) => {
|
||||||
let entries = [];
|
let entries = [];
|
||||||
if (value.keymaps) {
|
if (value.keymaps) {
|
||||||
let keymaps = Object.assign({}, value.keymaps, reservedKeymaps);
|
let keymaps = { ...value.keymaps, ...reservedKeymaps };
|
||||||
entries = Object.entries(keymaps).map((entry) => {
|
entries = Object.entries(keymaps).map((entry) => {
|
||||||
return [
|
return [
|
||||||
keyUtils.fromMapKeys(entry[0]),
|
keyUtils.fromMapKeys(entry[0]),
|
||||||
|
@ -21,9 +21,8 @@ const set = (value) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: actions.SETTING_SET,
|
type: actions.SETTING_SET,
|
||||||
value: Object.assign({}, value, {
|
value: { ...value,
|
||||||
keymaps: entries,
|
keymaps: entries, }
|
||||||
})
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,14 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.ADDON_ENABLE:
|
case actions.ADDON_ENABLE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
enabled: true,
|
enabled: true, };
|
||||||
});
|
|
||||||
case actions.ADDON_DISABLE:
|
case actions.ADDON_DISABLE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
enabled: false,
|
enabled: false, };
|
||||||
});
|
|
||||||
case actions.ADDON_TOGGLE_ENABLED:
|
case actions.ADDON_TOGGLE_ENABLED:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
enabled: !state.enabled,
|
enabled: !state.enabled, };
|
||||||
});
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.FIND_SET_KEYWORD:
|
case actions.FIND_SET_KEYWORD:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keyword: action.keyword,
|
keyword: action.keyword,
|
||||||
found: action.found,
|
found: action.found, };
|
||||||
});
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,20 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.FOLLOW_CONTROLLER_ENABLE:
|
case actions.FOLLOW_CONTROLLER_ENABLE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
newTab: action.newTab,
|
newTab: action.newTab,
|
||||||
background: action.background,
|
background: action.background,
|
||||||
keys: '',
|
keys: '', };
|
||||||
});
|
|
||||||
case actions.FOLLOW_CONTROLLER_DISABLE:
|
case actions.FOLLOW_CONTROLLER_DISABLE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
enabled: false,
|
enabled: false, };
|
||||||
});
|
|
||||||
case actions.FOLLOW_CONTROLLER_KEY_PRESS:
|
case actions.FOLLOW_CONTROLLER_KEY_PRESS:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keys: state.keys + action.key,
|
keys: state.keys + action.key, };
|
||||||
});
|
|
||||||
case actions.FOLLOW_CONTROLLER_BACKSPACE:
|
case actions.FOLLOW_CONTROLLER_BACKSPACE:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keys: state.keys.slice(0, -1),
|
keys: state.keys.slice(0, -1), };
|
||||||
});
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,12 @@ const defaultState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
return Object.assign({}, state, {
|
return {
|
||||||
|
...state,
|
||||||
addon: addonReducer(state.addon, action),
|
addon: addonReducer(state.addon, action),
|
||||||
find: findReducer(state.find, action),
|
find: findReducer(state.find, action),
|
||||||
setting: settingReducer(state.setting, action),
|
setting: settingReducer(state.setting, action),
|
||||||
input: inputReducer(state.input, action),
|
input: inputReducer(state.input, action),
|
||||||
followController: followControllerReducer(state.followController, action),
|
followController: followControllerReducer(state.followController, action),
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.INPUT_KEY_PRESS:
|
case actions.INPUT_KEY_PRESS:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keys: state.keys.concat([action.key]),
|
keys: state.keys.concat([action.key]), };
|
||||||
});
|
|
||||||
case actions.INPUT_CLEAR_KEYS:
|
case actions.INPUT_CLEAR_KEYS:
|
||||||
return Object.assign({}, state, {
|
return { ...state,
|
||||||
keys: [],
|
keys: [], };
|
||||||
});
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ const defaultState = {
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.SETTING_SET:
|
case actions.SETTING_SET:
|
||||||
return Object.assign({}, action.value);
|
return { ...action.value };
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ class KeymapsForm extends Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let next = Object.assign({}, this.props.value);
|
let next = { ...this.props.value };
|
||||||
next[e.target.name] = e.target.value;
|
next[e.target.name] = e.target.value;
|
||||||
|
|
||||||
this.props.onChange(next);
|
this.props.onChange(next);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PropertiesForm extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = e.target.name;
|
let name = e.target.name;
|
||||||
let next = Object.assign({}, this.props.value);
|
let next = { ...this.props.value };
|
||||||
if (e.target.type.toLowerCase() === 'checkbox') {
|
if (e.target.type.toLowerCase() === 'checkbox') {
|
||||||
next[name] = e.target.checked;
|
next[name] = e.target.checked;
|
||||||
} else if (e.target.type.toLowerCase() === 'number') {
|
} else if (e.target.type.toLowerCase() === 'number') {
|
||||||
|
|
|
@ -53,10 +53,10 @@ class SearchForm extends Component {
|
||||||
let value = this.props.value;
|
let value = this.props.value;
|
||||||
let name = e.target.name;
|
let name = e.target.name;
|
||||||
let index = e.target.getAttribute('data-index');
|
let index = e.target.getAttribute('data-index');
|
||||||
let next = Object.assign({}, {
|
let next = {
|
||||||
default: value.default,
|
default: value.default,
|
||||||
engines: value.engines ? value.engines.slice() : [],
|
engines: value.engines ? value.engines.slice() : [],
|
||||||
});
|
};
|
||||||
|
|
||||||
if (name === 'name') {
|
if (name === 'name') {
|
||||||
next.engines[index][0] = e.target.value;
|
next.engines[index][0] = e.target.value;
|
||||||
|
|
|
@ -134,7 +134,7 @@ class SettingsComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
validateValue(e) {
|
validateValue(e) {
|
||||||
let next = Object.assign({}, this.state);
|
let next = { ...this.state };
|
||||||
|
|
||||||
next.errors.json = '';
|
next.errors.json = '';
|
||||||
try {
|
try {
|
||||||
|
@ -146,18 +146,16 @@ class SettingsComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
bindForm(name, value) {
|
bindForm(name, value) {
|
||||||
let next = Object.assign({}, this.state, {
|
let next = { ...this.state,
|
||||||
settings: Object.assign({}, this.state.settings, {
|
settings: { ...this.state.settings,
|
||||||
form: Object.assign({}, this.state.settings.form)
|
form: { ...this.state.settings.form }}};
|
||||||
})
|
|
||||||
});
|
|
||||||
next.settings.form[name] = value;
|
next.settings.form[name] = value;
|
||||||
this.setState(next);
|
this.setState(next);
|
||||||
this.context.store.dispatch(settingActions.save(next.settings));
|
this.context.store.dispatch(settingActions.save(next.settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
bindValue(e) {
|
bindValue(e) {
|
||||||
let next = Object.assign({}, this.state);
|
let next = { ...this.state };
|
||||||
let error = false;
|
let error = false;
|
||||||
|
|
||||||
next.errors.json = '';
|
next.errors.json = '';
|
||||||
|
@ -190,7 +188,7 @@ class SettingsComponent extends Component {
|
||||||
|
|
||||||
let form = settingsValues.formFromJson(
|
let form = settingsValues.formFromJson(
|
||||||
this.state.settings.json, KeymapsForm.AllowdOps);
|
this.state.settings.json, KeymapsForm.AllowdOps);
|
||||||
let next = Object.assign({}, this.state);
|
let next = { ...this.state };
|
||||||
next.settings.form = form;
|
next.settings.form = form;
|
||||||
next.settings.source = 'form';
|
next.settings.source = 'form';
|
||||||
next.errors.json = '';
|
next.errors.json = '';
|
||||||
|
@ -201,7 +199,7 @@ class SettingsComponent extends Component {
|
||||||
|
|
||||||
migrateToJson() {
|
migrateToJson() {
|
||||||
let json = settingsValues.jsonFromForm(this.state.settings.form);
|
let json = settingsValues.jsonFromForm(this.state.settings.form);
|
||||||
let next = Object.assign({}, this.state);
|
let next = { ...this.state };
|
||||||
next.settings.json = json;
|
next.settings.json = json;
|
||||||
next.settings.source = 'json';
|
next.settings.source = 'json';
|
||||||
next.errors.json = '';
|
next.errors.json = '';
|
||||||
|
|
|
@ -6,7 +6,7 @@ const loadRaw = async() => {
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
return DefaultSettings;
|
return DefaultSettings;
|
||||||
}
|
}
|
||||||
return Object.assign({}, DefaultSettings, settings);
|
return { ...DefaultSettings, ...settings };
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadValue = async() => {
|
const loadValue = async() => {
|
||||||
|
@ -20,9 +20,7 @@ const loadValue = async() => {
|
||||||
if (!value.properties) {
|
if (!value.properties) {
|
||||||
value.properties = {};
|
value.properties = {};
|
||||||
}
|
}
|
||||||
return Object.assign({},
|
return { ...settingsValues.valueFromJson(DefaultSettings.json), ...value };
|
||||||
settingsValues.valueFromJson(DefaultSettings.json),
|
|
||||||
value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = (settings) => {
|
const save = (settings) => {
|
||||||
|
|
|
@ -6,12 +6,12 @@ const operationFromFormName = (name) => {
|
||||||
if (argStr) {
|
if (argStr) {
|
||||||
args = JSON.parse(argStr);
|
args = JSON.parse(argStr);
|
||||||
}
|
}
|
||||||
return Object.assign({ type }, args);
|
return { type, ...args };
|
||||||
};
|
};
|
||||||
|
|
||||||
const operationToFormName = (op) => {
|
const operationToFormName = (op) => {
|
||||||
let type = op.type;
|
let type = op.type;
|
||||||
let args = Object.assign({}, op);
|
let args = { ...op };
|
||||||
delete args.type;
|
delete args.type;
|
||||||
|
|
||||||
if (Object.keys(args).length === 0) {
|
if (Object.keys(args).length === 0) {
|
||||||
|
@ -83,7 +83,7 @@ const formFromValue = (value, allowedOps) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let formProperties = Object.assign({}, properties.defaults, value.properties);
|
let formProperties = { ...properties.defaults, ...value.properties };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
keymaps,
|
keymaps,
|
||||||
|
|
Reference in a new issue