Power tool for busy Benchling admins and devs
I have one client with 5 Benchling tenants, another with 3, various others with a pair each. This means that I’m frequently bouncing into Feature Settings or the tenant-specific API pages. How about you? To get to each of these pages via the UI is not hard but does take some clicks and mouse travel (and an extra page load to get to your personal settings before getting to the API page). If you manage just a pair of tenants, you can just bookmark these pages on your bookmarks bar, and you’ll be good to go. However, if you manage more than two tenants, then have I got a goody for you!
Like most of us, I’m quite busy and juggling a lot of diverse activities. Anything that adds even a little friction breaks the cognitive flow, impacts productivity, and increases stress. Since I’m jumping into the Feature Settings and API pages many times a day, I was getting frustrated and wanted to find a way to get to these pages faster.
The problem is that the URLs for each of these pages includes the tenant host name. Therefore, it’s different for each tenant. I could bookmark these, but that would be over two dozen for environments I’m actively using. That won’t save anything. What I really want is a built-in Benchling keyboard shortcut. (I’ve submitted the idea for a polish bash, we’ll see.)
After exploring various options, I finally came up with a solution that works great and I’m happy to share it with you here. The solution is based on using Alfred workflows (this is a Mac-only solution; if you are not using a Mac, then maybe this will inspire you to build an equivalent for Windows).
In the end it’s pretty simple (though I’ll admit I had to fight with this for a while to get it working). For each page type, I created an Alfred workflow (using a common script) that maps a hotkey to an AppleScript to compute the target URL which is then used to open a new tab.
There is an environment variable that tells the script which suffix to append to the base URL (this allows for configurability and the ability to reuse the AppleScript). Once set up, when you are on a page with a host name ending with “.benchling.com” just press the hotkey and a new Feature Settings (or API) tab will open using the same host name (tenant) based on your currently active tab.
For the Feature Settings page case, I land on the sub-page for Configuration Migration. There are a couple of reasons for this. First, Configuration Migration is awesome, and I use it frequently (apparently, I’m the most frequent user of the feature according to the PM). The other reason is more pragmatic. The URLs for the Registry, Template Collections, and various other sub-pages in Feature Settings embed either the registry ID or a user handle. The registry ID will obviously be different across tenants so I can’t encode that in the URL. The user handle might be okay for you, but my handle is different on some tenants, so I avoid using that. I’m happy enough to just land on any part of the Feature Settings page since the specific sub-feature I need varies a lot, and once the page is loaded it’s an easy secondary click.
If you want to optimize and set up hotkeys for different or more pages, you can modify the script in a couple of ways. First, if you have the same user handle across tenants, then you can encode that in the SUFFIX environment variable. If you really want to get directly to a page whose URL embeds a registry ID or other such unique value, then you could create a lookup table of all possible URLs you might want and use the host name to look up the URL for the given type of sub-feature.
The script below is hopefully sufficiently documented that you can use it to configure everything.
(*
This script is triggered by an Alfred 5 hotkey trigger.
This only works with Google Chrome and only when the current tab's hostname ends with .benchling.com.
This is Mac specific.
My current configuration uses the following hotkeys:
Shift-Command-F => Open a Feature Settings tab for the current tenant
Shift-Command-X => Open a Tenant-specific Open API tab for the current tenant
The Alfred 5 workflow is as follows:
1. Hotkey
2. Run script
Language: /usr/bin/osascript (AppleScript)
Input: with input as argv
Running instances: Sequentially
3. Transform (Trim Whitespace)
This is required since the script adds a %0A in its return statement and I couldn't find a way to prevent that.
4. Open URL
URL {var:newURL}
Open with Default Browser
Encoding: Check box Encode boxes
In the workflow configuration, set the SUFFIX environment variable as follows:
"/config-migration"
Use this to open a Feature settings tab. I use Configuration Migration instead
of Registry or Template Collections since those require parameters that I don't have.
"/api/reference"
Use this to open the tenant-specific Open API page
Author: Ken Robbins, Go2 Software
Benchling Bistro blog: https://medium.com/benchling-bistro
LinkedIn: https://www.linkedin.com/in/kerobbins/
*)
on run
-- Get the configuration variable from the environment
set suffix to system attribute "SUFFIX"
tell application "Google Chrome"
activate
-- Get the URL of the active tab of the front window
set currentTabURL to URL of active tab of front window
-- Extract the hostname from the currentTabURL
set AppleScript's text item delimiters to "/"
set hostname to text items 1 thru 3 of currentTabURL as text
-- Abort the workflow if the hostname does not end with .benchling.com
if hostname does not end with ".benchling.com" then
return ""
end if
set newURL to hostname & suffix
-- display dialog newURL -- Useful for debugging
return newURL
end tell
end run
I hope you find this is useful as I do. If you have any improvements or feedback, please let me know.
I hope you find this useful and that I’ve made it easy to reduce to practice! Please provide feedback on the content, style, and most importantly what you want to hear about. Be sure to “follow” to be notified of new articles.