diff --git a/apps/remix-ide-e2e/src/tests/homeTab.test.ts b/apps/remix-ide-e2e/src/tests/homeTab.test.ts index 3f70c1b98f..810ae1d2cd 100644 --- a/apps/remix-ide-e2e/src/tests/homeTab.test.ts +++ b/apps/remix-ide-e2e/src/tests/homeTab.test.ts @@ -28,8 +28,8 @@ module.exports = { 'Should start with ERC20 workspace #group1': function (browser: NightwatchBrowser) { browser .click('*[data-path="home"') - .waitForElementVisible('*[data-id="homeTabGetStartedERC20"]') - .click('*[data-id="homeTabGetStartederc20"') + .waitForElementVisible('*[data-id="homeTabGetStartedozerc20"]') + .click('*[data-id="homeTabGetStartedozerc20"') .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]') .waitForElementVisible('*[data-id="treeViewDivtreeViewItemtests/MyToken_test.sol"]') .click('*[data-id="treeViewDivtreeViewItemtests/MyToken_test.sol"]') diff --git a/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts b/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts index 98156e3074..d2dbe89f21 100644 --- a/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts +++ b/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts @@ -3,9 +3,9 @@ import { NightwatchBrowser } from 'nightwatch' import init from '../helpers/init' const testData = { - validURL: 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol', + validURL: 'https://github.com/remix-project-org/git-hometab-test.git', invalidURL: 'https://github.com/Oppelin/Roles.sol', - JSON: 'https://github.com/ethereum/remix-project/blob/master/package.json' + JSON: 'https://github.com/remix-project-org/git-hometab-test.git' } module.exports = { @@ -23,62 +23,52 @@ module.exports = { .pause(1000) .click('button[data-id="landingPageImportFromGitHubButton"]') .waitForElementVisible('*[data-id="fileSystemModalDialogModalTitle-react"]') - .assert.containsText('*[data-id="homeTabModalDialogModalTitle-react"]', 'Import from GitHub') + .assert.containsText('*[data-id="fileSystemModalDialogModalTitle-react"]', 'Clone Git Repository') .waitForElementVisible('*[data-id="fileSystemModalDialogModalBody-react"]') - .assert.containsText('*[data-id="fileSystemModalDialogModalBody-react"]', 'Enter the github URL you would like to load.') .waitForElementVisible('input[data-id="modalDialogCustomPromptTextClone"]') }, 'Display Error Message For Invalid GitHub URL Modal #group1': function (browser: NightwatchBrowser) { browser .execute(() => { - (document.querySelector('input[data-id="homeTabModalDialogCustomPromptText"]') as any).focus() + (document.querySelector('input[data-id="modalDialogCustomPromptTextClone"]') as any).focus() }, [], () => { }) - .setValue('input[data-id="homeTabModalDialogCustomPromptText"]', testData.invalidURL) - .waitForElementVisible('*[data-id="cloneGitRepositoryModalDialogModalFooter-react"]') - .click('[data-id="cloneGitRepository-modal-footer-ok-react"]') // submitted + .setValue('input[data-id="modalDialogCustomPromptTextClone"]', testData.invalidURL) + .waitForElementVisible('*[data-id="fileSystemModalDialogModalFooter-react"]') + .click('[data-id="fileSystem-modal-footer-ok-react"]') // submitted //.waitForElementVisible('*[data-shared="tooltipPopup"]') //.waitForElementContainsText('*[data-shared="tooltipPopup"] span', 'not found ' + testData.invalidURL) }, - 'Import From GitHub For Valid URL #group2': function (browser: NightwatchBrowser) { + 'Clone From GitHub with Valid URL #group2': function (browser: NightwatchBrowser) { browser .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) .clickLaunchIcon('filePanel') .click('div[data-id="verticalIconsHomeIcon"]') .waitForElementVisible('button[data-id="landingPageImportFromGitHubButton"]').pause(1000) .click('button[data-id="landingPageImportFromGitHubButton"]') - .waitForElementVisible('input[data-id="homeTabModalDialogCustomPromptText"]') + .waitForElementVisible('input[data-id="modalDialogCustomPromptTextClone"]') .execute(() => { - (document.querySelector('input[data-id="homeTabModalDialogCustomPromptText"]') as any).focus() + (document.querySelector('input[data-id="modalDialogCustomPromptTextClone"]') as any).focus() }, [], () => { }) - .clearValue('input[data-id="homeTabModalDialogCustomPromptText"]').pause(1000) - .setValue('input[data-id="homeTabModalDialogCustomPromptText"]', testData.validURL) - .waitForElementVisible('*[data-id="homeTab-modal-footer-ok-react"]') - .click('[data-id="homeTab-modal-footer-ok-react"]') - .openFile('github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol') + .clearValue('input[data-id="modalDialogCustomPromptTextClone"]').pause(1000) + .setValue('input[data-id="modalDialogCustomPromptTextClone"]', testData.validURL) + .waitForElementVisible('*[data-id="fileSystem-modal-footer-ok-react"]') + .click('[data-id="fileSystem-modal-footer-ok-react"]') + .openFile('Roles.sol') .waitForElementVisible({ - selector: `//*[@data-id='tab-active' and @data-path="default_workspace/github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol"]`, + selector: `//*[@data-id='tab-active' and @data-path="git-hometab-test.git/Roles.sol"]`, locateStrategy: 'xpath' }) .getEditorValue((content) => { browser.assert.ok(content.indexOf('library Roles {') !== -1, 'content does contain "library Roles {"') }) }, - 'Import JSON From GitHub For Valid URL #group2': function (browser: NightwatchBrowser) { + 'Confirm JSON After Cloning From GitHub For Valid URL #group2': function (browser: NightwatchBrowser) { browser .click('div[data-id="verticalIconsHomeIcon"]') - .click('button[data-id="landingPageImportFromGitHubButton"]') - .waitForElementVisible('input[data-id="homeTabModalDialogCustomPromptText"]').pause(1000) - .execute(() => { - (document.querySelector('input[data-id="homeTabModalDialogCustomPromptText"]') as any).focus() - }, [], () => { }) - .clearValue('input[data-id="homeTabModalDialogCustomPromptText"]').pause(1000) - .setValue('input[data-id="homeTabModalDialogCustomPromptText"]', testData.JSON) - .waitForElementVisible('*[data-id="homeTab-modal-footer-ok-react"]') - .click('[data-id="homeTab-modal-footer-ok-react"]') - .openFile('github/ethereum/remix-project/package.json') - .waitForElementVisible("div[data-path='default_workspace/github/ethereum/remix-project/package.json'") + .openFile('package.json') + .waitForElementVisible("*[data-path='git-hometab-test.git/package.json'") .getEditorValue((content) => { browser.assert.ok(content.indexOf('"name": "remix-project",') !== -1, 'content does contain "name": "remix-project"') }) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index f4f0e57836..2a0853d20a 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -11,21 +11,6 @@ interface HomeTabFileProps { plugin: any } -const loadingInitialState = { - tooltip: '', - showModalDialog: false, - importSource: '', -} - -const loadingReducer = (state = loadingInitialState, action) => { - return { - ...state, - tooltip: action.tooltip, - showModalDialog: false, - importSource: '', - } -} - function HomeTabFile({ plugin }: HomeTabFileProps) { const [state, setState] = useState<{ searchInput: string @@ -48,10 +33,6 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { recentWorkspaces: [], }) - const [, dispatch] = useReducer(loadingReducer, loadingInitialState) - - const inputValue = useRef(null) - useEffect(() => { plugin.on('filePanel', 'setWorkspace', async () => { let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) @@ -91,41 +72,6 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { } }, [plugin]) - const processLoading = (type: string) => { - _paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type]) - const contentImport = plugin.contentImport - const workspace = plugin.fileManager.getProvider('workspace') - const startsWith = state.importSource.substring(0, 4) - - if ((type === 'ipfs' || type === 'IPFS') && startsWith !== 'ipfs' && startsWith !== 'IPFS') { - setState((prevState) => { - return { ...prevState, importSource: startsWith + state.importSource } - }) - } - contentImport.import( - state.modalInfo.prefix + state.importSource, - (loadingMsg) => dispatch({ tooltip: loadingMsg }), - async (error, content, cleanUrl, type, url) => { - if (error) { - toast(error.message || error) - } else { - try { - if (await workspace.exists(type + '/' + cleanUrl)) toast('File already exists in workspace') - else { - workspace.addExternal(type + '/' + cleanUrl, content, url) - plugin.call('menuicons', 'select', 'filePanel') - } - } catch (e) { - toast(e.message) - } - } - } - ) - setState((prevState) => { - return { ...prevState, showModalDialog: false, importSource: '' } - }) - } - const toast = (message: string) => { setState((prevState) => { return { ...prevState, toasterMsg: message } @@ -180,74 +126,16 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { plugin.verticalIcons.select('filePanel') } - const showFullMessage = (title: string, loadItem: string, examples: Array, prefix = '') => { - setState((prevState) => { - return { - ...prevState, - showModalDialog: true, - modalInfo: { - title: title, - loadItem: loadItem, - examples: examples, - prefix, - }, - } - }) - } - - const hideFullMessage = () => { - //eslint-disable-line - setState((prevState) => { - return { ...prevState, showModalDialog: false, importSource: '' } - }) - } - const handleSwichToRecentWorkspace = async (e, workspaceName) => { e.preventDefault() _paq.push(['trackEvent', 'hometab', 'filesSection', 'loadRecentWorkspace']) await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) } - const examples = state.modalInfo.examples.map((urlEl, key) => ( -
- {urlEl} -
- )) - return ( <> - hideFullMessage()} - okFn={() => processLoading(state.modalInfo.title)}> -
- {state.modalInfo.loadItem !== '' && Enter the {state.modalInfo.loadItem} you would like to load.} - {state.modalInfo.examples.length !== 0 && ( - <> -
e.g
-
{examples}
- - )} -
- {state.modalInfo.prefix && ipfs://} - { - setState((prevState) => { - return { ...prevState, importSource: inputValue.current.value } - }) - }} - /> -
-
-
-
+
{(state.recentWorkspaces[0] || state.recentWorkspaces[1] || state.recentWorkspaces[2]) && (
@@ -272,7 +160,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
)}
-
+