Merge pull request #3531 from ethereum/update_settings

Update settings
add_tweak_vm
yann300 2 years ago committed by GitHub
commit a5d11c4127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts
  2. 7
      apps/remix-ide-e2e/src/tests/editorReferences.test.ts
  3. 8
      apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts
  4. 8
      apps/remix-ide-e2e/src/tests/editor_line_text.test.ts
  5. 1
      apps/remix-ide/src/blockchain/blockchain.js
  6. 2
      apps/remix-ide/src/blockchain/execution-context.js
  7. 2
      libs/remix-ui/editor/src/lib/providers/completionProvider.ts
  8. 22
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx
  9. 5
      libs/remix-ui/settings/src/lib/settingsAction.ts

@ -18,14 +18,6 @@ module.exports = {
init(browser, done, 'http://127.0.0.1:8080', false) init(browser, done, 'http://127.0.0.1:8080', false)
}, },
'Should enable settings': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('settings')
.click('[data-id="settingsAutoCompleteLabel"]')
.click('[data-id="settingsShowGasLabel"]')
.click('[data-id="displayErrorsLabel"]')
},
'Should load the test file': function (browser: NightwatchBrowser) { 'Should load the test file': function (browser: NightwatchBrowser) {
browser.openFile('contracts') browser.openFile('contracts')
.openFile('contracts/3_Ballot.sol') .openFile('contracts/3_Ballot.sol')

@ -20,13 +20,6 @@ module.exports = {
init(browser, done, 'http://127.0.0.1:8080', false) init(browser, done, 'http://127.0.0.1:8080', false)
}, },
'Should enable settings': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('settings')
.click('[data-id="settingsAutoCompleteLabel"]')
.click('[data-id="settingsShowGasLabel"]')
.click('[data-id="displayErrorsLabel"]')
},
'Should load the test file': function (browser: NightwatchBrowser) { 'Should load the test file': function (browser: NightwatchBrowser) {
browser.openFile('contracts') browser.openFile('contracts')
.openFile('contracts/3_Ballot.sol') .openFile('contracts/3_Ballot.sol')

@ -8,13 +8,7 @@ module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) { before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', true) init(browser, done, 'http://127.0.0.1:8080', true)
}, },
'Should enable settings': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('settings')
.click('[data-id="settingsAutoCompleteLabel"]')
.click('[data-id="settingsShowGasLabel"]')
.click('[data-id="displayErrorsLabel"]')
},
'Should add error marker': function (browser: NightwatchBrowser) { 'Should add error marker': function (browser: NightwatchBrowser) {
browser browser
.openFile('contracts') .openFile('contracts')

@ -8,13 +8,7 @@ module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) { before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', true) init(browser, done, 'http://127.0.0.1:8080', true)
}, },
'Should enable settings': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('settings')
.click('[data-id="settingsAutoCompleteLabel"]')
.click('[data-id="settingsShowGasLabel"]')
.click('[data-id="displayErrorsLabel"]')
},
'Should add line texts': function (browser: NightwatchBrowser) { 'Should add line texts': function (browser: NightwatchBrowser) {
browser browser
.openFile('contracts') .openFile('contracts')

@ -500,7 +500,6 @@ export class Blockchain extends Plugin {
} }
// NOTE: the config is only needed because exectuionContext.init does // NOTE: the config is only needed because exectuionContext.init does
// if config.get('settings/always-use-vm'), we can simplify this later
async resetAndInit (config, transactionContextAPI) { async resetAndInit (config, transactionContextAPI) {
this.transactionContextAPI = transactionContextAPI this.transactionContextAPI = transactionContextAPI
this.executionContext.init(config) this.executionContext.init(config)

@ -34,9 +34,7 @@ export class ExecutionContext {
} }
init (config) { init (config) {
if (config.get('settings/always-use-vm')) {
this.executionContext = 'vm-merge' this.executionContext = 'vm-merge'
}
this.event.trigger('contextChanged', [this.executionContext]) this.event.trigger('contextChanged', [this.executionContext])
} }

@ -119,7 +119,7 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion
// truncate for performance // truncate for performance
if (filteredNodes.length > this.maximumItemsForContractCompletion) { if (filteredNodes.length > this.maximumItemsForContractCompletion) {
await this.props.plugin.call('notification', 'toast', `Too many completion items. Only ${this.maximumItemsForContractCompletion} items will be shown.`) // await this.props.plugin.call('notification', 'toast', `Too many completion items. Only ${this.maximumItemsForContractCompletion} items will be shown.`)
filteredNodes = filteredNodes.slice(0, this.maximumItemsForContractCompletion) filteredNodes = filteredNodes.slice(0, this.maximumItemsForContractCompletion)
} }

@ -3,7 +3,7 @@ import React, { useState, useReducer, useEffect, useCallback } from 'react' // e
import { labels, textDark, textSecondary } from './constants' import { labels, textDark, textSecondary } from './constants'
import './remix-ui-settings.css' import './remix-ui-settings.css'
import { ethereumVM, generateContractMetadat, personal, textWrapEventAction, useMatomoAnalytics, saveTokenToast, removeTokenToast, saveSwarmSettingsToast, saveIpfsSettingsToast, useAutoCompletion, useShowGasInEditor, useDisplayErrors } from './settingsAction' import { generateContractMetadat, personal, textWrapEventAction, useMatomoAnalytics, saveTokenToast, removeTokenToast, saveSwarmSettingsToast, saveIpfsSettingsToast, useAutoCompletion, useShowGasInEditor, useDisplayErrors } from './settingsAction'
import { initialState, toastInitialState, toastReducer, settingReducer } from './settingsReducer' import { initialState, toastInitialState, toastReducer, settingReducer } from './settingsReducer'
import { Toaster } from '@remix-ui/toaster'// eslint-disable-line import { Toaster } from '@remix-ui/toaster'// eslint-disable-line
import { RemixUiThemeModule, ThemeModule} from '@remix-ui/theme-module' import { RemixUiThemeModule, ThemeModule} from '@remix-ui/theme-module'
@ -41,17 +41,14 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
const metadataConfig = props.config.get('settings/generate-contract-metadata') const metadataConfig = props.config.get('settings/generate-contract-metadata')
if (metadataConfig === undefined || metadataConfig === null) generateContractMetadat(props.config, true, dispatch) if (metadataConfig === undefined || metadataConfig === null) generateContractMetadat(props.config, true, dispatch)
const javascriptVM = props.config.get('settings/always-use-vm')
if (javascriptVM === null || javascriptVM === undefined) ethereumVM(props.config, true, dispatch)
const useAutoComplete = props.config.get('settings/auto-completion') const useAutoComplete = props.config.get('settings/auto-completion')
if (useAutoComplete === null || useAutoComplete === undefined) useAutoCompletion(props.config, false, dispatch) if (useAutoComplete === null || useAutoComplete === undefined) useAutoCompletion(props.config, true, dispatch)
const displayErrors = props.config.get('settings/display-errors') const displayErrors = props.config.get('settings/display-errors')
if (displayErrors === null || displayErrors === undefined) useDisplayErrors(props.config, false, dispatch) if (displayErrors === null || displayErrors === undefined) useDisplayErrors(props.config, true, dispatch)
const useShowGas = props.config.get('settings/show-gas') const useShowGas = props.config.get('settings/show-gas')
if (useShowGas === null || useShowGas === undefined) useShowGasInEditor(props.config, false, dispatch) if (useShowGas === null || useShowGas === undefined) useShowGasInEditor(props.config, true, dispatch)
} }
useEffect(() => initValue(), [resetState, props.config]) useEffect(() => initValue(), [resetState, props.config])
useEffect(() => initValue(), []) useEffect(() => initValue(), [])
@ -110,10 +107,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
generateContractMetadat(props.config, event.target.checked, dispatch) generateContractMetadat(props.config, event.target.checked, dispatch)
} }
const onchangeOption = (event) => {
ethereumVM(props.config, event.target.checked, dispatch)
}
const textWrapEvent = (event) => { const textWrapEvent = (event) => {
textWrapEventAction(props.config, props.editor, event.target.checked, dispatch) textWrapEventAction(props.config, props.editor, event.target.checked, dispatch)
} }
@ -148,7 +141,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
const generalConfig = () => { const generalConfig = () => {
const isMetadataChecked = props.config.get('settings/generate-contract-metadata') || false const isMetadataChecked = props.config.get('settings/generate-contract-metadata') || false
const isEthereumVMChecked = props.config.get('settings/always-use-vm') || false
const isEditorWrapChecked = props.config.get('settings/text-wrap') || false const isEditorWrapChecked = props.config.get('settings/text-wrap') || false
const isPersonalChecked = props.config.get('settings/personal-mode') || false const isPersonalChecked = props.config.get('settings/personal-mode') || false
const isMatomoChecked = props.config.get('settings/matomo-analytics') || false const isMatomoChecked = props.config.get('settings/matomo-analytics') || false
@ -192,12 +184,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
<FormattedMessage id='settings.generateContractMetadataText' /> <FormattedMessage id='settings.generateContractMetadataText' />
</label> </label>
</div> </div>
<div className="fmt-2 custom-control custom-checkbox mb-1">
<input onChange={onchangeOption} className="custom-control-input" id="alwaysUseVM" data-id="settingsTabAlwaysUseVM" type="checkbox" name="ethereumVM" checked={isEthereumVMChecked} />
<label className={`form-check-label custom-control-label align-middle ${getTextClass('settings/always-use-vm')}`} htmlFor="alwaysUseVM">
<FormattedMessage id='settings.ethereunVMText' />
</label>
</div>
<div className="mt-2 custom-control custom-checkbox mb-1"> <div className="mt-2 custom-control custom-checkbox mb-1">
<input id="editorWrap" className="custom-control-input" type="checkbox" onChange={textWrapEvent} checked={isEditorWrapChecked} /> <input id="editorWrap" className="custom-control-input" type="checkbox" onChange={textWrapEvent} checked={isEditorWrapChecked} />
<label className={`form-check-label custom-control-label align-middle ${getTextClass('settings/text-wrap')}`} htmlFor="editorWrap"> <label className={`form-check-label custom-control-label align-middle ${getTextClass('settings/text-wrap')}`} htmlFor="editorWrap">

@ -13,11 +13,6 @@ export const generateContractMetadat = (config, checked, dispatch) => {
dispatch({ type: 'contractMetadata', payload: { isChecked: checked, textClass: checked ? textDark : textSecondary } }) dispatch({ type: 'contractMetadata', payload: { isChecked: checked, textClass: checked ? textDark : textSecondary } })
} }
export const ethereumVM = (config, checked: boolean, dispatch) => {
config.set('settings/always-use-vm', checked)
dispatch({ type: 'ethereumVM', payload: { isChecked: checked, textClass: checked ? textDark : textSecondary } })
}
export const textWrapEventAction = (config, editor, checked, dispatch) => { export const textWrapEventAction = (config, editor, checked, dispatch) => {
config.set('settings/text-wrap', checked) config.set('settings/text-wrap', checked)
editor.resize(checked) editor.resize(checked)

Loading…
Cancel
Save