mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Open New Block and Delete Files (#76)
This implements the behavior for the context menu recently added to the directories. Open New Block simply opens the file in a preview in a new block. Delete files will delete the selected file, but it does not trigger a rerender at this time. To see the change, you must navigate to a different directory and then return. This will be fixed in a future update.
This commit is contained in:
parent
a012de8413
commit
182c5f6e3d
@ -51,6 +51,9 @@ class FileServiceType {
|
||||
AddWidget(arg1: WidgetsConfigType): Promise<void> {
|
||||
return WOS.callBackendService("file", "AddWidget", Array.from(arguments))
|
||||
}
|
||||
DeleteFile(arg1: string): Promise<void> {
|
||||
return WOS.callBackendService("file", "DeleteFile", Array.from(arguments))
|
||||
}
|
||||
GetSettingsConfig(): Promise<any> {
|
||||
return WOS.callBackendService("file", "GetSettingsConfig", Array.from(arguments))
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright 2024, Command Line Inc.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as services from "@/store/services";
|
||||
import * as util from "@/util/util";
|
||||
import {
|
||||
Table,
|
||||
@ -14,7 +15,7 @@ import clsx from "clsx";
|
||||
import * as jotai from "jotai";
|
||||
import React from "react";
|
||||
import { ContextMenuModel } from "../store/contextmenu";
|
||||
import { atoms } from "../store/global";
|
||||
import { atoms, createBlock } from "../store/global";
|
||||
|
||||
import "./directorypreview.less";
|
||||
|
||||
@ -121,14 +122,18 @@ function handleFileContextMenu(e: React.MouseEvent<HTMLDivElement>, path: string
|
||||
let menu: ContextMenuItem[] = [];
|
||||
menu.push({
|
||||
label: "Open in New Block",
|
||||
click: () => {
|
||||
alert("Not Implemented");
|
||||
click: async () => {
|
||||
const blockDef = {
|
||||
view: "preview",
|
||||
meta: { file: path },
|
||||
};
|
||||
await createBlock(blockDef);
|
||||
},
|
||||
});
|
||||
menu.push({
|
||||
label: "Delete File",
|
||||
click: () => {
|
||||
alert("Not Implemented");
|
||||
click: async () => {
|
||||
await services.FileService.DeleteFile(path).catch((e) => console.log(e)); //todo these errors need a popup
|
||||
},
|
||||
});
|
||||
ContextMenuModel.showContextMenu(menu, e);
|
||||
@ -262,6 +267,8 @@ interface TableBodyProps {
|
||||
}
|
||||
|
||||
function TableBody({ table, cwd, setFileName }: TableBodyProps) {
|
||||
let [refresh, setRefresh] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div className="dir-table-body">
|
||||
{table.getRowModel().rows.map((row) => (
|
||||
|
4
frontend/types/gotypes.d.ts
vendored
4
frontend/types/gotypes.d.ts
vendored
@ -288,8 +288,8 @@ declare global {
|
||||
data64: string;
|
||||
};
|
||||
|
||||
// eventbus.WSLayoutAction
|
||||
type WSLayoutAction = {
|
||||
// eventbus.WSLayoutActionData
|
||||
type WSLayoutActionData = {
|
||||
tabid: string;
|
||||
actiontype: string;
|
||||
blockid: string;
|
||||
|
@ -131,6 +131,11 @@ func (fs *FileService) GetWaveFile(id string, path string) (any, error) {
|
||||
return file, nil
|
||||
}
|
||||
|
||||
func (fs *FileService) DeleteFile(path string) error {
|
||||
cleanedPath := filepath.Clean(wavebase.ExpandHomeDir(path))
|
||||
return os.Remove(cleanedPath)
|
||||
}
|
||||
|
||||
func (fs *FileService) GetSettingsConfig() interface{} {
|
||||
watcher := wconfig.GetWatcher()
|
||||
return watcher.GetSettingsConfig()
|
||||
|
Loading…
Reference in New Issue
Block a user