Action

Select Workspace

Posted by @jsamlarose, Last update about 3 years ago - Unlisted

Prompt to select from a list of available Workspaces, and load the selected workspace.

Slight edit to this original action: https://actions.getdrafts.com/a/1SG
… in order to answer this: https://forums.getdrafts.com/t/modify-select-workspace-action/9680

Steps

  • script

    // select from a list of workspace and load
    
    // set keyword to filter workspaces here: 
    let filter = "scripting"
    
    let f = () => {
    	let workspaces = Workspace.getAll();
    	if (workspaces.length == 0) {
    		alert("No workspaces defined.");
    		return false;
    	}
    	
    	let p = Prompt.create();
    	p.title = "Select Workspace";
    	p.message = "Choose workspace to apply";
    	
    	let ix = 0;
    	for (let ws of workspaces) {
    		if (ws.name.includes(filter)){
    		p.addButton(ws.name, ix);
    		ix++;
    		}
    	}
    	
    	if (!p.show()) {
    		return false;
    	}
    	
    	let selectedIndex = p.buttonPressed;
    	let ws = workspaces[selectedIndex];
    	app.applyWorkspace(ws);
    	app.showDraftList();
    }
    
    if (!f()) {
    	context.cancel();
    }

Options

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