remove uneeded gist type and add copy gist ID to clipboard

pull/4550/head
yann300 9 months ago
parent 9f15938a0a
commit b3be9a61dc
  1. 2
      libs/remix-ui/drag-n-drop/src/lib/types/index.ts
  2. 2
      libs/remix-ui/file-decorators/src/lib/types/index.ts
  3. 4
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 2
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  5. 4
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  6. 4
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  7. 10
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  8. 4
      libs/remix-ui/workspace/src/lib/types/index.ts
  9. 18
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -4,7 +4,7 @@ export interface FileType {
path: string,
name: string,
isDirectory: boolean,
type: 'folder' | 'file' | 'gist',
type: 'folder' | 'file',
child?: File[]
}

@ -24,6 +24,6 @@ export interface FileType {
path: string,
name?: string,
isDirectory?: boolean,
type?: 'folder' | 'file' | 'gist',
type?: 'folder' | 'file',
child?: File[]
}

@ -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])

@ -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)

@ -21,7 +21,7 @@ export const FileSystemContext = createContext<{
dispatchUploadFile: (target?: SyntheticEvent, targetFolder?: string) => Promise<void>,
dispatchUploadFolder: (target?: SyntheticEvent, targetFolder?: string) => Promise<void>,
dispatchCreateNewFile: (path: string, rootDir: string) => Promise<void>,
dispatchSetFocusElement: (elements: { key: string, type: 'file' | 'folder' | 'gist' }[]) => Promise<void>,
dispatchSetFocusElement: (elements: { key: string, type: 'file' | 'folder' }[]) => Promise<void>,
dispatchCreateNewFolder: (path: string, rootDir: string) => Promise<void>,
dispatchDeletePath: (path: string[]) => Promise<void>,
dispatchRenamePath: (oldPath: string, newPath: string) => Promise<void>,
@ -31,7 +31,7 @@ export const FileSystemContext = createContext<{
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' ) => Promise<void>
dispatchHandleExpandPath: (paths: string[]) => Promise<void>,
dispatchHandleDownloadFiles: () => Promise<void>,
dispatchHandleDownloadWorkspace: () => Promise<void>,

@ -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)
}

@ -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() {
>
<i onClick={() => saveSampleCodeWorkspace()} className="far fa-exclamation-triangle text-warning ml-2 align-self-center" aria-hidden="true"></i>
</CustomTooltip>}
{selectedWorkspace && selectedWorkspace.isGist && <CopyToClipboard tip={'Copy Gist ID to clipboard'} getContent={() => selectedWorkspace.isGist} direction="bottom" icon="far fa-copy">
<i className="remixui_copyIcon ml-2 fab fa-github text-info" aria-hidden="true" style={{fontSize: '1.1rem', cursor: 'pointer'}} ></i>
</CopyToClipboard>
}
</span>
</div>
<div className='mx-2'>

@ -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<T extends keyof ActionPayloadTypes> {
export type Actions = {[A in keyof ActionPayloadTypes]: Action<A>}[keyof ActionPayloadTypes]
export type WorkspaceElement = 'folder' | 'gist' | 'file' | 'workspace'
export type WorkspaceElement = 'folder' | 'file' | 'workspace'

@ -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,

Loading…
Cancel
Save