fix niggly issues

pull/4930/head
Joseph Izang 7 months ago committed by Aniket
parent 9aebbff87b
commit cc0032fc85
  1. 2
      apps/remix-ide/src/app/tabs/locales/en/home.json
  2. 11
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx
  3. 2
      libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx
  4. 19
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -68,7 +68,7 @@
"home.seeAllTutorials": "See all tutorials",
"home.maintainedByRemix": "Maintained by Remix",
"home.gitCloneTooltip": "Clone a Github repo to a new workspace",
"home.gistTooltip": "Import gist to a workspace",
"home.gistTooltip": "Open Gist repo",
"home.newFileTooltip": "Add a new file to a workspace"
}

@ -168,7 +168,11 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
<div className="d-flex flex-column">
<div className="d-flex flex-row">
<CustomTooltip placement={'top'} tooltipId="overlay-tooltip" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="home.newFileTooltip" />} tooltipTextClasses="border bg-light text-dark p-1 pr-3">
<button className="btn btn-primary text-nowrap p-2 mr-2 border my-1" data-id="homeTabNewFile" style={{ width: 'fit-content' }} onClick={async () => await plugin.call('filePanel', 'createNewFile')}>
<button className="btn btn-primary text-nowrap p-2 mr-2 border my-1" data-id="homeTabNewFile" style={{ width: 'fit-content' }} onClick={async () => {
_paq.push(['trackEvent', 'hometab', 'filesSection', 'newFile'])
await plugin.call('menuicons', 'select', 'filePanel')
await plugin.call('filePanel', 'createNewFile')
}}>
<FormattedMessage id="home.newFile" />
</button>
</CustomTooltip>
@ -181,9 +185,9 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
title="open file"
type="file"
id="openFileInput"
onChange={(event) => {
onChange={async (event) => {
event.stopPropagation()
plugin.verticalIcons.select('filePanel')
await plugin.call('menuicons', 'select', 'filePanel')
uploadFile(event.target)
}}
multiple
@ -193,6 +197,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
<CustomTooltip placement={'top'} tooltipId="overlay-tooltip" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="home.gitCloneTooltip" />} tooltipTextClasses="border bg-light text-dark p-1 pr-3"
>
<button className="btn text-nowrap p-2 mr-2 border my-1" data-id="landingPageImportFromGitHubButton" onClick={async () => {
_paq.push(['trackEvent', 'hometab', 'filesSection', 'Git Clone'])
await plugin.call('filePanel', 'clone')
}}>
Git Clone

@ -159,8 +159,10 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => {
} else if (action === 'publishToGist' || action == 'updateGist') {
props.publishToGist()
} else if (action === 'importFromIpfs') {
_paq.push(['trackEvent', 'fileExplorer', 'fileAction', action])
props.importFromIpfs('Ipfs', 'ipfs hash', ['ipfs://QmQQfBMkpDgmxKzYaoAtqfaybzfgGm9b2LWYyT56Chv6xH'], 'ipfs://')
} else if (action === 'importFromHttps') {
_paq.push(['trackEvent', 'fileExplorer', 'fileAction', action])
props.importFromHttps('Https', 'http/https raw content', ['https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol'])
} else {
state.actions[action]()

@ -152,7 +152,7 @@ export function Workspace() {
})
}
const showFullMessage = (title: string, loadItem: string, examples: Array<string>, prefix = '') => {
const showFullMessage = async (title: string, loadItem: string, examples: Array<string>, prefix = '') => {
setModalState((prevState) => {
return {
...prevState,
@ -186,18 +186,11 @@ export function Workspace() {
const workspace = global.plugin.fileManager.getProvider('workspace')
const startsWith = modalState.importSource.substring(0, 4)
if ((type === 'ipfs' || type === 'IPFS') && startsWith !== 'ipfs' && startsWith !== 'IPFS') {
setState((prevState) => {
setModalState((prevState) => {
return { ...prevState, importSource: startsWith + modalState.importSource }
})
} else {
global.plugin.call('notification', 'alert', { id: 'homeTabAlert', message: 'The provided value is invalid!' })
return
}
if (!startsWith.startsWith('https://') || !startsWith.startsWith('http://')) {
global.plugin.call('notification', 'alert', { id: 'homeTabAlert', message: 'The provided value is invalid!' })
return
}
contentImport.import(
modalState.modalInfo.prefix + modalState.importSource,
(loadingMsg) => dispatch({ tooltip: loadingMsg }),
@ -232,15 +225,14 @@ export function Workspace() {
/**
* Validate the url fed into the modal for ipfs and https imports
* @returns {ValidationResult}
*/
const validateUrlForImport = (input: any) => {
if ((input.trim().startsWith('ipfs://') && input.length > 7) || input.trim().startsWith('https://') || input.trim() !== '') {
setValidationResult({ valid: true, message: '' })
return validationResult
return { valid: true, message: '' }
} else {
global.plugin.call('notification', 'alert', { id: 'homeTabAlert', message: 'The provided value is invalid!' })
setValidationResult({ valid: false, message: 'The provided value is invalid!' })
return validationResult
return { valid: false, message: 'The provided value is invalid!' }
}
}
@ -1477,6 +1469,7 @@ export function Workspace() {
downloadPath={downloadPath}
/>
)}
<ModalDialog id="homeTab" title={'Import from ' + modalState.modalInfo.title}
okLabel="Import" hide={!modalState.showModalDialog} handleHide={() => hideFullMessage()}
okFn={() => processLoading(modalState.modalInfo.title)} validationFn={validateUrlForImport}

Loading…
Cancel
Save