WorkspaceTemplate type

pull/2353/head
Aniket-Engg 3 years ago
parent 3b023c4d98
commit d7096e0d66
  1. 4
      libs/remix-ui/workspace/src/lib/actions/events.ts
  2. 6
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  3. 2
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -1,6 +1,6 @@
import { extractParentFromKey } from '@remix-ui/helper'
import React from 'react'
import { action } from '../types'
import { action, WorkspaceTemplate } from '../types'
import { displayNotification, displayPopUp, fileAddedSuccess, fileRemovedSuccess, fileRenamedSuccess, folderAddedSuccess, loadLocalhostError, loadLocalhostRequest, loadLocalhostSuccess, removeContextMenuItem, removeFocus, rootFolderChangedSuccess, setContextMenuItem, setMode, setReadOnlyMode } from './payload'
import { addInputField, createWorkspace, deleteWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from './workspace'
@ -10,7 +10,7 @@ let plugin, dispatch: React.Dispatch<any>
export const listenOnPluginEvents = (filePanelPlugin) => {
plugin = filePanelPlugin
plugin.on('filePanel', 'createWorkspaceReducerEvent', (name: string, workspaceTemplateName, isEmpty = false, cb: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => {
plugin.on('filePanel', 'createWorkspaceReducerEvent', (name: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => {
createWorkspace(name, workspaceTemplateName, isEmpty, cb)
})

@ -4,7 +4,7 @@ import axios, { AxiosResponse } from 'axios'
import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload'
import { checkSlash, checkSpecialChars } from '@remix-ui/helper'
import { JSONStandardInput, workspaceTemplate } from '../types'
import { JSONStandardInput, WorkspaceTemplate } from '../types'
import { QueryParams } from '@remix-project/remix-lib'
@ -59,7 +59,7 @@ export const createWorkspace = async (workspaceName: string, workspaceTemplateNa
return promise
}
export const createWorkspaceTemplate = async (workspaceName: string, template: workspaceTemplate = 'remixDefault') => {
export const createWorkspaceTemplate = async (workspaceName: string, template: WorkspaceTemplate = 'remixDefault') => {
if (!workspaceName) throw new Error('workspace name cannot be empty')
if (checkSpecialChars(workspaceName) || checkSlash(workspaceName)) throw new Error('special characters are not allowed')
if (await workspaceExists(workspaceName) && template === 'remixDefault') throw new Error('workspace already exists')
@ -76,7 +76,7 @@ export type UrlParametersType = {
url: string
}
export const loadWorkspacePreset = async (template: workspaceTemplate = 'remixDefault') => {
export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDefault') => {
const workspaceProvider = plugin.fileProviders.workspace
const params = queryParams.get() as UrlParametersType

@ -13,7 +13,7 @@ export interface JSONStandardInput {
};
}
export type MenuItems = action[]
export type workspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault'
export type WorkspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault' | 'blank' | 'erc20'
export interface WorkspaceProps {
plugin: {
setWorkspace: ({ name: string, isLocalhost: boolean }, setEvent: boolean) => void,

Loading…
Cancel
Save