Merge branch 'master' into mochatest

pull/3166/head
Aniket 2 years ago committed by GitHub
commit 3759c56acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      apps/remix-ide/src/app/editor/editor.js
  2. 4
      apps/remix-ide/src/app/files/fileManager.ts
  3. 2
      apps/remix-ide/src/app/plugins/file-decorator.ts
  4. 18
      apps/remix-ide/src/app/tabs/settings-tab.tsx
  5. 9
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  6. 6
      libs/remix-ui/locale-module/src/lib/remix-ui-locale-module.tsx
  7. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -220,7 +220,7 @@ class Editor extends Plugin {
if (pathExists) { if (pathExists) {
contentDep = await readFile(pathDep) contentDep = await readFile(pathDep)
if (contentDep !== '') { if (contentDep !== '') {
this.emit('addModel', contentDep, 'typescript', pathDep, false) this.emit('addModel', contentDep, 'typescript', pathDep, this.readOnlySessions[path])
} }
} else { } else {
console.log("The file ", pathDep, " can't be found.") console.log("The file ", pathDep, " can't be found.")
@ -241,7 +241,7 @@ class Editor extends Plugin {
async _createSession (path, content, mode) { async _createSession (path, content, mode) {
if (!this.activated) return if (!this.activated) return
this.emit('addModel', content, mode, path, false) this.emit('addModel', content, mode, path, this.readOnlySessions[path])
return { return {
path, path,
language: mode, language: mode,
@ -266,7 +266,7 @@ class Editor extends Plugin {
} }
addModel(path, content) { addModel(path, content) {
this.emit('addModel', content, this._getMode(path), path, false) this.emit('addModel', content, this._getMode(path), path, this.readOnlySessions[path])
} }
/** /**
@ -301,9 +301,9 @@ class Editor extends Plugin {
- URL not prepended with the file explorer. We assume (as it is in the whole app, that this is a "browser" URL - URL not prepended with the file explorer. We assume (as it is in the whole app, that this is a "browser" URL
*/ */
if (!this.sessions[path]) { if (!this.sessions[path]) {
this.readOnlySessions[path] = false
const session = await this._createSession(path, content, this._getMode(path)) const session = await this._createSession(path, content, this._getMode(path))
this.sessions[path] = session this.sessions[path] = session
this.readOnlySessions[path] = false
} else if (this.sessions[path].getValue() !== content) { } else if (this.sessions[path].getValue() !== content) {
this.sessions[path].setValue(content) this.sessions[path].setValue(content)
} }
@ -317,9 +317,9 @@ class Editor extends Plugin {
*/ */
async openReadOnly (path, content) { async openReadOnly (path, content) {
if (!this.sessions[path]) { if (!this.sessions[path]) {
this.readOnlySessions[path] = true
const session = await this._createSession(path, content, this._getMode(path)) const session = await this._createSession(path, content, this._getMode(path))
this.sessions[path] = session this.sessions[path] = session
this.readOnlySessions[path] = true
} }
this._switchSession(path) this._switchSession(path)
} }

@ -19,7 +19,9 @@ const profile = {
icon: 'assets/img/fileManager.webp', icon: 'assets/img/fileManager.webp',
permission: true, permission: true,
version: packageJson.version, version: packageJson.version,
methods: ['closeAllFiles', 'closeFile', 'file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'dirList', 'fileList', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath', 'saveCurrentFile', 'setBatchFiles', 'isGitRepo'], methods: ['closeAllFiles', 'closeFile', 'file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir',
'readdir', 'dirList', 'fileList', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh',
'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath', 'saveCurrentFile', 'setBatchFiles', 'isGitRepo'],
kind: 'file-system' kind: 'file-system'
} }
const errorMsg = { const errorMsg = {

@ -12,7 +12,6 @@ const profile = {
events: ['fileDecoratorsChanged'], events: ['fileDecoratorsChanged'],
version: '0.0.1' version: '0.0.1'
} }
export class FileDecorator extends Plugin { export class FileDecorator extends Plugin {
private _fileStates: fileDecoration[] = [] private _fileStates: fileDecoration[] = []
constructor() { constructor() {
@ -26,7 +25,6 @@ export class FileDecorator extends Plugin {
} }
/** /**
*
* @param fileStates Array of file states * @param fileStates Array of file states
*/ */
async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) { async setFileDecorators(fileStates: fileDecoration[] | fileDecoration) {

@ -53,19 +53,19 @@ module.exports = class SettingsTab extends ViewPlugin {
render() { render() {
return <div id='settingsTab'> return <div id='settingsTab'>
<PluginViewWrapper plugin={this} /> <PluginViewWrapper plugin={this} />
</div> </div>
} }
updateComponent(state: any){ updateComponent(state: any){
return <RemixUiSettings return <RemixUiSettings
config={state.config} config={state.config}
editor={state.editor} editor={state.editor}
_deps={state._deps} _deps={state._deps}
useMatomoAnalytics={state.useMatomoAnalytics} useMatomoAnalytics={state.useMatomoAnalytics}
themeModule = {state._deps.themeModule} themeModule = {state._deps.themeModule}
localeModule={state._deps.localeModule} localeModule={state._deps.localeModule}
/> />
} }
renderComponent () { renderComponent () {

@ -671,7 +671,6 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.languages.registerHoverProvider('remix-solidity', new RemixHoverProvider(props, monaco)) monacoRef.current.languages.registerHoverProvider('remix-solidity', new RemixHoverProvider(props, monaco))
monacoRef.current.languages.registerCompletionItemProvider('remix-solidity', new RemixCompletionProvider(props, monaco)) monacoRef.current.languages.registerCompletionItemProvider('remix-solidity', new RemixCompletionProvider(props, monaco))
loadTypes(monacoRef.current) loadTypes(monacoRef.current)
} }
@ -683,10 +682,14 @@ export const EditorUI = (props: EditorUIProps) => {
language={editorModelsState[props.currentFile] ? editorModelsState[props.currentFile].language : 'text'} language={editorModelsState[props.currentFile] ? editorModelsState[props.currentFile].language : 'text'}
onMount={handleEditorDidMount} onMount={handleEditorDidMount}
beforeMount={handleEditorWillMount} beforeMount={handleEditorWillMount}
options={{ glyphMargin: true, readOnly: (!editorRef.current || !props.currentFile) }} options={{ glyphMargin: true, readOnly: ((!editorRef.current || !props.currentFile) && editorModelsState[props.currentFile]?.readOnly) }}
defaultValue={defaultEditorValue} defaultValue={defaultEditorValue}
/> />
{editorModelsState[props.currentFile]?.readOnly && <span className='pl-4 h6 mb-0 w-100 alert-info position-absolute bottom-0 end-0'>
<i className="fas fa-lock-alt p-2"></i>
The file is opened in <b>read-only</b> mode.
</span>
}
</div> </div>
) )
} }

@ -15,9 +15,11 @@ export function RemixUiLocaleModule({ localeModule }: RemixUiLocaleModuleProps)
}, [localeName, localeModule]) }, [localeName, localeModule])
return ( return (
<div className="border-top"> <div className="border-top mb-4">
<div className="card-body pt-3 pb-2"> <div className="card-body pt-3 pb-2">
<h6 className="card-title"><FormattedMessage id='settings.locales' defaultMessage='Lanaguage' /></h6> <h6 className="card-title">
<FormattedMessage id='settings.locales' defaultMessage='Lanaguage' />
</h6>
<div className="card-text locales-container"> <div className="card-text locales-container">
{localeModule.getLocales() {localeModule.getLocales()
? localeModule.getLocales().map((locale, idx) => ( ? localeModule.getLocales().map((locale, idx) => (

@ -350,6 +350,10 @@ export function Workspace () {
) )
} }
const formatNameForReadonly = (name: string) => {
return global.fs.readonly ? name + " (read-only)" : name
}
const cloneModalMessage = () => { const cloneModalMessage = () => {
return ( return (
<> <>
@ -607,7 +611,7 @@ export function Workspace () {
<Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}> <Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}>
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control mt-1" icon={selectedWorkspace && selectedWorkspace.isGitRepo && !(currentWorkspace === LOCALHOST) ? 'far fa-code-branch' : null}> <Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control mt-1" icon={selectedWorkspace && selectedWorkspace.isGitRepo && !(currentWorkspace === LOCALHOST) ? 'far fa-code-branch' : null}>
{ selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? 'localhost' : NO_WORKSPACE } { selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? formatNameForReadonly("localhost") : NO_WORKSPACE }
</Dropdown.Toggle> </Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} className='w-100 custom-dropdown-items' data-id="custom-dropdown-items"> <Dropdown.Menu as={CustomMenu} className='w-100 custom-dropdown-items' data-id="custom-dropdown-items">

Loading…
Cancel
Save