Action

Copy Workspace URL

Posted by agiletortoise, Last update almost 2 years ago

Prompt to select from a list of available Workspaces, and place a URL in the system clipboard that will open that Workspace.

Steps

  • script

    // select from a list of workspace and load
    
    let f = () => {
       if (!app.isPro) {
           alert("Draft Pro required");
       	    return false;
       }
    
    	let workspaces = Workspace.getAll();
    	if (workspaces.length == 0) {
    		alert("No workspaces defined.");
    		return false;
    	}
    	
    	let p = Prompt.create();
    	p.title = "Copy Workspace URL";
    	p.message = "Choose workspace. A URL to open that workspace will by placed in the system clipboard.";
    	
    	let ix = 0;
    	for (let ws of workspaces) {
    		p.addButton(ws.name, ix, false);
    		ix++;
    	}
    	
    	p.addButton("Default Workspace", -1, true);
    	
    	if (!p.show()) {
    		return false;
    	}
    	
    	let selectedIndex = p.buttonPressed;
    	if (selectedIndex == -1) { // default
    	    app.setClipboard(`drafts://workspace?name=default`)
    	}
    	else {
    		let ws = workspaces[selectedIndex];
    		app.setClipboard(`drafts://workspace?name=${encodeURIComponent(ws.name)}`)
    	}
    }
    
    if (!f()) {
    	context.cancel();
    }

Options

  • After Success Nothing
    Notification Info
    Log Level None
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.