From 8814d702573596acd08fe2843c57aeb16147c591 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 30 May 2022 14:35:06 +0100 Subject: [PATCH 01/25] Tooltip clone UI --- .../src/lib/components/tooltipInput.tsx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx diff --git a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx new file mode 100644 index 0000000000..443e98dbdd --- /dev/null +++ b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx @@ -0,0 +1,32 @@ +import React, { useState } from 'react' +import { ButtonGroup, Dropdown } from 'react-bootstrap' + +export function DeployButton (props: DeployButtonProps) { + const [showOptions, setShowOptions] = useState(false) + + const toggleOptions = () => { + setShowOptions(!showOptions) + } + + return ( + <> + { props.deployOptions && (props.deployOptions || []).length > 0 ? + + + + + { + (props.deployOptions).map(({ title, active }, index) => { + props.setSelectedIndex(index) + toggleOptions() + }} key={index}> { props.selectedIndex === index ? ✓ {title} : {title} }) + } + + : + + } + + ) +} \ No newline at end of file From 9f02554e0ecb5547c1e5e8918a31f71d5ab66a57 Mon Sep 17 00:00:00 2001 From: David Disu Date: Thu, 2 Jun 2022 10:16:00 +0100 Subject: [PATCH 02/25] Use custom icon --- .../src/lib/components/tooltipInput.tsx | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx index 443e98dbdd..873e798f19 100644 --- a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx +++ b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx @@ -1,32 +1,53 @@ -import React, { useState } from 'react' -import { ButtonGroup, Dropdown } from 'react-bootstrap' +import React, { ReactNode, Ref } from 'react' +import { Dropdown, FormControl } from 'react-bootstrap' -export function DeployButton (props: DeployButtonProps) { - const [showOptions, setShowOptions] = useState(false) +// The forwardRef is important!! +// Dropdown needs access to the DOM node in order to position the Menu +const CustomToggle = React.forwardRef(({ children, onClick }: { children?: ReactNode, onClick: (e) => void }, ref: Ref) => ( + { + e.preventDefault() + onClick(e) + }} + > + {children} + +)) - const toggleOptions = () => { - setShowOptions(!showOptions) - } +export const cloneWorkspace = () => { return ( - <> - { props.deployOptions && (props.deployOptions || []).length > 0 ? - - - - - { - (props.deployOptions).map(({ title, active }, index) => { - props.setSelectedIndex(index) - toggleOptions() - }} key={index}> { props.selectedIndex === index ? ✓ {title} : {title} }) - } - - : - - } - + + + {}} + className='far fa-upload remixui_menuicon' + title='Restore Workspaces Backup'> + + + + + {/* + setValue(e.target.value)} + value={value} + /> + */} + {}} + value='' + /> + + ) } \ No newline at end of file From f5812938475e315ba5193b9260fb6e050c428988 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 6 Jun 2022 15:20:45 +0100 Subject: [PATCH 03/25] Added clone icon --- .../workspace/src/lib/components/tooltipInput.tsx | 14 ++++---------- .../workspace/src/lib/remix-ui-workspace.tsx | 2 ++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx index 873e798f19..8c1afe28c7 100644 --- a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx +++ b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx @@ -12,22 +12,16 @@ const CustomToggle = React.forwardRef(({ children, onClick }: { children?: React onClick(e) }} > - {children} + { children } )) -export const cloneWorkspace = () => { +export const CloneWorkspace = () => { return ( - + - {}} - className='far fa-upload remixui_menuicon' - title='Restore Workspaces Backup'> - + diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 98a80306bd..be299b9b96 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint import { FileExplorer } from './components/file-explorer' // eslint-disable-line import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' +import { CloneWorkspace } from './components/tooltipInput' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -214,6 +215,7 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> + switchWorkspace(e.target.value)} className="form-control custom-select"> { global.fs.browser.workspaces From 57b463ec2e4f00fa3160e19b64a959e289da3823 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 13 Jun 2022 12:32:32 +0100 Subject: [PATCH 05/25] Cleanup clone tooltip UI --- .../workspace/src/lib/components/clone.tsx | 23 +++++++++ .../src/lib/components/tooltipInput.tsx | 50 ------------------- .../src/lib/css/remix-ui-workspace.css | 23 ++++++++- .../workspace/src/lib/remix-ui-workspace.tsx | 4 +- 4 files changed, 47 insertions(+), 53 deletions(-) create mode 100644 libs/remix-ui/workspace/src/lib/components/clone.tsx delete mode 100644 libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx new file mode 100644 index 0000000000..4972fbe68f --- /dev/null +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import { OverlayTrigger, Popover } from 'react-bootstrap'; + +const popover = ( + + Clone workspace + +
+ +
+
+
+) + +export const CloneWorkspace = () => ( + + + +) diff --git a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx b/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx deleted file mode 100644 index b67ca5318c..0000000000 --- a/libs/remix-ui/workspace/src/lib/components/tooltipInput.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React, { ReactNode, Ref } from 'react' -import { Dropdown, FormControl } from 'react-bootstrap' - -// The forwardRef is important!! -// Dropdown needs access to the DOM node in order to position the Menu -const CustomToggle = React.forwardRef(({ children, onClick }: { children?: ReactNode, onClick: (e) => void }, ref: Ref) => ( - { - e.preventDefault() - onClick(e) - }} - > - { children } - -)) - -export const CloneWorkspace = () => { - - return ( - - - - - - - {/* - setValue(e.target.value)} - value={value} - /> - */} -
- {}} - value='' - /> -
- -
-
- ) -} \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css index 62a557f8cf..856599f681 100644 --- a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css +++ b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css @@ -62,4 +62,25 @@ .remixui_menuicon:hover { transform: scale(1.3); } - \ No newline at end of file + .remixui_cloneContainer { + display: flex; + align-items: center; + height: 32px; + } + + .remixui_cloneContainer input { + height: 32px; + border-top-left-radius: 0 !important; + border-bottom-left-radius: 0 !important; + width: 250px; + font-size: 10px !important; + padding: .25rem; + } + + .remixui_menuicon .bs-popover-auto[x-placement^="bottom"] .popover-header::before, .bs-popover-bottom .popover-header::before { + border-bottom-color: var(--dark) !important + } + + .remixui_menuicon .bs-popover-auto[x-placement^="bottom"] > .arrow::after, .bs-popover-bottom > .arrow::after { + border-bottom-color: var(--dark) !important + } \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 19dcf694ea..95e1929cc0 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint import { FileExplorer } from './components/file-explorer' // eslint-disable-line import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' -import { CloneWorkspace } from './components/tooltipInput' +import { CloneWorkspace } from './components/clone' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -218,7 +218,7 @@ export function Workspace () { - + handleChangeTokenState(e)} value={ githubToken } /> +
+ +
+ + +
+ +
+ handleChangeUserNameState(e)} value={ githubUserName } /> +
+
+
+ +
+ handleChangeEmailState(e)} value={ githubEmail } /> +
+ + +
+
+
+ + + ) +} \ No newline at end of file diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 2de3ecd67b..7b112eef9c 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -8,6 +8,7 @@ import { ethereumVM, generateContractMetadat, personal, textWrapEventAction, use import { initialState, toastInitialState, toastReducer, settingReducer } from './settingsReducer' import { Toaster } from '@remix-ui/toaster'// eslint-disable-line import { RemixUiThemeModule, ThemeModule} from '@remix-ui/theme-module' +import { GithubSettings } from './github-settings' /* eslint-disable-next-line */ export interface RemixUiSettingsProps { @@ -347,7 +348,10 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
{state.message ? : null} {generalConfig()} - {token('gist')} + { saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") }} + removeTokenToast={() => { removeTokenToast(props.config, dispatchToast, "gist-access-token") }} + /> {token('etherscan')} {swarmSettings()} {ipfsSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts new file mode 100644 index 0000000000..827820b870 --- /dev/null +++ b/libs/remix-ui/settings/src/types/index.ts @@ -0,0 +1,4 @@ +export interface GithubSettingsProps { + saveTokenToast: (githubToken: string) => void, + removeTokenToast: () => void +} diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index 4972fbe68f..f6f4bf49df 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -2,7 +2,7 @@ import React from 'react' import { OverlayTrigger, Popover } from 'react-bootstrap'; const popover = ( - + Clone workspace
@@ -17,7 +17,7 @@ const popover = ( ) export const CloneWorkspace = () => ( - + ) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 95e1929cc0..c4d0e4d5f6 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -218,7 +218,7 @@ export function Workspace () { - +
handleChangeTokenState(e)} value={ githubToken } />
- +
diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 7b112eef9c..62d1e07cfb 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -349,8 +349,16 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { {state.message ? : null} {generalConfig()} { saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") }} - removeTokenToast={() => { removeTokenToast(props.config, dispatchToast, "gist-access-token") }} + saveTokenToast={(githubToken: string, githubUserName: string, githubEmail: string) => { + saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") + saveTokenToast(props.config, dispatchToast, githubUserName, "github-user-name") + saveTokenToast(props.config, dispatchToast, githubEmail, "github-email") + }} + removeTokenToast={() => { + removeTokenToast(props.config, dispatchToast, "gist-access-token") + removeTokenToast(props.config, dispatchToast, "github-user-name") + removeTokenToast(props.config, dispatchToast, "github-email") + }} /> {token('etherscan')} {swarmSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts index 827820b870..b9f3fcfbd3 100644 --- a/libs/remix-ui/settings/src/types/index.ts +++ b/libs/remix-ui/settings/src/types/index.ts @@ -1,4 +1,4 @@ export interface GithubSettingsProps { - saveTokenToast: (githubToken: string) => void, + saveTokenToast: (githubToken: string, githubUserName: string, githubEmail: string) => void, removeTokenToast: () => void } diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index f6f4bf49df..fa92552b22 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -3,21 +3,21 @@ import { OverlayTrigger, Popover } from 'react-bootstrap'; const popover = ( - Clone workspace + Clone Repository
) -export const CloneWorkspace = () => ( - - +export const CloneRepository = () => ( + + ) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index c4d0e4d5f6..40779306ee 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint import { FileExplorer } from './components/file-explorer' // eslint-disable-line import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' -import { CloneWorkspace } from './components/clone' +import { CloneRepository } from './components/clone' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -159,7 +159,6 @@ export function Workspace () { -
+ - - - -
handleChangeUserNameState(e)} value={ githubUserName } /> + handleChangeUserNameState(e)} value={ githubUserName } />
- handleChangeEmailState(e)} value={ githubEmail } /> + handleChangeEmailState(e)} value={ githubEmail } />
diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 62d1e07cfb..19655dd281 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -359,6 +359,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { removeTokenToast(props.config, dispatchToast, "github-user-name") removeTokenToast(props.config, dispatchToast, "github-email") }} + config={props.config} /> {token('etherscan')} {swarmSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts index b9f3fcfbd3..5b4af8dfc1 100644 --- a/libs/remix-ui/settings/src/types/index.ts +++ b/libs/remix-ui/settings/src/types/index.ts @@ -1,4 +1,12 @@ export interface GithubSettingsProps { saveTokenToast: (githubToken: string, githubUserName: string, githubEmail: string) => void, - removeTokenToast: () => void + removeTokenToast: () => void, + config: { + exists: (key: string) => boolean, + get: (key: string) => string, + set: (key: string, content: string) => void, + clear: () => void, + getUnpersistedProperty: (key: string) => void, + setUnpersistedProperty: (key: string, value: string) => void + } } diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index fa92552b22..95ec9c6d88 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -18,6 +18,6 @@ const popover = ( export const CloneRepository = () => ( - + ) From 0aa21b2a6a9e2a12f296e963cf47fc3b9d88be16 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 20 Jun 2022 13:38:59 +0100 Subject: [PATCH 09/25] Set clone repository dispatch --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 4 ++++ libs/remix-ui/workspace/src/lib/contexts/index.ts | 3 ++- .../workspace/src/lib/providers/FileSystemProvider.tsx | 9 +++++++-- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 1b73f63cc0..154a9e9968 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -321,3 +321,7 @@ export const getWorkspaces = async (): Promise | undefined => { return workspaces } catch (e) {} } + +export const cloneRepository = async (url: string) => { + console.log('url: ', url) +} diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 792bed8188..1bd33c2529 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -29,5 +29,6 @@ export const FileSystemContext = createContext<{ dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise dispatchHandleExpandPath: (paths: string[]) => Promise, dispatchHandleDownloadFiles: () => Promise, - dispatchHandleRestoreBackup: () => Promise + dispatchHandleRestoreBackup: () => Promise, + dispatchCloneRepository: (url: string) => Promise }>(null) diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index fab8e652b5..86f4cccaf2 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line // eslint-disable-next-line @typescript-eslint/no-unused-vars import { FileSystemContext } from '../contexts' import { browserReducer, browserInitialState } from '../reducers/workspace' -import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip } from '../actions' +import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip, cloneRepository } from '../actions' import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types' // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Workspace } from '../remix-ui-workspace' @@ -123,6 +123,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await restoreBackupZip() } + const dispatchCloneRepository = async (url: string) => { + await cloneRepository(url) + } + useEffect(() => { dispatchInitWorkspace() }, []) @@ -224,7 +228,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => { dispatchHandleClickFile, dispatchHandleExpandPath, dispatchHandleDownloadFiles, - dispatchHandleRestoreBackup + dispatchHandleRestoreBackup, + dispatchCloneRepository } return ( diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 40779306ee..0cf5b93feb 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -215,7 +215,8 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - + + -
- - -) - -export const CloneRepository = () => ( - - - -) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0cf5b93feb..f70bf31612 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -1,8 +1,8 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line import { FileExplorer } from './components/file-explorer' // eslint-disable-line -import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' -import { CloneRepository } from './components/clone' +import { TooltipPopup } from '@remix-ui/tooltip-popup' +import './css/remix-ui-workspace.css' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -14,6 +14,7 @@ export function Workspace () { const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() const workspaceCreateTemplateInput = useRef() + const cloneUrlRef = useRef() useEffect(() => { resetFocus() @@ -125,6 +126,18 @@ export function Workspace () { workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` } + const handleTypingUrl = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + const url = cloneUrlRef.current.value + + if (url) { + global.dispatchCloneRepository() + } else { + console.log('Please provide a valid github repository url.') + } + } + } + const createModalMessage = () => { return ( <> @@ -215,8 +228,17 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - - + +
+ +
+
+ + ) + } + return (
@@ -228,17 +237,16 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - -
- -
-
+ { + e.stopPropagation() + cloneGitRepository() + }} + className='far fa-clone remixui_menuicon' + title='Clone Git Repository'> + switchWorkspace(e.target.value)} className="form-control custom-select"> + {/* { + const { code, title } = [{ code: 'NG', title: 'Nigeria' }].find(({ code }) => value === code) + + setSelectedCountry(value) + setToggleContents(<> {title}) + }} + > + + {toggleContents} + + + + {[{ code: 'NG', title: 'Nigeria' }].map(({ code, title }) => ( + {title} + ))} + + */} + switchWorkspace(e.target.value)} className="form-select"> - { - global.fs.browser.workspaces - .map((folder, index) => { - return - }) - } - - { global.fs.browser.workspaces.length <= 0 && } - +
From 9edfd398c88b29393eba6f86a5e04f9f6c45a5be Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 11:45:01 +0100 Subject: [PATCH 15/25] Clone cleanup --- apps/remix-ide/src/app/files/dgitProvider.js | 13 ++-- .../workspace/src/lib/actions/index.ts | 5 +- .../workspace/src/lib/actions/payload.ts | 18 +++++ .../workspace/src/lib/actions/workspace.ts | 26 +++++-- .../workspace/src/lib/reducers/workspace.ts | 58 ++++++++++++++-- .../workspace/src/lib/remix-ui-workspace.tsx | 68 ++++++++++--------- 6 files changed, 135 insertions(+), 53 deletions(-) diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index d4a1a26c8c..8b5ce925c5 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -233,12 +233,11 @@ class DGitProvider extends Plugin { return this.calculateLocalStorage() } - async clone (input, workspaceName) { + async clone (input, workspaceName, workspaceExists = false) { const permission = await this.askUserPermission('clone', 'Import multiple files into your workspaces.') if (!permission) return false if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.') - await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) - + if (!workspaceExists) await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) const cmd = { url: input.url, singleBranch: input.singleBranch, @@ -249,9 +248,11 @@ class DGitProvider extends Plugin { } const result = await git.clone(cmd) - setTimeout(async () => { - await this.call('fileManager', 'refresh') - }, 1000) + if (!workspaceExists) { + setTimeout(async () => { + await this.call('fileManager', 'refresh') + }, 1000) + } return result } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 460aa1d1f8..7a5387474b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -33,9 +33,10 @@ const basicWorkspaceInit = async (workspaces: { name: string; isGitRepo: boolean } else { if (workspaces.length > 0) { const workspace = workspaces[workspaces.length - 1] + const workspaceName = (workspace || {}).name - workspaceProvider.setWorkspace(workspace.name) - plugin.setWorkspace({ name: (workspace || {}).name, isLocalhost: false }) + workspaceProvider.setWorkspace(workspaceName) + plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) dispatch(setCurrentWorkspace(workspace)) } } diff --git a/libs/remix-ui/workspace/src/lib/actions/payload.ts b/libs/remix-ui/workspace/src/lib/actions/payload.ts index 67b45d01f5..b663f60cfe 100644 --- a/libs/remix-ui/workspace/src/lib/actions/payload.ts +++ b/libs/remix-ui/workspace/src/lib/actions/payload.ts @@ -239,3 +239,21 @@ export const fsInitializationCompleted = () => { type: 'FS_INITIALIZATION_COMPLETED' } } + +export const cloneRepositoryRequest = () => { + return { + type: 'CLONE_REPOSITORY_REQUEST' + } +} + +export const cloneRepositorySuccess = () => { + return { + type: 'CLONE_REPOSITORY_SUCCESS' + } +} + +export const cloneRepositoryFailed = () => { + return { + type: 'CLONE_REPOSITORY_FAILED' + } +} diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index b0a3531f1d..ee8ade4f2b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -1,7 +1,7 @@ import React from 'react' import { bufferToHex, keccakFromString } from 'ethereumjs-util' import axios, { AxiosResponse } from 'axios' -import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, displayPopUp, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' +import { addInputFieldSuccess, cloneRepositoryFailed, cloneRepositoryRequest, cloneRepositorySuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, displayPopUp, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' import { checkSlash, checkSpecialChars, createNonClashingTitle } from '@remix-ui/helper' import { JSONStandardInput, WorkspaceTemplate } from '../types' @@ -42,13 +42,13 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?: return promise } -export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void) => { +export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void, isGitRepo: boolean = false) => { await plugin.fileManager.closeAllFiles() const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) dispatch(createWorkspaceRequest(promise)) promise.then(async () => { - dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo: false })) + dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) await plugin.workspaceCreated(workspaceName) @@ -334,12 +334,26 @@ export const cloneRepository = async (url: string) => { const token = config.get('currentFile') const repoConfig = { url, token } const urlArray = url.split('/') - let repoName = urlArray[urlArray.length - 1] + let repoName = urlArray.length > 0 ? urlArray[urlArray.length - 1] : '' try { repoName = await createNonClashingTitle(repoName, plugin.fileManager) - await plugin.call('dGitProvider', 'clone', repoConfig, repoName) - await plugin.call('manager', 'activatePlugin', 'dgit') + await createWorkspace(repoName, 'blank', true, null, true) + const promise = plugin.call('dGitProvider', 'clone', repoConfig, repoName, true) + + dispatch(cloneRepositoryRequest()) + promise.then(async () => { + const isActive = await plugin.call('manager', 'isActive', 'dgit') + + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') + await fetchWorkspaceDirectory(repoName) + dispatch(cloneRepositorySuccess()) + }).catch((e) => { + dispatch(displayNotification('Clone Git Repository', 'An error occured: ' + e, 'Ok', null, async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + })) + }) } catch (e) { dispatch(displayPopUp('An error occured: ' + e)) } diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 36b8497f70..39f56a202f 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -18,6 +18,8 @@ export interface BrowserState { isSuccessfulDirectory: boolean, isRequestingWorkspace: boolean, isSuccessfulWorkspace: boolean, + isRequestingCloning: boolean, + isSuccessfulCloning: boolean, error: string, contextMenu: { registeredMenuItems: action[], @@ -53,8 +55,7 @@ export interface BrowserState { popup: string, focusEdit: string, focusElement: { key: string, type: 'file' | 'folder' | 'gist' }[], - initializingFS: boolean, - isGitRepo: boolean + initializingFS: boolean } export const browserInitialState: BrowserState = { @@ -67,6 +68,8 @@ export const browserInitialState: BrowserState = { isSuccessfulDirectory: false, isRequestingWorkspace: false, isSuccessfulWorkspace: false, + isRequestingCloning: false, + isSuccessfulCloning: false, error: null, contextMenu: { registeredMenuItems: [], @@ -102,8 +105,7 @@ export const browserInitialState: BrowserState = { popup: '', focusEdit: '', focusElement: [], - initializingFS: true, - isGitRepo: false + initializingFS: true } export const browserReducer = (state = browserInitialState, action: Action) => { @@ -451,14 +453,25 @@ export const browserReducer = (state = browserInitialState, action: Action) => { case 'RENAME_WORKSPACE': { const payload = action.payload as { oldName: string, workspaceName: string } - const workspaces = state.browser.workspaces.filter(({ name }) => name && (name !== payload.oldName)) + let renamedWorkspace + const workspaces = state.browser.workspaces.filter(({ name, isGitRepo }) => { + if (name && (name !== payload.oldName)) { + return true + } else { + renamedWorkspace = { + name: payload.workspaceName, + isGitRepo + } + return false + } + }) return { ...state, browser: { ...state.browser, currentWorkspace: payload.workspaceName, - workspaces: [...workspaces, payload.workspaceName], + workspaces: [...workspaces, renamedWorkspace], expandPath: [] } } @@ -597,6 +610,39 @@ export const browserReducer = (state = browserInitialState, action: Action) => { } } + case 'CLONE_REPOSITORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: true, + isSuccessfulCloning: false + } + } + } + + case 'CLONE_REPOSITORY_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: true + } + } + } + + case 'CLONE_REPOSITORY_FAILED': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: false + } + } + } + case 'FS_INITIALIZATION_COMPLETED': { return { ...state, diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0df9b8b53c..e911d9decf 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -290,39 +290,41 @@ export function Workspace () {
-
- { (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && - - } -
+ { global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning ?
+ :
+ { (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && + + } +
+ } { global.fs.localhost.isRequestingLocalhost ?
:
From df655ad3a26440ce31410bef83dfd7c3c094faf0 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 12:07:35 +0100 Subject: [PATCH 16/25] Restore target dependency build --- nx.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nx.json b/nx.json index bec616c17c..13cd26c2b2 100644 --- a/nx.json +++ b/nx.json @@ -173,5 +173,13 @@ "remix-ui-tooltip-popup": { "tags": [] } + }, + "targetDependencies": { + "build": [ + { + "target": "build", + "projects": "dependencies" + } + ] } } From 3631c4186f12802a99360940c79f2116024c8506 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 12:34:45 +0100 Subject: [PATCH 17/25] Restore linting config --- package.json | 2 +- workspace.json | 62 +++++++++++++++++++++++++------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index cced59ff97..54a2b7c8aa 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "workspace-schematic": "nx workspace-schematic", "dep-graph": "nx dep-graph", "help": "nx help", - "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remix-ws-templates,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handler,remix-ui-search", + "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remix-ws-templates,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handler,remix-ui-search,remix-ui-tooltip-popup", "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remix-ws-templates,remixd", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "publish:libs": "yarn run build:libs && lerna publish --skip-git && yarn run bumpVersion:libs", diff --git a/workspace.json b/workspace.json index 9261341d28..4a1f176ac2 100644 --- a/workspace.json +++ b/workspace.json @@ -1,35 +1,5 @@ { "version": 1, - "cli": { - "defaultCollection": "@nrwl/react" - }, - "defaultProject": "remix-ide", - "schematics": { - "@nrwl/workspace": { - "library": { - "linter": "eslint" - } - }, - "@nrwl/react": { - "application": { - "style": "css", - "linter": "eslint", - "babel": true - }, - "component": { - "style": "css" - }, - "library": { - "style": "css", - "linter": "eslint" - } - }, - "@nrwl/nx-plugin": { - "plugin": { - "linter": "eslint" - } - } - }, "projects": { "remix-ide": { "root": "apps/remix-ide", @@ -1299,5 +1269,35 @@ } } } - } + }, + "cli": { + "defaultCollection": "@nrwl/react" + }, + "schematics": { + "@nrwl/workspace": { + "library": { + "linter": "eslint" + } + }, + "@nrwl/react": { + "application": { + "style": "css", + "linter": "eslint", + "babel": true + }, + "component": { + "style": "css" + }, + "library": { + "style": "css", + "linter": "eslint" + } + }, + "@nrwl/nx-plugin": { + "plugin": { + "linter": "eslint" + } + } + }, + "defaultProject": "remix-ide" } From 15dd3cf1edb83ec92e1bf5c87556847e2ba0e9b0 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 14:55:58 +0100 Subject: [PATCH 18/25] Fixed tooltip library eslint config --- workspace.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/workspace.json b/workspace.json index 4a1f176ac2..02a11c683b 100644 --- a/workspace.json +++ b/workspace.json @@ -1260,11 +1260,12 @@ "projectType": "library", "architect": { "lint": { - "builder": "@nrwl/linter:eslint", + "builder": "@nrwl/linter:lint", "options": { - "lintFilePatterns": [ - "libs/remix-ui/tooltip-popup/**/*.{ts,tsx,js,jsx}" - ] + "linter": "eslint", + "config": "libs/remix-ui/tooltip-popup/.eslintrc.json", + "tsConfig": ["libs/remix-ui/tooltip-popup/tsconfig.lib.json"], + "exclude": ["**/node_modules/**"] } } } From 68242913475786065bb135698171ae09b3c22c1a Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 16:09:38 +0100 Subject: [PATCH 19/25] Fixed plugin api test --- .../src/commands/switchWorkspace.ts | 18 ++++++++++++++++++ apps/remix-ide-e2e/src/tests/plugin_api.ts | 8 ++++---- apps/remix-ide-e2e/src/types/index.d.ts | 3 ++- .../workspace/src/lib/remix-ui-workspace.tsx | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 apps/remix-ide-e2e/src/commands/switchWorkspace.ts diff --git a/apps/remix-ide-e2e/src/commands/switchWorkspace.ts b/apps/remix-ide-e2e/src/commands/switchWorkspace.ts new file mode 100644 index 0000000000..6219ddd218 --- /dev/null +++ b/apps/remix-ide-e2e/src/commands/switchWorkspace.ts @@ -0,0 +1,18 @@ +import { NightwatchBrowser } from 'nightwatch' +import EventEmitter from 'events' + +class switchWorkspace extends EventEmitter { + command (this: NightwatchBrowser, workspaceName: string): NightwatchBrowser { + this.api.waitForElementVisible('[data-id="workspacesSelect"]') + .click('[data-id="workspacesSelect"]') + .waitForElementVisible(`[data-id="dropdown-item-${workspaceName}"]`) + .click(`[data-id="dropdown-item-${workspaceName}"]`) + .perform((done) => { + done() + this.emit('complete') + }) + return this + } +} + +module.exports = switchWorkspace diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index 1c21c849ca..f05a2fe130 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -298,25 +298,25 @@ module.exports = { }, null, null) }, 'Should get all workspaces #group2': async function (browser: NightwatchBrowser) { - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['default_workspace', 'emptyworkspace', 'testspace'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"default_workspace",isGitRepo:false}, {name:"emptyworkspace",isGitRepo:false}, {name:"testspace",isGitRepo:false}], null, null) }, 'Should have set workspace event #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:createWorkspace', null, { event: 'setWorkspace', args: [{ name: 'newspace', isLocalhost: false }] }, 'newspace') }, 'Should have event when switching workspace #group2': async function (browser: NightwatchBrowser) { // @ts-ignore - browser.frameParent().useCss().clickLaunchIcon('filePanel').click('*[data-id="workspacesSelect"] option[value="default_workspace"]').useXpath().click('//*[@data-id="verticalIconsKindlocalPlugin"]').frame(0, async () => { + browser.frameParent().useCss().clickLaunchIcon('filePanel').switchWorkspace('default_workspace').useXpath().click('//*[@data-id="verticalIconsKindlocalPlugin"]').frame(0, async () => { await clickAndCheckLog(browser, null, null, { event: 'setWorkspace', args: [{ name: 'default_workspace', isLocalhost: false }] }, null) }) }, 'Should rename workspace #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:renameWorkspace', null, null, ['default_workspace', 'renamed']) - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['emptyworkspace', 'testspace', 'newspace', 'renamed'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"emptyworkspace",isGitRepo:false},{name:"testspace",isGitRepo:false},{name:"newspace",isGitRepo:false},{name:"renamed",isGitRepo:false}], null, null) }, 'Should delete workspace #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:deleteWorkspace', null, null, ['testspace']) - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['emptyworkspace', 'newspace', 'renamed'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"emptyworkspace",isGitRepo:false},{name:"newspace",isGitRepo:false},{name:"renamed",isGitRepo:false}], null, null) }, // DGIT 'Should have changes on new workspace #group3': async function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index f17e6b17de..eccd50bad5 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -62,7 +62,8 @@ declare module 'nightwatch' { clearConsole (this: NightwatchBrowser): NightwatchBrowser clearTransactions (this: NightwatchBrowser): NightwatchBrowser getBrowserLogs (this: NightwatchBrowser): NightwatchBrowser - currentSelectedFileIs (name: string): NightwatchBrowser + currentSelectedFileIs (name: string): NightwatchBrowser, + switchWorkspace: (workspaceName: string) => NightwatchBrowser } export interface NightwatchBrowser { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index e911d9decf..8bbe2a2703 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -262,7 +262,7 @@ export function Workspace () { { selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? 'localhost' : NO_WORKSPACE } - + { global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( { switchWorkspace(name) }} + data-id={`dropdown-item-${name}`} > { isGitRepo ?
From 004dbffc0c4051d58232873b672ea09b729a7837 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 17:44:18 +0100 Subject: [PATCH 20/25] Fixed url test --- .../src/commands/currentWorkspaceIs.ts | 18 +++++++++--------- apps/remix-ide-e2e/src/tests/url.test.ts | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts b/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts index a090735f45..26da9cf9c8 100644 --- a/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts +++ b/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts @@ -3,15 +3,15 @@ import EventEmitter from 'events' class CurrentWorkspaceIs extends EventEmitter { command (this: NightwatchBrowser, name: string): NightwatchBrowser { - this.api - .execute(function () { - const el = document.querySelector('select[data-id="workspacesSelect"]') as HTMLSelectElement - return el.value - }, [], (result) => { - console.log(result) - this.api.assert.equal(result.value, name) - this.emit('complete') - }) + const browser = this.api + + browser.getText('[data-id="workspacesSelect"]', function (result) { + browser.assert.equal(result.value, name) + }) + .perform((done) => { + done() + this.emit('complete') + }) return this } } diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index a201b4ea36..00885338b4 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -29,6 +29,7 @@ module.exports = { .click('[for="autoCompile"]') // we set it too false again .click('[for="autoCompile"]') // back to True in the local storage .assert.containsText('*[data-id="compilerContainerCompileBtn"]', 'contract-76747f6e19.sol') + .clickLaunchIcon('filePanel') .currentWorkspaceIs('code-sample') .getEditorValue((content) => { browser.assert.ok(content && content.indexOf( @@ -57,6 +58,7 @@ module.exports = { .url('http://127.0.0.1:8080/#optimize=true&runs=300&evmVersion=istanbul&version=soljson-v0.7.4+commit.3f05b770.js&url=https://github.com/ethereum/remix-project/blob/master/apps/remix-ide/contracts/app/solidity/mode.sol&code=cHJhZ21hIHNvbGlkaXR5ID49MC42LjAgPDAuNy4wOwoKaW1wb3J0ICJodHRwczovL2dpdGh1Yi5jb20vT3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHMvYmxvYi9tYXN0ZXIvY29udHJhY3RzL2FjY2Vzcy9Pd25hYmxlLnNvbCI7Cgpjb250cmFjdCBHZXRQYWlkIGlzIE93bmFibGUgewogIGZ1bmN0aW9uIHdpdGhkcmF3KCkgZXh0ZXJuYWwgb25seU93bmVyIHsKICB9Cn0') .refresh() // we do one reload for making sure we already have the default workspace .pause(5000) + .clickLaunchIcon('filePanel') .currentWorkspaceIs('code-sample') .getEditorValue((content) => { browser.assert.ok(content && content.indexOf( @@ -113,7 +115,7 @@ module.exports = { .url('http://127.0.0.1:8080/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.6.12+commit.27d51765.js&url=https://raw.githubusercontent.com/EthVM/evm-source-verification/main/contracts/1/0x011e5846975c6463a8c6337eecf3cbf64e328884/input.json') .refresh() .pause(5000) - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="code-sample"]') + .switchWorkspace('code-sample') .openFile('@openzeppelin') .openFile('@openzeppelin/contracts') .openFile('@openzeppelin/contracts/access') From 057b1330fbc8b7d007792f7e2e9ea4a3a7345dd6 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 18:07:19 +0100 Subject: [PATCH 21/25] Fixed solidity unit testing --- apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts index 30a2913891..7e61167107 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts @@ -181,7 +181,7 @@ module.exports = { .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_new' }) .waitForElementVisible('*[data-id="fileSystem-modal-footer-ok-react"]') .execute(function () { (document.querySelector('[data-id="fileSystem-modal-footer-ok-react"]') as HTMLElement).click() }) - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_new"]') + .currentWorkspaceIs('workspace_new') .waitForElementVisible('li[data-id="treeViewLitreeViewItem.deps/remix-tests/remix_tests.sol"]') .waitForElementVisible('li[data-id="treeViewLitreeViewItem.deps/remix-tests/remix_accounts.sol"]') .openFile('.deps/remix-tests/remix_tests.sol') From cb1620fe528255880c72ac24841abdc0ed9c232c Mon Sep 17 00:00:00 2001 From: David Disu Date: Thu, 30 Jun 2022 10:51:29 +0100 Subject: [PATCH 22/25] Fixed e2e tests --- .../src/tests/migrateFileSystem.test.ts | 4 ++-- apps/remix-ide-e2e/src/tests/workspace.test.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts b/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts index 3d04a3edfc..0914f6c2f5 100644 --- a/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts +++ b/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts @@ -81,7 +81,7 @@ module.exports = { // these are test data entries 'Should have a workspace_test #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000) - .click('*[data-id="workspacesSelect"] option[value="workspace_test"]') + .switchWorkspace('workspace_test') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtest_contracts"]') }, 'Should have a sol file with test data #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { @@ -103,7 +103,7 @@ module.exports = { }, 'Should have a empty workspace #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000) - .click('*[data-id="workspacesSelect"] option[value="emptyspace"]') + .switchWorkspace('emptyspace') }, // end of test data entries 'Should load with all storage blocked #group4': function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 95819b7598..aa0d2bbaf1 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -235,7 +235,7 @@ module.exports = { .pause(2000) .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') .pause(2000) - .click('*[data-id="workspacesSelect"] option[value="workspace_name"]') + .switchWorkspace('workspace_name') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]') }, @@ -249,23 +249,23 @@ module.exports = { .setValue('*[data-id="modalDialogCustomPromptTextRename"]', 'workspace_name_renamed') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .click('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') - .click('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .switchWorkspace('workspace_name_1') .pause(2000) .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_name_renamed"]') - .click('*[data-id="workspacesSelect"] option[value="workspace_name_renamed"]') + .switchWorkspace('workspace_name_renamed') .pause(2000) .waitForElementVisible('*[data-id="treeViewLitreeViewItemtest.sol"]') }, 'Should delete a workspace #group1': function (browser: NightwatchBrowser) { browser - .click('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .switchWorkspace('workspace_name_1') .click('*[data-id="workspaceDelete"]') // delete workspace_name_1 .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .click('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .waitForElementNotPresent('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .waitForElementVisible('[data-id="workspacesSelect"]') + .click('[data-id="workspacesSelect"]') + .waitForElementNotPresent(`[data-id="dropdown-item-workspace_name_1"]`) .end() }, From 22a668ccef018ee239d90756d818f457e694fe18 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 14:15:09 +0100 Subject: [PATCH 23/25] Fixed found issues with clone UI --- .../settings/src/lib/github-settings.tsx | 4 ++-- .../settings/src/lib/settingsAction.ts | 4 ++-- .../workspace/src/lib/actions/workspace.ts | 22 ++++++++++++++----- .../workspace/src/lib/remix-ui-workspace.tsx | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/settings/src/lib/github-settings.tsx b/libs/remix-ui/settings/src/lib/github-settings.tsx index a52ca7507d..e7c9c3f2ce 100644 --- a/libs/remix-ui/settings/src/lib/github-settings.tsx +++ b/libs/remix-ui/settings/src/lib/github-settings.tsx @@ -46,8 +46,8 @@ export function GithubSettings (props: GithubSettingsProps) { return (
-
GitHub Access Token
-

Manage the access token used to publish to Gist and retrieve GitHub contents.

+
GitHub Credentials
+

Manage your GitHub credentials used to publish to Gist and retrieve GitHub contents.

Go to github token page (link below) to create a new token and save it in Remix. Make sure this token has only \'create gist\' permission.

https://github.com/settings/tokens

diff --git a/libs/remix-ui/settings/src/lib/settingsAction.ts b/libs/remix-ui/settings/src/lib/settingsAction.ts index b7a7eddd95..fc3bed1f4d 100644 --- a/libs/remix-ui/settings/src/lib/settingsAction.ts +++ b/libs/remix-ui/settings/src/lib/settingsAction.ts @@ -43,12 +43,12 @@ export const useMatomoAnalytics = (config, checked, dispatch) => { export const saveTokenToast = (config, dispatch, tokenValue, key) => { config.set('settings/' + key, tokenValue) - dispatch({ type: 'save', payload: { message: 'Access token has been saved' } }) + dispatch({ type: 'save', payload: { message: 'GitHub credentials updated' } }) } export const removeTokenToast = (config, dispatch, key) => { config.set('settings/' + key, '') - dispatch({ type: 'removed', payload: { message: 'Access token removed' } }) + dispatch({ type: 'removed', payload: { message: 'GitHub credentials removed' } }) } export const saveSwarmSettingsToast = (config, dispatch, privateBeeAddress, postageStampId) => { diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index ee8ade4f2b..12aab6f93d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -331,7 +331,7 @@ export const getWorkspaces = async (): Promise<{name: string, isGitRepo: boolean export const cloneRepository = async (url: string) => { const config = plugin.registry.get('config').api - const token = config.get('currentFile') + const token = config.get('settings/gist-access-token') const repoConfig = { url, token } const urlArray = url.split('/') let repoName = urlArray.length > 0 ? urlArray[urlArray.length - 1] : '' @@ -349,10 +349,22 @@ export const cloneRepository = async (url: string) => { await fetchWorkspaceDirectory(repoName) dispatch(cloneRepositorySuccess()) }).catch((e) => { - dispatch(displayNotification('Clone Git Repository', 'An error occured: ' + e, 'Ok', null, async () => { - await deleteWorkspace(repoName) - dispatch(cloneRepositoryFailed()) - })) + const cloneModal = { + id: 'cloneGitRepository', + title: 'Clone Git Repository', + message: 'An error occured: ' + e, + modalType: 'modal', + okLabel: 'OK', + okFn: async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + }, + hideFn: async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + } + } + plugin.call('notification', 'modal', cloneModal) }) } catch (e) { dispatch(displayPopUp('An error occured: ' + e)) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 8bbe2a2703..5302d907ed 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -144,7 +144,7 @@ export function Workspace () { if (url) { global.dispatchCloneRepository(url) } else { - global.modal('Create Workspace', 'Please provide a valid github repository url.', 'OK', () => {}, '') + global.modal('Clone Git Repository', 'Please provide a valid git repository url.', 'OK', () => {}, '') } } From 438bd279c9674e90ddca5f98536ed4da810ba204 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 16:46:07 +0100 Subject: [PATCH 24/25] Fix failing test --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index ca54678a7b..accf71bdfb 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -41,7 +41,7 @@ module.exports = { .setValue('*[data-id="settingsTabGistAccessToken"]', '**********') .click('*[data-id="settingsTabSaveGistToken"]') .waitForElementVisible('*[data-shared="tooltipPopup"]', 5000) - .assert.containsText('*[data-shared="tooltipPopup"]', 'Access token has been saved') + .assert.containsText('*[data-shared="tooltipPopup"]', 'GitHub credentials updated') .pause(3000) }, From 5921febc35b94bb41c404fadac073b881f23466c Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 16:57:09 +0100 Subject: [PATCH 25/25] Fix generalSettings test --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index accf71bdfb..a4932b05fd 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -59,7 +59,7 @@ module.exports = { .pause(1000) .click('*[data-id="settingsTabRemoveGistToken"]') .waitForElementVisible('*[data-shared="tooltipPopup"]', 5000) - .assert.containsText('*[data-shared="tooltipPopup"]', 'Access token removed') + .assert.containsText('*[data-shared="tooltipPopup"]', 'GitHub credentials removed') .assert.containsText('*[data-id="settingsTabGistAccessToken"]', '') },