From b3be9a61dce64628e50bd1c86d0c524b3fd6227f Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 19 Feb 2024 14:36:58 +0100 Subject: [PATCH] remove uneeded gist type and add copy gist ID to clipboard --- .../drag-n-drop/src/lib/types/index.ts | 2 +- .../file-decorators/src/lib/types/index.ts | 2 +- .../workspace/src/lib/actions/index.ts | 4 ++-- .../src/lib/components/file-explorer.tsx | 2 +- .../workspace/src/lib/contexts/index.ts | 4 ++-- .../src/lib/providers/FileSystemProvider.tsx | 4 ++-- .../workspace/src/lib/remix-ui-workspace.tsx | 10 ++++++++-- libs/remix-ui/workspace/src/lib/types/index.ts | 4 ++-- libs/remix-ui/workspace/src/lib/utils/index.ts | 18 +++++------------- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/libs/remix-ui/drag-n-drop/src/lib/types/index.ts b/libs/remix-ui/drag-n-drop/src/lib/types/index.ts index 8bd4b0066a..c81cad0b5b 100644 --- a/libs/remix-ui/drag-n-drop/src/lib/types/index.ts +++ b/libs/remix-ui/drag-n-drop/src/lib/types/index.ts @@ -4,7 +4,7 @@ export interface FileType { path: string, name: string, isDirectory: boolean, - type: 'folder' | 'file' | 'gist', + type: 'folder' | 'file', child?: File[] } diff --git a/libs/remix-ui/file-decorators/src/lib/types/index.ts b/libs/remix-ui/file-decorators/src/lib/types/index.ts index bb84b6d26c..e78a1a4136 100644 --- a/libs/remix-ui/file-decorators/src/lib/types/index.ts +++ b/libs/remix-ui/file-decorators/src/lib/types/index.ts @@ -24,6 +24,6 @@ export interface FileType { path: string, name?: string, isDirectory?: boolean, - type?: 'folder' | 'file' | 'gist', + type?: 'folder' | 'file', child?: File[] } \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 15344a2a4b..540abc8397 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -320,7 +320,7 @@ export const createNewFile = async (path: string, rootDir: string) => { } } -export const setFocusElement = async (elements: { key: string, type: 'file' | 'folder' | 'gist' }[]) => { +export const setFocusElement = async (elements: { key: string, type: 'file' | 'folder' }[]) => { dispatch(focusElement(elements)) } @@ -435,7 +435,7 @@ export const emitContextMenuEvent = async (cmd: customAction) => { await plugin.call(cmd.id, cmd.name, cmd) } -export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => { +export const handleClickFile = async (path: string, type: 'file' | 'folder' ) => { if (type === 'file' && path.endsWith('.md')) { // just opening the preview await plugin.call('doc-viewer' as any, 'viewDocs', [path]) diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index 6e2010f80b..b323e2a750 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -173,7 +173,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } } - const handleClickFolder = async (path: string, type: 'folder' | 'file' | 'gist') => { + const handleClickFolder = async (path: string, type: 'folder' | 'file' ) => { if (state.ctrlKey) { if (props.focusElement.findIndex((item) => item.key === path) !== -1) { const focusElement = props.focusElement.filter((item) => item.key !== path) diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index c3ac0849a4..42e7f8bbf9 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -21,7 +21,7 @@ export const FileSystemContext = createContext<{ dispatchUploadFile: (target?: SyntheticEvent, targetFolder?: string) => Promise, dispatchUploadFolder: (target?: SyntheticEvent, targetFolder?: string) => Promise, dispatchCreateNewFile: (path: string, rootDir: string) => Promise, - dispatchSetFocusElement: (elements: { key: string, type: 'file' | 'folder' | 'gist' }[]) => Promise, + dispatchSetFocusElement: (elements: { key: string, type: 'file' | 'folder' }[]) => Promise, dispatchCreateNewFolder: (path: string, rootDir: string) => Promise, dispatchDeletePath: (path: string[]) => Promise, dispatchRenamePath: (oldPath: string, newPath: string) => Promise, @@ -31,7 +31,7 @@ export const FileSystemContext = createContext<{ dispatchCopyFolder: (src: string, dest: string) => Promise, dispatchRunScript: (path: string) => Promise, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise, - dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise + dispatchHandleClickFile: (path: string, type: 'file' | 'folder' ) => Promise dispatchHandleExpandPath: (paths: string[]) => Promise, dispatchHandleDownloadFiles: () => Promise, dispatchHandleDownloadWorkspace: () => Promise, diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 8d7c1ac5bd..e4bbd25cec 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -133,7 +133,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await createNewFile(path, rootDir) } - const dispatchSetFocusElement = async (elements: {key: string; type: 'file' | 'folder' | 'gist'}[]) => { + const dispatchSetFocusElement = async (elements: {key: string; type: 'file' | 'folder' }[]) => { await setFocusElement(elements) } @@ -173,7 +173,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await emitContextMenuEvent(cmd) } - const dispatchHandleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => { + const dispatchHandleClickFile = async (path: string, type: 'file' | 'folder' ) => { await handleClickFile(path, type) } 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 fc059dc90d..3f9dde30f2 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, ChangeEvent} from 'react import {FormattedMessage, useIntl} from 'react-intl' import {Dropdown} from 'react-bootstrap' import {CustomIconsToggle, CustomMenu, CustomToggle, CustomTooltip, extractNameFromKey, extractParentFromKey} from '@remix-ui/helper' +import {CopyToClipboard} from '@remix-ui/clipboard' import {FileExplorer} from './components/file-explorer' // eslint-disable-line import {FileSystemContext} from './contexts' import './css/remix-ui-workspace.css' @@ -438,7 +439,7 @@ export function Workspace() { } } - const handleCopyClick = (path: string, type: 'folder' | 'gist' | 'file' | 'workspace') => { + const handleCopyClick = (path: string, type: 'folder' | 'file' | 'workspace') => { setState((prevState) => { return {...prevState, copyElement: [{key: path, type}]} }) @@ -507,7 +508,6 @@ export function Workspace() { const focusElement = global.fs.focusElement if (focusElement[0]) { if (focusElement[0].type === 'folder' && focusElement[0].key) return focusElement[0].key - else if (focusElement[0].type === 'gist' && focusElement[0].key) return focusElement[0].key else if (focusElement[0].type === 'file' && focusElement[0].key) return extractParentFromKey(focusElement[0].key) ? extractParentFromKey(focusElement[0].key) : ROOT_PATH else return ROOT_PATH } @@ -988,6 +988,12 @@ export function Workspace() { > saveSampleCodeWorkspace()} className="far fa-exclamation-triangle text-warning ml-2 align-self-center" aria-hidden="true"> } + + {selectedWorkspace && selectedWorkspace.isGist && selectedWorkspace.isGist} direction="bottom" icon="far fa-copy"> + + + } +
diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index 313f7a5dda..635c9925db 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -43,7 +43,7 @@ export interface FileType { path: string name: string isDirectory: boolean - type: 'folder' | 'file' | 'gist' + type: 'folder' | 'file' child?: File[] } @@ -319,4 +319,4 @@ export interface Action { export type Actions = {[A in keyof ActionPayloadTypes]: Action}[keyof ActionPayloadTypes] -export type WorkspaceElement = 'folder' | 'gist' | 'file' | 'workspace' +export type WorkspaceElement = 'folder' | 'file' | 'workspace' diff --git a/libs/remix-ui/workspace/src/lib/utils/index.ts b/libs/remix-ui/workspace/src/lib/utils/index.ts index 438599bd94..d29b524163 100644 --- a/libs/remix-ui/workspace/src/lib/utils/index.ts +++ b/libs/remix-ui/workspace/src/lib/utils/index.ts @@ -1,18 +1,18 @@ import { appPlatformTypes } from '@remix-ui/app' import { FileType } from '@remix-ui/file-decorators' -import { WorkspaceProps, MenuItems } from '../types' +import { MenuItems } from '../types' export const contextMenuActions: MenuItems = [{ id: 'newFile', name: 'New File', - type: ['folder', 'gist', 'workspace'], + type: ['folder', 'workspace'], multiselect: false, label: '', group: 0 }, { id: 'newFolder', name: 'New Folder', - type: ['folder', 'gist', 'workspace'], + type: ['folder', 'workspace'], multiselect: false, label: '', group: 0 @@ -26,7 +26,7 @@ export const contextMenuActions: MenuItems = [{ }, { id: 'delete', name: 'Delete', - type: ['file', 'folder', 'gist'], + type: ['file', 'folder'], multiselect: false, label: '', group: 0 @@ -80,14 +80,6 @@ export const contextMenuActions: MenuItems = [{ multiselect: false, label: '', group: 3 -}, { - id: 'pushChangesToGist', - name: 'Push changes to gist', - type: ['gist'], - multiselect: false, - label: '', - group: 4, - platform: appPlatformTypes.web }, { id: 'publishFolderToGist', name: 'Publish folder to gist', @@ -107,7 +99,7 @@ export const contextMenuActions: MenuItems = [{ }, { id: 'uploadFile', name: 'Load a Local File', - type: ['folder', 'gist', 'workspace'], + type: ['folder', 'workspace'], multiselect: false, label: 'Load a Local File', group: 4,