Provide a way to open app folder in finder (#42)
This commit is contained in:
@@ -22,4 +22,24 @@ export function registerShellHandlers() {
|
||||
return { success: false, error: (error as Error).message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("show-item-in-folder", async (_event, fullPath: string) => {
|
||||
try {
|
||||
// Validate that a path was provided
|
||||
if (!fullPath) {
|
||||
logger.error("Attempted to show item with empty path");
|
||||
return {
|
||||
success: false,
|
||||
error: "No file path provided.",
|
||||
};
|
||||
}
|
||||
|
||||
shell.showItemInFolder(fullPath);
|
||||
logger.debug("Showed item in folder:", fullPath);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
logger.error(`Failed to show item in folder ${fullPath}:`, error);
|
||||
return { success: false, error: (error as Error).message };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -292,8 +292,22 @@ export class IpcClient {
|
||||
return result as { success: boolean; error?: string };
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
// Ensure a consistent return type even on invoke error
|
||||
return { success: false, error: (error as Error).message };
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async showItemInFolder(
|
||||
fullPath: string
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
try {
|
||||
const result = await this.ipcRenderer.invoke(
|
||||
"show-item-in-folder",
|
||||
fullPath
|
||||
);
|
||||
return result as { success: boolean; error?: string };
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
MessageCircle,
|
||||
Pencil,
|
||||
Github,
|
||||
Folder,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
Popover,
|
||||
@@ -159,6 +160,8 @@ export default function AppDetailsPage() {
|
||||
);
|
||||
}
|
||||
|
||||
const fullAppPath = appBasePath.replace("$APP_BASE_PATH", selectedApp.path);
|
||||
|
||||
return (
|
||||
<div className="relative min-h-screen p-4 w-full">
|
||||
<Button
|
||||
@@ -232,9 +235,20 @@ export default function AppDetailsPage() {
|
||||
<span className="block text-gray-500 dark:text-gray-400 mb-0.5 text-xs">
|
||||
Path
|
||||
</span>
|
||||
<span className="text-sm break-all">
|
||||
{appBasePath.replace("$APP_BASE_PATH", selectedApp.path)}
|
||||
</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm break-all">{fullAppPath}</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="p-0.5 h-auto cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
||||
onClick={() => {
|
||||
IpcClient.getInstance().showItemInFolder(fullAppPath);
|
||||
}}
|
||||
title="Show in folder"
|
||||
>
|
||||
<Folder className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex flex-col gap-2">
|
||||
|
||||
@@ -30,6 +30,7 @@ const validInvokeChannels = [
|
||||
"set-user-settings",
|
||||
"get-env-vars",
|
||||
"open-external-url",
|
||||
"show-item-in-folder",
|
||||
"reset-all",
|
||||
"nodejs-status",
|
||||
"install-node",
|
||||
|
||||
Reference in New Issue
Block a user