From 60a846d35f3a9c95813b7a7464c70f405bb73168 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 12 Jan 2023 14:04:33 +0100 Subject: [PATCH] Add icons, moved hamburger to separate file and added translation --- .../src/app/tabs/locales/en/filePanel.json | 6 +- .../src/app/tabs/locales/zh/filePanel.json | 8 +- .../lib/components/workspace-hamburger.tsx | 322 ++++++++++++++++++ .../workspace/src/lib/remix-ui-workspace.tsx | 305 +---------------- .../workspace/src/lib/utils/constants.ts | 2 +- 5 files changed, 349 insertions(+), 294 deletions(-) create mode 100644 libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx diff --git a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json index b9e043b201..4c6393f41c 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -16,11 +16,11 @@ "filePanel.workspace.clone": "Clone Git Repository", "filePanel.workspace.enterGitUrl": "Enter git repository url", "filePanel.workspace.solghaction": "Adds a preset yml file to run solidity unit tests on github actions CI.", - "filePanel.solghaction": "Add Solidity Test Workflow", + "filePanel.solghaction": "Solidity Test Workflow", "filePanel.workspace.tssoltestghaction": "Adds a preset yml file to run mocha and chai tests for solidity on github actions CI", - "filePanel.tssoltestghaction": "Add Mocha Chai Test Workflow", + "filePanel.tssoltestghaction": "Mocha Chai Test Workflow", "filePanel.workspace.slitherghaction": "Adds a preset yml file to run slither analysis on github actions CI", - "filePanel.slitherghaction": "Add Slither Workflow", + "filePanel.slitherghaction": "Slither Workflow", "filePanel.newFile": "New File", "filePanel.newFolder": "New Folder", "filePanel.rename": "Rename", diff --git a/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json b/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json index 546d581380..d663e53819 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json @@ -15,8 +15,12 @@ "filePanel.workspace.restore": "恢复工作空间", "filePanel.workspace.clone": "克隆 Git 仓库", "filePanel.workspace.enterGitUrl": "输入 Git 仓库地址", - "filePanel.workspace.solghaction": "添加 Solidity GitHub Action 文件。推送到一个代码仓库,然后在 GitHub CI 中运行它。", - "filePanel.solghaction": "添加 Solidity GitHub Action", + "filePanel.workspace.solghaction": "添加预设 yml 文件以在 github 操作 CI 上运行 solidity 单元测试。", + "filePanel.solghaction": "Solidity Test Workflow", + "filePanel.workspace.tssoltestghaction": "添加一个预设的 yml 文件以在 github 操作 CI 上运行 mocha 和 chai 测试以确保可靠性", + "filePanel.tssoltestghaction": "Mocha Chai Test Workflow", + "filePanel.workspace.slitherghaction": "添加一个预设的 yml 文件以在 github actions CI 上运行 slither 分析", + "filePanel.slitherghaction": "Slither Workflow", "filePanel.newFile": "新建文件", "filePanel.newFolder": "新建文件夹", "filePanel.rename": "重命名", diff --git a/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx new file mode 100644 index 0000000000..713b3ac6fa --- /dev/null +++ b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx @@ -0,0 +1,322 @@ +import React from 'react' +import { CustomTooltip } from '@remix-ui/helper' +import { Dropdown } from 'react-bootstrap' +import { FormattedMessage } from 'react-intl' + +const _paq = window._paq = window._paq || [] + +export interface HamburgerMenuProps { + createWorkspace: () => void, + deleteCurrentWorkspace: () => void, + renameCurrentWorkspace: () => void, + cloneGitRepository: () => void, + downloadWorkspaces: () => void, + restoreBackup: () => void, + hideIconsMenu: (showMenu: boolean) => void, + addGithubAction: () => void, + addTsSolTestGithubAction: () => void, + addSlitherGithubAction: () => void, + showIconsMenu: boolean, + hideWorkspaceOptions: boolean, + hideLocalhostOptions: boolean +} + +export function HamburgerMenu (props: HamburgerMenuProps) { + const { showIconsMenu, hideWorkspaceOptions, hideLocalhostOptions } = props + return ( + <> + + } + > +
{ + props.createWorkspace() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceCreate']) + props.hideIconsMenu(!showIconsMenu) + }} + key={`workspacesCreate-fe-ws`} + > + + +
+
+
+ + } + > +
{ + props.deleteCurrentWorkspace() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceDelete']) + props.hideIconsMenu(!showIconsMenu) + }} + key={`workspacesDelete-fe-ws`} + > + + +
+
+
+ + } + > +
{ + props.renameCurrentWorkspace() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceRename']) + props.hideIconsMenu(!showIconsMenu) + }} + data-id='workspaceRename' + key={`workspacesRename-fe-ws`} + > + + +
+
+
+ + + } + > +
{ + props.cloneGitRepository() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'cloneGitRepository']) + props.hideIconsMenu(!showIconsMenu) + }} + key={`cloneGitRepository-fe-ws`} + > + + +
+
+
+ + + } + > +
{ + props.downloadWorkspaces() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspacesDownload']) + props.hideIconsMenu(!showIconsMenu) + }} + key={`workspacesDownload-fe-ws`} + > + + +
+
+
+ + } + > +
{ + props.restoreBackup() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspacesRestore']) + props.hideIconsMenu(!showIconsMenu) + }} + key={`workspacesRestore-fe-ws`} + > + + +
+
+
+ + + } + > +
{ + e.stopPropagation() + props.addGithubAction() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSolidityTesting']) + props.hideIconsMenu(!showIconsMenu) + }} + > + + {} +
+
+
+ + } + > +
{ + e.stopPropagation() + props.addTsSolTestGithubAction() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addTsSolTestingAction']) + props.hideIconsMenu(!showIconsMenu) + }} + > + + {} +
+
+
+ + } + > +
{ + e.stopPropagation() + props.addSlitherGithubAction() + _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSlitherAction']) + props.hideIconsMenu(!showIconsMenu) + }} + > + + {} +
+
+
+ + ) + } 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 ce8f8fe8d9..6eba79f344 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -1,11 +1,12 @@ import React, { useState, useEffect, useRef, useContext, SyntheticEvent, ChangeEvent, KeyboardEvent } from 'react' // eslint-disable-line import { FormattedMessage, useIntl } from 'react-intl' -import { ButtonGroup, Dropdown, DropdownButton } from 'react-bootstrap' +import { Dropdown } from 'react-bootstrap' import { CustomIconsToggle, CustomMenu, CustomToggle, CustomTooltip } from '@remix-ui/helper' 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 { HamburgerMenu } from './components/workspace-hamburger' const _paq = window._paq = window._paq || [] const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -380,284 +381,6 @@ export function Workspace () { ) } - const workspaceMenuIcons = [ - } - > -
{ - createWorkspace() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceCreate']) - hideIconsMenu(!showIconsMenu) - }} - key={`workspacesCreate-fe-ws`} - > - - -
-
, - } - > -
{ - deleteCurrentWorkspace() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceDelete']) - hideIconsMenu(!showIconsMenu) - }} - key={`workspacesDelete-fe-ws`} - > - - -
-
, - } - > -
{ - renameCurrentWorkspace() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspaceRename']) - hideIconsMenu(!showIconsMenu) - }} - data-id='workspaceRename' - key={`workspacesRename-fe-ws`} - > - - -
-
, - , - } - > -
{ - cloneGitRepository() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'cloneGitRepository']) - hideIconsMenu(!showIconsMenu) - }} - key={`cloneGitRepository-fe-ws`} - > - - -
-
, - , - } - > -
{ - downloadWorkspaces() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspacesDownload']) - hideIconsMenu(!showIconsMenu) - }} - key={`workspacesDownload-fe-ws`} - > - - -
-
, - } - > -
{ - restoreBackup() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'workspacesRestore']) - hideIconsMenu(!showIconsMenu) - }} - key={`workspacesRestore-fe-ws`} - > - - -
-
, - , - } - > -
{ - e.stopPropagation() - addGithubAction() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSolidityTesting']) - hideIconsMenu(!showIconsMenu) - }} - > - - {} -
-
, - } - > -
{ - e.stopPropagation() - addTsSolTestGithubAction() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addTsSolTestingAction']) - hideIconsMenu(!showIconsMenu) - }} - > - - {} -
-
, - } - > -
{ - e.stopPropagation() - addSlitherGithubAction() - _paq.push(['trackEvent', 'fileExplorer', 'workspaceMenu', 'addSlitherAction']) - hideIconsMenu(!showIconsMenu) - }} - > - - {} -
-
- ] - const menuLength = workspaceMenuIcons.length - let count = 0 return (
@@ -701,15 +424,21 @@ export function Workspace () { icon={'fas fa-bars'} > - { - workspaceMenuIcons.map(m => { - return ( - - {m} - - ) - }) - } + ) : null} diff --git a/libs/remix-ui/workspace/src/lib/utils/constants.ts b/libs/remix-ui/workspace/src/lib/utils/constants.ts index 32b07d3fbb..20cc9b08b6 100644 --- a/libs/remix-ui/workspace/src/lib/utils/constants.ts +++ b/libs/remix-ui/workspace/src/lib/utils/constants.ts @@ -28,7 +28,7 @@ export const tsSolTestYml = ` - name: Checkout uses: actions/checkout@v2 - name: Run SUT Action - uses: EthereumRemix/ts-sol-test@v0.1.4-dev + uses: EthereumRemix/ts-sol-test@v1 with: test-path: 'tests' contract-path: 'contracts'