fix: fmt
This commit is contained in:
		@ -215,7 +215,10 @@ export const ProjectExplorer = ({
 | 
			
		||||
                  systemIOActor.send({
 | 
			
		||||
                    type: SystemIOMachineEvents.createBlankFolder,
 | 
			
		||||
                    data: {
 | 
			
		||||
                      requestedAbsolutePath: joinOSPaths(getParentAbsolutePath(row.path), requestedName)
 | 
			
		||||
                      requestedAbsolutePath: joinOSPaths(
 | 
			
		||||
                        getParentAbsolutePath(row.path),
 | 
			
		||||
                        requestedName
 | 
			
		||||
                      ),
 | 
			
		||||
                    },
 | 
			
		||||
                  })
 | 
			
		||||
                } else {
 | 
			
		||||
@ -225,7 +228,9 @@ export const ProjectExplorer = ({
 | 
			
		||||
                    data: {
 | 
			
		||||
                      requestedFolderName: requestedName,
 | 
			
		||||
                      folderName: name,
 | 
			
		||||
                      absolutePathToParentDirectory: getParentAbsolutePath(row.path)
 | 
			
		||||
                      absolutePathToParentDirectory: getParentAbsolutePath(
 | 
			
		||||
                        row.path
 | 
			
		||||
                      ),
 | 
			
		||||
                    },
 | 
			
		||||
                  })
 | 
			
		||||
                  // TODO: Gotcha... Set new string open even if it fails?
 | 
			
		||||
@ -240,7 +245,6 @@ export const ProjectExplorer = ({
 | 
			
		||||
                    setOpenedRows(newOpenedRows)
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
              }
 | 
			
		||||
            } else {
 | 
			
		||||
              // rename a file
 | 
			
		||||
@ -259,19 +263,25 @@ export const ProjectExplorer = ({
 | 
			
		||||
                systemIOActor.send({
 | 
			
		||||
                  type: SystemIOMachineEvents.createBlankFile,
 | 
			
		||||
                  data: {
 | 
			
		||||
                    requestedAbsolutePath: joinOSPaths(getParentAbsolutePath(row.path),fileNameForcedWithOriginalExt)
 | 
			
		||||
                    requestedAbsolutePath: joinOSPaths(
 | 
			
		||||
                      getParentAbsolutePath(row.path),
 | 
			
		||||
                      fileNameForcedWithOriginalExt
 | 
			
		||||
                    ),
 | 
			
		||||
                  },
 | 
			
		||||
                })
 | 
			
		||||
              } else { 
 | 
			
		||||
              } else {
 | 
			
		||||
                // rename the file otherwise
 | 
			
		||||
                systemIOActor.send({
 | 
			
		||||
                type: SystemIOMachineEvents.renameFile,
 | 
			
		||||
                data: {
 | 
			
		||||
                  requestedFileNameWithExtension: fileNameForcedWithOriginalExt,
 | 
			
		||||
                  fileNameWithExtension: name,
 | 
			
		||||
                  absolutePathToParentDirectory: getParentAbsolutePath(row.path)
 | 
			
		||||
                },
 | 
			
		||||
              })
 | 
			
		||||
                  type: SystemIOMachineEvents.renameFile,
 | 
			
		||||
                  data: {
 | 
			
		||||
                    requestedFileNameWithExtension:
 | 
			
		||||
                      fileNameForcedWithOriginalExt,
 | 
			
		||||
                    fileNameWithExtension: name,
 | 
			
		||||
                    absolutePathToParentDirectory: getParentAbsolutePath(
 | 
			
		||||
                      row.path
 | 
			
		||||
                    ),
 | 
			
		||||
                  },
 | 
			
		||||
                })
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
@ -292,10 +302,15 @@ export const ProjectExplorer = ({
 | 
			
		||||
          !!fakeRow?.entry?.children &&
 | 
			
		||||
          fakeRow?.entry?.key === row.parentPath &&
 | 
			
		||||
          row.name === FILE_PLACEHOLDER_NAME
 | 
			
		||||
        const fakeRowIsNullShowRootFile = fakeRow.entry === null && row.parentPath === project.name &&
 | 
			
		||||
        const fakeRowIsNullShowRootFile =
 | 
			
		||||
          fakeRow.entry === null &&
 | 
			
		||||
          row.parentPath === project.name &&
 | 
			
		||||
          row.name === FILE_PLACEHOLDER_NAME
 | 
			
		||||
        showPlaceHolder = showFileAtSameLevel || showFileWithinFolder || fakeRowIsNullShowRootFile
 | 
			
		||||
      } else if (fakeRow?.isFile === false){
 | 
			
		||||
        showPlaceHolder =
 | 
			
		||||
          showFileAtSameLevel ||
 | 
			
		||||
          showFileWithinFolder ||
 | 
			
		||||
          fakeRowIsNullShowRootFile
 | 
			
		||||
      } else if (fakeRow?.isFile === false) {
 | 
			
		||||
        // fake row is a folder
 | 
			
		||||
        const showFolderAtSameLevel =
 | 
			
		||||
          fakeRow?.entry?.parentPath === row.parentPath &&
 | 
			
		||||
@ -306,9 +321,14 @@ export const ProjectExplorer = ({
 | 
			
		||||
          !!fakeRow?.entry?.children &&
 | 
			
		||||
          fakeRow?.entry?.key === row.parentPath &&
 | 
			
		||||
          row.name === FOLDER_PLACEHOLDER_NAME
 | 
			
		||||
        const fakeRowIsNullShowRootFolder = fakeRow.entry === null && row.parentPath === project.name &&
 | 
			
		||||
        const fakeRowIsNullShowRootFolder =
 | 
			
		||||
          fakeRow.entry === null &&
 | 
			
		||||
          row.parentPath === project.name &&
 | 
			
		||||
          row.name === FOLDER_PLACEHOLDER_NAME
 | 
			
		||||
        showPlaceHolder = showFolderAtSameLevel || showFolderWithinFolder || fakeRowIsNullShowRootFolder
 | 
			
		||||
        showPlaceHolder =
 | 
			
		||||
          showFolderAtSameLevel ||
 | 
			
		||||
          showFolderWithinFolder ||
 | 
			
		||||
          fakeRowIsNullShowRootFolder
 | 
			
		||||
      }
 | 
			
		||||
      const skipPlaceHolder =
 | 
			
		||||
        !(
 | 
			
		||||
 | 
			
		||||
@ -249,6 +249,6 @@ export const getEXTWithPeriod = (filePath: string) => {
 | 
			
		||||
export const getParentAbsolutePath = (absolutePath: string) => {
 | 
			
		||||
  const split = desktopSafePathSplit(absolutePath)
 | 
			
		||||
  split.pop()
 | 
			
		||||
  const joined =  desktopSafePathJoin(split)
 | 
			
		||||
  const joined = desktopSafePathJoin(split)
 | 
			
		||||
  return joined
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -164,17 +164,17 @@ export const systemIOMachine = setup({
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      | {
 | 
			
		||||
        type: SystemIOMachineEvents.createBlankFile
 | 
			
		||||
        data: {
 | 
			
		||||
          requestedAbsolutePath: string
 | 
			
		||||
          type: SystemIOMachineEvents.createBlankFile
 | 
			
		||||
          data: {
 | 
			
		||||
            requestedAbsolutePath: string
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      | {
 | 
			
		||||
        type: SystemIOMachineEvents.createBlankFolder
 | 
			
		||||
        data: {
 | 
			
		||||
          requestedAbsolutePath: string
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
          type: SystemIOMachineEvents.createBlankFolder
 | 
			
		||||
          data: {
 | 
			
		||||
            requestedAbsolutePath: string
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
  },
 | 
			
		||||
  actions: {
 | 
			
		||||
    [SystemIOMachineActions.setFolders]: assign({
 | 
			
		||||
 | 
			
		||||
@ -271,18 +271,17 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
 | 
			
		||||
 | 
			
		||||
        // Create the project around the file if newProject
 | 
			
		||||
        try {
 | 
			
		||||
        const result = await createNewProjectDirectory(
 | 
			
		||||
          newProjectName,
 | 
			
		||||
          requestedCode,
 | 
			
		||||
          configuration,
 | 
			
		||||
          newFileName
 | 
			
		||||
        ) 
 | 
			
		||||
        console.log(result)
 | 
			
		||||
          const result = await createNewProjectDirectory(
 | 
			
		||||
            newProjectName,
 | 
			
		||||
            requestedCode,
 | 
			
		||||
            configuration,
 | 
			
		||||
            newFileName
 | 
			
		||||
          )
 | 
			
		||||
          console.log(result)
 | 
			
		||||
        } catch (e) {
 | 
			
		||||
          console.error(e)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
          message: 'File created successfully',
 | 
			
		||||
          fileName: newFileName,
 | 
			
		||||
@ -545,7 +544,9 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
 | 
			
		||||
        try {
 | 
			
		||||
          const result = await window.electron.stat(input.requestedAbsolutePath)
 | 
			
		||||
          if (result) {
 | 
			
		||||
            return Promise.reject(new Error(`File ${input.requestedAbsolutePath} already exists`))
 | 
			
		||||
            return Promise.reject(
 | 
			
		||||
              new Error(`File ${input.requestedAbsolutePath} already exists`)
 | 
			
		||||
            )
 | 
			
		||||
          }
 | 
			
		||||
        } catch (e) {
 | 
			
		||||
          console.error(e)
 | 
			
		||||
@ -556,8 +557,8 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
 | 
			
		||||
          requestedAbsolutePath: input.requestedAbsolutePath,
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
  ),
 | 
			
		||||
  [SystemIOMachineActors.createBlankFolder]: fromPromise(
 | 
			
		||||
    ),
 | 
			
		||||
    [SystemIOMachineActors.createBlankFolder]: fromPromise(
 | 
			
		||||
      async ({
 | 
			
		||||
        input,
 | 
			
		||||
      }: {
 | 
			
		||||
@ -569,18 +570,22 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
 | 
			
		||||
      }) => {
 | 
			
		||||
        try {
 | 
			
		||||
          const result = await window.electron.stat(input.requestedAbsolutePath)
 | 
			
		||||
            if (result) {
 | 
			
		||||
            return Promise.reject(new Error(`Folder ${input.requestedAbsolutePath} already exists`))
 | 
			
		||||
          if (result) {
 | 
			
		||||
            return Promise.reject(
 | 
			
		||||
              new Error(`Folder ${input.requestedAbsolutePath} already exists`)
 | 
			
		||||
            )
 | 
			
		||||
          }
 | 
			
		||||
        } catch (e) {
 | 
			
		||||
          console.error(e)
 | 
			
		||||
        }
 | 
			
		||||
        await window.electron.mkdir(input.requestedAbsolutePath, {recursive: true})
 | 
			
		||||
        await window.electron.mkdir(input.requestedAbsolutePath, {
 | 
			
		||||
          recursive: true,
 | 
			
		||||
        })
 | 
			
		||||
        return {
 | 
			
		||||
          message: `File ${input.requestedAbsolutePath} written successfully`,
 | 
			
		||||
          requestedAbsolutePath: input.requestedAbsolutePath,
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
  ),
 | 
			
		||||
    ),
 | 
			
		||||
  },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ export enum SystemIOMachineActors {
 | 
			
		||||
  renameFile = 'renameFile',
 | 
			
		||||
  deleteFileOrFolder = 'deleteFileOrFolder',
 | 
			
		||||
  createBlankFile = 'create blank file',
 | 
			
		||||
  createBlankFolder = 'create blank folder'
 | 
			
		||||
  createBlankFolder = 'create blank folder',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum SystemIOMachineStates {
 | 
			
		||||
@ -42,7 +42,7 @@ export enum SystemIOMachineStates {
 | 
			
		||||
  renamingFile = 'renamingFile',
 | 
			
		||||
  deletingFileOrFolder = 'deletingFileOrFolder',
 | 
			
		||||
  creatingBlankFile = 'creatingBlankFile',
 | 
			
		||||
  creatingBlankFolder = 'creatingBlankFolder'
 | 
			
		||||
  creatingBlankFolder = 'creatingBlankFolder',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const donePrefix = 'xstate.done.actor.'
 | 
			
		||||
@ -75,7 +75,7 @@ export enum SystemIOMachineEvents {
 | 
			
		||||
  renameFile = 'rename file',
 | 
			
		||||
  deleteFileOrFolder = 'delete file or folder',
 | 
			
		||||
  createBlankFile = 'create blank file',
 | 
			
		||||
  createBlankFolder = 'create blank folder'
 | 
			
		||||
  createBlankFolder = 'create blank folder',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum SystemIOMachineActions {
 | 
			
		||||
 | 
			
		||||
@ -239,6 +239,8 @@ const Home = () => {
 | 
			
		||||
    children: [],
 | 
			
		||||
    readWriteAccess: true,
 | 
			
		||||
  }
 | 
			
		||||
  const duplicated1 = JSON.parse(JSON.stringify(kclSamples1))
 | 
			
		||||
  addPlaceHoldersForNewFileAndFolder(duplicated1.children, kclSamples1.path)
 | 
			
		||||
  return (
 | 
			
		||||
    <div className="relative flex flex-col items-stretch h-screen w-screen overflow-hidden">
 | 
			
		||||
      <AppHeader
 | 
			
		||||
@ -424,8 +426,8 @@ const Home = () => {
 | 
			
		||||
        >
 | 
			
		||||
          <ProjectExplorer project={duplicated}></ProjectExplorer>
 | 
			
		||||
          <ProjectExplorer project={duplicated}></ProjectExplorer>
 | 
			
		||||
          <ProjectExplorer project={kclSamples1}></ProjectExplorer>
 | 
			
		||||
          <ProjectExplorer project={kclSamples1}></ProjectExplorer>
 | 
			
		||||
          <ProjectExplorer project={duplicated1}></ProjectExplorer>
 | 
			
		||||
          <ProjectExplorer project={duplicated1}></ProjectExplorer>
 | 
			
		||||
        </section>
 | 
			
		||||
        <ProjectGrid
 | 
			
		||||
          searchResults={searchResults}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user