Merge branch 'master' into master

pull/4130/head
Liana Husikyan 1 year ago committed by GitHub
commit 42cbede141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
  2. 30
      apps/remix-ide/src/app/files/fileManager.ts
  3. 3
      apps/remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css
  4. 3
      apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css
  5. 3
      apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css
  6. 3
      apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css
  7. 1
      apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css
  8. 1
      apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css
  9. 1
      apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css
  10. 1
      apps/remix-ide/src/assets/css/themes/remix-unicorn.css
  11. 1
      apps/remix-ide/src/assets/css/themes/remix-violet.css

@ -42,6 +42,25 @@ module.exports = {
})
},
'Should execute `writeMultipleFiles` api from file manager external api #group1': function (browser: NightwatchBrowser) {
browser
.addFile('writeMultipleFiles.js', { content: executeWriteMultipleFiles })
.executeScriptInTerminal('remix.exeCurrent()')
.pause(2000)
.openFile('contracts/new_contract_1.sol')
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('pragma solidity ^0.6.0') !== -1, 'content does not contain "pragma solidity ^0.6.0"')
})
.openFile('new_contract_2.sol')
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('pragma solidity ^0.8.0') !== -1, 'content does not contain "pragma solidity ^0.8.0"')
})
.openFile('testing.txt')
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('test') !== -1, 'content does not contain "test"')
})
},
'Should execute `readFile` api from file manager external api #group2': function (browser: NightwatchBrowser) {
browser
.addFile('writeFile.js', { content: executeWriteFile })
@ -143,6 +162,14 @@ const executeWriteFile = `
run()
`
const executeWriteMultipleFiles = `
const run = async () => {
await remix.call('fileManager', 'writeMultipleFiles', ['contracts/new_contract_1.sol', 'new_contract_2.sol', 'testing.txt'], ['pragma solidity ^0.6.0', 'pragma solidity ^0.8.0', 'test'], '/')
}
run()
`
const executeReadFile = `
const run = async () => {
const result = await remix.call('fileManager', 'readFile', 'new_contract.sol')

@ -225,23 +225,25 @@ class FileManager extends Plugin {
* @param {string} folderPath base folder path
* @returns {void}
*/
async writeMultipleFiles(filePaths, fileData, folderPath) {
async writeMultipleFiles(filePaths: string[], fileData: string[], folderPath: string) {
if (this.currentRequest) {
const canCall = await this.askUserPermission(`writeFile`, `will write multiple files to ${folderPath}...`)
const required = this.appManager.isRequired(this.currentRequest.from)
if (canCall && !required) {
this.call('notification', 'toast', fileChangedToastMsg(this.currentRequest.from, folderPath))
}
}
try {
let alert = true
for (let i = 0; i < filePaths.length; i++) {
const installPath = folderPath + "/" + filePaths[i]
let path = this.normalize(installPath)
path = this.limitPluginScope(path)
if (await this.exists(path)) {
await this._handleIsFile(path, `Cannot write file ${path}`)
await this.setMultipleFileContent(path, fileData[i], folderPath, alert)
} else {
await this.setMultipleFileContent(path, fileData[i], folderPath, alert)
if (!await this.exists(path)) {
await this._setFileInternal(path, fileData[i])
this.emit('fileAdded', path)
}
alert = false
}
} catch (e) {
throw new Error(e)
@ -603,18 +605,6 @@ class FileManager extends Plugin {
return await this._setFileInternal(path, content)
}
async setMultipleFileContent(path, content, folderPath, alert) {
if (this.currentRequest) {
const canCall = await this.askUserPermission(`writeFile`, `modifying ${folderPath} ...`)
const required = this.appManager.isRequired(this.currentRequest.from)
if (canCall && !required && alert) {
// inform the user about modification after permission is granted and even if permission was saved before
this.call('notification', 'toast', fileChangedToastMsg(this.currentRequest.from, folderPath))
}
}
return await this._setFileInternal(path, content)
}
_setFileInternal(path, content) {
const provider = this.fileProviderOf(path)
if (!provider) throw createError({ code: 'ENOENT', message: `${path} not available` })

@ -3928,7 +3928,8 @@ input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-
padding:1.25rem
}
.card-title {
margin-bottom:.75rem
margin-bottom:.75rem;
color: var(--text);
}
.card-subtitle {
margin-top:-.375rem;

@ -3929,7 +3929,8 @@ input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-
padding:1.25rem
}
.card-title {
margin-bottom:.75rem
margin-bottom:.75rem;
color: var(--text);
}
.card-subtitle {
margin-top:-.375rem;

@ -3395,7 +3395,8 @@ input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-
-ms-flex:1 1 auto; flex:1 1 auto; min-height:1px; padding:1.25rem
}
.card-title {
margin-bottom:.75rem
margin-bottom:.75rem;
color: var(--text);
}
.card-subtitle {
margin-top:-.375rem; margin-bottom:0

@ -3931,7 +3931,8 @@ input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-
padding:1.25rem
}
.card-title {
margin-bottom:.75rem
margin-bottom:.75rem;
color: var(--text);
}
.card-subtitle {
margin-top:-.375rem;

@ -4371,6 +4371,7 @@ input[type="button"].btn-block {
.card-title {
margin-bottom: 0.75rem;
color: var(--text);
}
.card-subtitle {

@ -4367,6 +4367,7 @@ input[type="button"].btn-block {
.card-title {
margin-bottom: 0.75rem;
color: var(--text);
}
.card-subtitle {

@ -4373,6 +4373,7 @@ input[type="button"].btn-block {
.card-title {
margin-bottom: 0.75rem;
color: var(--text);
}
.card-subtitle {

@ -4371,6 +4371,7 @@ input[type="button"].btn-block {
.card-title {
margin-bottom: 0.75rem;
color: var(--text);
}
.card-subtitle {

@ -4367,6 +4367,7 @@ input[type="button"].btn-block {
.card-title {
margin-bottom: 0.75rem;
color: var(--text);
}
.card-subtitle {

Loading…
Cancel
Save