Skip to content

Commit

Permalink
feat(explorer): interactive connection
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Nov 28, 2024
1 parent 660bcf7 commit fdea578
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
1 change: 0 additions & 1 deletion addons/explorer/src/renderer/FileExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ function openContextMenu(event: MouseEvent, file?: FileEntity) {
<template>
<div class="file-explorer" @contextmenu="openContextMenu">
<nav data-commas class="action-line">
<slot></slot>
<button ref="back" type="button" data-commas :disabled="!hasPreviousValue" @click="goBack">
<VisualIcon name="lucide-undo-2" />
</button>
Expand Down
23 changes: 6 additions & 17 deletions addons/explorer/src/renderer/FileExplorerPane.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<script lang="ts" setup>
import type { TerminalTab } from '@commas/types/terminal'
import * as commas from 'commas:api/renderer'
import { watch } from 'vue'
import FileExplorer from './FileExplorer.vue'
import { getDirectoryProcess } from './compositions'
const { tab } = defineProps<{
tab: TerminalTab,
}>()
const { TerminalBlock, VisualIcon } = commas.ui.vueAssets
const { TerminalBlock } = commas.ui.vueAssets
let directory = $computed({
get: () => tab.cwd,
Expand All @@ -29,31 +30,19 @@ const target = $computed(() => {
if (teletypes.length === 1) return teletypes[0]
})
const isConnected = $computed(() => {
if (!target) return false
return !target.pane && target.idle
})
function send() {
if (!target) return
watch($$(directory), () => {
if (!target || target.pane || !target.idle) return
const command = commas.workspace.getTerminalExecutorCommand({
directory,
shell: target.shell,
})
commas.workspace.executeTerminalTab(target, command)
setTimeout(() => {
commas.workspace.activateTerminalTab(target)
})
}
})
</script>

<template>
<TerminalBlock :tab="tab" class="file-editor-pane">
<FileExplorer v-model="directory">
<button v-if="isConnected" type="button" data-commas @click="send">
<VisualIcon name="lucide-arrow-right" />
</button>
</FileExplorer>
<FileExplorer v-model="directory" />
</TerminalBlock>
</template>

Expand Down

0 comments on commit fdea578

Please sign in to comment.