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