diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index f5efe07019..188087d4fb 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.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 export const listenOnPluginEvents = (filePanelPlugin) => { plugin = filePanelPlugin - plugin.on('filePanel', 'createWorkspaceReducerEvent', (name: string, workspaceTemplateName, isEmpty = false, cb: (err: Error, result?: string | number | boolean | Record) => void) => { + plugin.on('filePanel', 'createWorkspaceReducerEvent', (name: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb: (err: Error, result?: string | number | boolean | Record) => void) => { createWorkspace(name, workspaceTemplateName, isEmpty, cb) }) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 515534a940..5281fc806a 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -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 diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index 137ccd3a01..b2d490713b 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -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,