Merge pull request #3508 from ethereum/default_project_name

Update default project name
pull/3519/head
yann300 2 years ago committed by GitHub
commit 6c5f168bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      apps/remix-ide/src/app/panels/file-panel.js
  2. 7
      libs/remix-ui/home-tab/src/lib/components/homeTabGetStarted.tsx
  3. 1
      libs/remix-ui/workspace/src/index.ts
  4. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  5. 1
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  6. 18
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  7. 10
      libs/remix-ui/workspace/src/lib/utils/constants.ts

@ -30,7 +30,7 @@ const { SlitherHandle } = require('../files/slither-handle.js')
const profile = {
name: 'filePanel',
displayName: 'File explorer',
methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getWorkspaces', 'createWorkspace', 'setWorkspace', 'registerContextMenuItem', 'renameWorkspace', 'deleteWorkspace'],
methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getAvailableWorkspaceName', 'getWorkspaces', 'createWorkspace', 'setWorkspace', 'registerContextMenuItem', 'renameWorkspace', 'deleteWorkspace'],
events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'],
icon: 'assets/img/fileManager.webp',
description: 'Remix IDE file explorer',
@ -94,6 +94,16 @@ module.exports = class Filepanel extends ViewPlugin {
return this.workspaces
}
getAvailableWorkspaceName (name) {
let index = 1
let workspace = this.workspaces.find(workspace => workspace.name === name + ' - ' + index)
while (workspace) {
index++
workspace = this.workspaces.find(workspace => workspace.name === name + ' - ' + index)
}
return name + ' - ' + index
}
setWorkspaces (workspaces) {
this.workspaces = workspaces
}

@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useEffect, useRef, useContext } from 'react'
import { useIntl, FormattedMessage } from 'react-intl'
import { TEMPLATE_NAMES } from '@remix-ui/workspace'
import { ThemeContext} from '../themeContext'
import Carousel from 'react-multi-carousel'
import WorkspaceTemplate from './workspaceTemplate'
@ -59,8 +60,10 @@ function HomeTabGetStarted ({plugin}: HomeTabGetStartedProps) {
const createWorkspace = async (templateName) => {
await plugin.appManager.activatePlugin('filePanel')
const timeStamp = Date.now()
await plugin.call('filePanel', 'createWorkspace', templateName + "_" + timeStamp, templateName)
await plugin.call('filePanel', 'setWorkspace', templateName + "_" + timeStamp)
let templateDisplayName = TEMPLATE_NAMES[templateName]
templateDisplayName = await plugin.call('filePanale', 'getAvailableWorkspaceName', templateDisplayName)
await plugin.call('filePanel', 'createWorkspace', templateDisplayName, templateName)
await plugin.call('filePanel', 'setWorkspace', templateDisplayName)
plugin.verticalIcons.select('filePanel')
_paq.push(['trackEvent', 'hometab', 'homeGetStarted', templateName])
}

@ -1,3 +1,4 @@
export * from './lib/providers/FileSystemProvider'
export * from './lib/contexts'
export * from './lib/utils/constants'
export { FileType } from './lib/types/index'

@ -4,6 +4,7 @@ import { BrowserState } from '../reducers/workspace'
export const FileSystemContext = createContext<{
fs: BrowserState,
plugin: any,
modal:(title: string | JSX.Element, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
dispatchInitWorkspace:() => Promise<void>,
dispatchFetchDirectory:(path: string) => Promise<void>,

@ -255,6 +255,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
const value = {
fs,
plugin,
modal,
toast,
dispatchInitWorkspace,

@ -5,7 +5,7 @@ import { CustomIconsToggle, CustomMenu, CustomToggle, CustomTooltip } from '@rem
import { FileExplorer } from './components/file-explorer' // eslint-disable-line
import { FileSystemContext } from './contexts'
import './css/remix-ui-workspace.css'
import { ROOT_PATH } from './utils/constants'
import { ROOT_PATH, TEMPLATE_NAMES } from './utils/constants'
import { HamburgerMenu } from './components/workspace-hamburger'
const _paq = window._paq = window._paq || []
@ -231,7 +231,10 @@ export function Workspace () {
} else displayOzCustomRef.current.style.display = 'none'
// @ts-ignore
workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}`
let displayName = TEMPLATE_NAMES[(workspaceCreateTemplateInput.current && workspaceCreateTemplateInput.current.value) || 'remixDefault']
displayName = global.plugin.getAvailableWorkspaceName(displayName)
// @ts-ignore
workspaceCreateInput.current.value = displayName
}
const handleTypingUrl = () => {
@ -254,11 +257,6 @@ export function Workspace () {
setShowDropdown(isOpen)
}
const handleUpgradeability = () => {
// @ts-ignore
workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value + '_upgradeable'}_${Date.now()}`
}
const toggleBranches = (isOpen: boolean) => {
setShowBranches(isOpen)
}
@ -303,7 +301,7 @@ export function Workspace () {
<label id="selectWsTemplate" className="form-check-label" style={{fontWeight: "bolder"}}><FormattedMessage id='filePanel.workspace.chooseTemplate' /></label>
<select name="wstemplate" className="mb-3 form-control custom-select" id="wstemplate" defaultValue='remixDefault' ref={workspaceCreateTemplateInput} onChange={updateWsName}>
<optgroup style={{fontSize: "medium"}} label="General">
<option style={{fontSize: "small"}} value='remixDefault'>Default</option>
<option style={{fontSize: "small"}} value='remixDefault'>Basic</option>
<option style={{fontSize: "small"}} value='blank'>Blank</option>
</optgroup>
<optgroup style={{fontSize: "medium"}} label="OpenZeppelin">
@ -339,7 +337,7 @@ export function Workspace () {
</div>
<label id="wsName" className="form-check-label d-block mb-1"><FormattedMessage id='filePanel.upgradeability' /></label>
<div onChange={handleUpgradeability}>
<div>
<div className="d-flex ml-2 custom-control custom-radio">
<input className="custom-control-input" type="radio" name="upgradeability" value="transparent" id="transparent" ref={transparentRadioRef} />
<label className="form-check-label custom-control-label" htmlFor="transparent" data-id="upgradeTypeTransparent" >Transparent</label>
@ -353,7 +351,7 @@ export function Workspace () {
</div>
<label id="wsName" className="form-check-label" style={{fontWeight: "bolder"}} ><FormattedMessage id='filePanel.workspaceName' /></label>
<input type="text" data-id="modalDialogCustomPromptTextCreate" defaultValue={`remixDefault_${Date.now()}`} ref={workspaceCreateInput} className="form-control" />
<input type="text" data-id="modalDialogCustomPromptTextCreate" defaultValue={global.plugin.getAvailableWorkspaceName(TEMPLATE_NAMES['remixDefault'])} ref={workspaceCreateInput} className="form-control" />
<div className="d-flex py-2 align-items-center custom-control custom-checkbox">
<input

@ -51,3 +51,13 @@ jobs:
fail-on: 'low'
solc-version: '0.8.2'
`
export const TEMPLATE_NAMES = {
'remixDefault': 'Basic',
'blank': 'Blank',
'ozerc20': 'OpenZeppelin ERC20',
'ozerc721': 'OpenZeppelin ERC721',
'ozerc1155': 'OpenZeppelin ERC1155',
'zeroxErc20': '0xProject ERC20',
'gnosisSafeMultisig': 'Gnosis Safe'
}

Loading…
Cancel
Save