workspaceTemplate type

pull/5370/head
Aniket-Engg 3 years ago
parent fff6af20e7
commit 255f4f4f8b
  1. 6
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  2. 1
      libs/remix-ui/workspace/src/lib/types/index.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 } from '../types'
import { JSONStandardInput, workspaceTemplate } from '../types'
import { remixDefault } from '../templates'
import { QueryParams } from '@remix-project/remix-lib'
@ -60,7 +60,7 @@ export const createWorkspace = async (workspaceName: string, workspaceTemplateNa
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 (checkSpecialChars(workspaceName) || checkSlash(workspaceName)) throw new Error('special characters are not allowed')
if (await workspaceExists(workspaceName) && template === 'remixDefault') throw new Error('workspace already exists')
@ -77,7 +77,7 @@ export type UrlParametersType = {
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 params = queryParams.get() as UrlParametersType

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

Loading…
Cancel
Save