From 841e76a0c8143c613d4eafc888b1d7ba3e42a582 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 11 Oct 2023 11:45:17 +0200 Subject: [PATCH 1/6] fix method write multiple --- apps/remix-ide/src/app/files/fileManager.ts | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 00ecb3b4e0..ad5a1075d4 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -226,6 +226,13 @@ class FileManager extends Plugin { * @returns {void} */ async writeMultipleFiles(filePaths, fileData, folderPath) { + 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++) { @@ -234,11 +241,8 @@ class FileManager extends Plugin { 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 @@ -603,18 +607,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` }) From a2e2a5212b1cd0f22c215d55611d0e9f634cbcc1 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 11 Oct 2023 11:55:36 +0200 Subject: [PATCH 2/6] add test --- .../src/tests/fileManager_api.test.ts | 27 +++++++++++++++++++ apps/remix-ide/src/app/files/fileManager.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts b/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts index 26a2e7cffd..229af6a645 100644 --- a/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts @@ -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('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', ['new_contract_1.sol', 'new_contract_2.sol', 'testing.txt'], ['pragma solidity ^0.6.0', 'pragma solidity ^0.80', 'test'], '/') + } + + run() +` + const executeReadFile = ` const run = async () => { const result = await remix.call('fileManager', 'readFile', 'new_contract.sol') diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index ad5a1075d4..b09417ab8c 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -225,7 +225,7 @@ 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) From fc4a6d521b9888306ee6e62e13242c9704744177 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 11 Oct 2023 11:59:35 +0200 Subject: [PATCH 3/6] fix test --- apps/remix-ide-e2e/src/tests/fileManager_api.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts b/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts index 229af6a645..38d1cfc5c1 100644 --- a/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/fileManager_api.test.ts @@ -47,7 +47,7 @@ module.exports = { .addFile('writeMultipleFiles.js', { content: executeWriteMultipleFiles }) .executeScriptInTerminal('remix.exeCurrent()') .pause(2000) - .openFile('new_contract_1.sol') + .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"') }) @@ -164,7 +164,7 @@ const executeWriteFile = ` const executeWriteMultipleFiles = ` const run = async () => { - await remix.call('fileManager', 'writeMultipleFiles', ['new_contract_1.sol', 'new_contract_2.sol', 'testing.txt'], ['pragma solidity ^0.6.0', 'pragma solidity ^0.80', 'test'], '/') + 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() From 77b97042a83bddced7ff1034907f31440d107972 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 11 Oct 2023 20:42:44 +0200 Subject: [PATCH 4/6] Update fileManager.ts --- apps/remix-ide/src/app/files/fileManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index b09417ab8c..8da20ea184 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -234,7 +234,6 @@ class FileManager extends Plugin { } } try { - let alert = true for (let i = 0; i < filePaths.length; i++) { const installPath = folderPath + "/" + filePaths[i] From 20d8075c7eb5e50d802d1c158be7bbf58641ad94 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 11 Oct 2023 21:05:55 +0200 Subject: [PATCH 5/6] Update fileManager.ts --- apps/remix-ide/src/app/files/fileManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 8da20ea184..cb4d5505af 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -244,7 +244,6 @@ class FileManager extends Plugin { await this._setFileInternal(path, fileData[i]) this.emit('fileAdded', path) } - alert = false } } catch (e) { throw new Error(e) From 3f725f6b624a947e17d23165fb848ac0f65bb539 Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 10 Oct 2023 11:34:10 +0200 Subject: [PATCH 6/6] card-titles color for all themes --- .../remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css | 3 ++- apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css | 3 ++- apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css | 3 ++- .../remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css | 3 ++- apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css | 1 + apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css | 1 + .../src/assets/css/themes/remix-midcentury_hrzph3.css | 1 + apps/remix-ide/src/assets/css/themes/remix-unicorn.css | 1 + apps/remix-ide/src/assets/css/themes/remix-violet.css | 1 + 9 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css index f46677c2aa..1bfee425c4 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-cerulean.min.css @@ -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; diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css index 8a43b26912..52e76c75f6 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css @@ -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; diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css index 30a639ca4d..19e49b7056 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css @@ -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 diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css index 99373822eb..7eb2d90e25 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css @@ -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; diff --git a/apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css b/apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css index 99e367a625..c30c7e0aba 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css +++ b/apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css @@ -4371,6 +4371,7 @@ input[type="button"].btn-block { .card-title { margin-bottom: 0.75rem; + color: var(--text); } .card-subtitle { diff --git a/apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css b/apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css index 8ba6a88f05..c44e0a927c 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css +++ b/apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css @@ -4367,6 +4367,7 @@ input[type="button"].btn-block { .card-title { margin-bottom: 0.75rem; + color: var(--text); } .card-subtitle { diff --git a/apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css b/apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css index 5df1a16a34..f9005585b4 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css +++ b/apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css @@ -4373,6 +4373,7 @@ input[type="button"].btn-block { .card-title { margin-bottom: 0.75rem; + color: var(--text); } .card-subtitle { diff --git a/apps/remix-ide/src/assets/css/themes/remix-unicorn.css b/apps/remix-ide/src/assets/css/themes/remix-unicorn.css index cf627d02c0..9055f297a6 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-unicorn.css +++ b/apps/remix-ide/src/assets/css/themes/remix-unicorn.css @@ -4371,6 +4371,7 @@ input[type="button"].btn-block { .card-title { margin-bottom: 0.75rem; + color: var(--text); } .card-subtitle { diff --git a/apps/remix-ide/src/assets/css/themes/remix-violet.css b/apps/remix-ide/src/assets/css/themes/remix-violet.css index 0b3f629e81..fab11de9fb 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-violet.css +++ b/apps/remix-ide/src/assets/css/themes/remix-violet.css @@ -4367,6 +4367,7 @@ input[type="button"].btn-block { .card-title { margin-bottom: 0.75rem; + color: var(--text); } .card-subtitle {