feat: allow launchApp to open explorer at a specific path

This commit is contained in:
jelveh
2024-11-15 15:29:23 -08:00
parent cdd1a8c4e3
commit 8fefd4a61f
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -2879,6 +2879,10 @@ window.navbar_path_droppable = (el_window)=>{
*
*/
window.navbar_path = (abs_path)=>{
// remove trailing slash
if(abs_path.endsWith('/') && abs_path !== '/')
abs_path = abs_path.slice(0, -1);
const dirs = (abs_path === '/' ? [''] : abs_path.split('/'));
const dirpaths = (abs_path === '/' ? ['/'] : [])
const path_seperator_html = `<img class="path-seperator" draggable="false" src="${html_encode(window.icons['triangle-right.svg'])}">`;
+14
View File
@@ -129,6 +129,20 @@ const launch_app = async (options)=>{
else
title = path.dirname(options.path);
// if options.args.path is provided, use it as the path
if(options.args?.path){
// if args.path is provided, enforce the directory
let fsentry = await puter.fs.stat(options.args.path);
if(!fsentry.is_dir){
let parent = path.dirname(options.args.path);
if(parent === options.args.path)
parent = window.home_path;
options.path = parent;
}else{
options.path = options.args.path;
}
}
// open window
el_win = UIWindow({
element_uuid: uuid,