Fix linting, remove comments and rename workspaceStatus

pull/1575/head
ioedeveloper 3 years ago
parent cfd58670ee
commit e585e0b578
  1. 3
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  2. 6
      apps/remix-ide/src/app/panels/file-panel.js
  3. 2
      libs/remix-ui/workspace/src/lib/components/file-label.tsx
  4. 2
      libs/remix-ui/workspace/src/lib/components/file-render.tsx
  5. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  6. 3
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  7. 11
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -31,7 +31,6 @@ class WorkspaceFileProvider extends FileProvider {
} }
removePrefix (path) { removePrefix (path) {
// if (!this.workspace) this.createWorkspace()
path = path.replace(/^\/|\/$/g, '') // remove first and last slash path = path.replace(/^\/|\/$/g, '') // remove first and last slash
if (path.startsWith(this.workspacesPath + '/' + this.workspace)) return path if (path.startsWith(this.workspacesPath + '/' + this.workspace)) return path
if (path.startsWith(this.workspace)) return path.replace(this.workspace, this.workspacesPath + '/' + this.workspace) if (path.startsWith(this.workspace)) return path.replace(this.workspace, this.workspacesPath + '/' + this.workspace)
@ -52,7 +51,6 @@ class WorkspaceFileProvider extends FileProvider {
} }
resolveDirectory (path, callback) { resolveDirectory (path, callback) {
// if (!this.workspace) this.createWorkspace()
super.resolveDirectory(path, (error, files) => { super.resolveDirectory(path, (error, files) => {
if (error) return callback(error) if (error) return callback(error)
const unscoped = {} const unscoped = {}
@ -77,7 +75,6 @@ class WorkspaceFileProvider extends FileProvider {
} }
_normalizePath (path) { _normalizePath (path) {
// if (!this.workspace) this.createWorkspace()
return path.replace(this.workspacesPath + '/' + this.workspace + '/', '') return path.replace(this.workspacesPath + '/' + this.workspace + '/', '')
} }

@ -54,7 +54,7 @@ module.exports = class Filepanel extends ViewPlugin {
this.slitherHandle = new SlitherHandle() this.slitherHandle = new SlitherHandle()
this.workspaces = [] this.workspaces = []
this.appManager = appManager this.appManager = appManager
this.workspaceStatus = {} this.currentWorkspaceInfo = {}
} }
onActivation () { onActivation () {
@ -84,7 +84,7 @@ module.exports = class Filepanel extends ViewPlugin {
} }
getCurrentWorkspace () { getCurrentWorkspace () {
return this.workspaceStatus return this.currentWorkspaceInfo
} }
getWorkspaces () { getWorkspaces () {
@ -120,7 +120,7 @@ module.exports = class Filepanel extends ViewPlugin {
setWorkspace (workspace) { setWorkspace (workspace) {
const workspaceProvider = this.fileProviders.workspace const workspaceProvider = this.fileProviders.workspace
this.workspaceStatus = { name: workspace.name, isLocalhost: workspace.isLocalhost, absolutePath: `${workspaceProvider.workspacesPath}/${workspace.name}` } this.currentWorkspaceInfo = { name: workspace.name, isLocalhost: workspace.isLocalhost, absolutePath: `${workspaceProvider.workspacesPath}/${workspace.name}` }
} }
workspaceDeleted (workspace) { workspaceDeleted (workspace) {

@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line no-use-before-define
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { FileType } from '../types' import { FileType } from '../types'

@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line no-use-before-define
import React, { SyntheticEvent, useEffect, useState } from 'react' import React, { SyntheticEvent, useEffect, useState } from 'react'
import { FileType } from '../types' import { FileType } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars

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

@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line no-use-before-define
import React, { useReducer, useState, useEffect, SyntheticEvent } from 'react' import React, { useReducer, useState, useEffect, SyntheticEvent } from 'react'
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
@ -166,6 +166,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
}) })
} }
// eslint-disable-next-line no-undef
const modal = (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => { const modal = (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
setModals(modals => { setModals(modals => {
modals.push({ message, title, okLabel, okFn, cancelLabel, cancelFn }) modals.push({ message, title, okLabel, okFn, cancelLabel, cancelFn })

@ -1,4 +1,9 @@
import React from 'react'
import { customAction } from '@remixproject/plugin-api/lib/file-system/file-panel' import { customAction } from '@remixproject/plugin-api/lib/file-system/file-panel'
export type action = { name: string, type?: Array<'folder' | 'gist' | 'file'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean }
export type MenuItems = action[]
export interface WorkspaceProps { export interface WorkspaceProps {
plugin: { plugin: {
setWorkspace: ({ name: string, isLocalhost: boolean }, setEvent: boolean) => void, setWorkspace: ({ name: string, isLocalhost: boolean }, setEvent: boolean) => void,
@ -36,6 +41,7 @@ export interface WorkspaceState {
export interface Modal { export interface Modal {
hide?: boolean hide?: boolean
title: string title: string
// eslint-disable-next-line no-undef
message: string | JSX.Element message: string | JSX.Element
okLabel: string okLabel: string
okFn: () => void okFn: () => void
@ -62,6 +68,7 @@ export interface FileExplorerProps {
focusEdit: string, focusEdit: string,
focusElement: { key: string, type: 'file' | 'folder' | 'gist' }[], focusElement: { key: string, type: 'file' | 'folder' | 'gist' }[],
dispatchCreateNewFile: (path: string, rootDir: string) => Promise<void>, dispatchCreateNewFile: (path: string, rootDir: string) => Promise<void>,
// eslint-disable-next-line no-undef
modal:(title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, modal:(title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
dispatchCreateNewFolder: (path: string, rootDir: string) => Promise<void>, dispatchCreateNewFolder: (path: string, rootDir: string) => Promise<void>,
readonly: boolean, readonly: boolean,
@ -90,10 +97,6 @@ export interface FileExplorerMenuProps {
publishToGist: (path?: string) => void, publishToGist: (path?: string) => void,
uploadFile: (target: EventTarget & HTMLInputElement) => void uploadFile: (target: EventTarget & HTMLInputElement) => void
} }
export type action = { name: string, type?: Array<'folder' | 'gist' | 'file'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean }
export type MenuItems = action[]
export interface FileExplorerContextMenuProps { export interface FileExplorerContextMenuProps {
actions: action[], actions: action[],
createNewFile: (folder?: string) => void, createNewFile: (folder?: string) => void,

Loading…
Cancel
Save