It has been a while since I have shown any love to this Power-Up. It has a LOT of users that use it a LOT. And unfortunately, for me they use the FREE features only. It might be a bit draconian, but with nearly 75,000 website hits per week from this one Power-Up alone, I added a retro-active limitation of only 5 pocket cards per board without a subscription. But I added a LOT to the subscription. Now you get all these features:
Epic cards, with epic covers and the ability to track resources, cost, budget, completeness, priority and deadline date.
You also have the ability to set cards to be pocketed at a future date.
Additionally, you can set cover colors, and
have more than 5 Pocket or Epic cards on the board.
Additional enhancement includes a bit of a redesign on the UI (star on the default pocket card), and more options on the back of the card. If these update garner more subscribers, I have even more planned:
Custom fields on Epics
Better pocketed card preview
Ability to edit the name, description or add comments to pocketed cards
Ability to select cards to pocket from the board, from the back of a pocket card, and
this includes searching for cards and adding them as well.
And much, much, more.
But I need more subscribers first. Please check it out: Pocket a Card
I was recently posting an issue in the Developer Forum for Trello and found a post I could answer fairly quickly since I knew the answer already. Thought I would share it here on my blog as well.
The question was along the lines of:
How do I show my board button only to members of the board who have paid for it? Or how do I block guests from getting the board button?
Here is the code:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message: "Sorry you are only a guest on this board!",
duration: 1,
});
return []; // no board button for you
}
/** @type {TrelloBoardButtonOption} */
const button = {
text: "hello",
icon: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAF2SURBVDhPtZMxT8JQEMfb0pI2xMbA0JWyNXQEJLHO7VrmfgAHTfgMLMTo0FknDU0TNze+gCbOSmSBwU2hgxMlAevd8wV95GG6+Euu73/v/e/aXlPhX8myrIBBUy4iXRmCIDicTqeeqqoHmKdp+lir1YaDweCeGHZx1u/vHTnOpWEYqSiKGWyRQI17juNc9cFDzNvEUay2ms1bkJtCXjTBE0WRCprFc70TTdO4Rb8DPa7rnoL+odfr6bZtP4HkFm0HeJ+xBrQg4WU+n7eSJLFR5wH8dfC3UJMGy+WyDJNGmQvwC4vFooyaNFAUZVUo/Pm5GdBbLBZXqEkD2Bjpuv6BOg/olSRpRNNv2u32NSzcoW0HeG9gJZAnQOx6/cKsVmc03YlZNWfgPacpi+/7rmma7yC5d8azDnhAb2AmNx6PJ77fGWqaqsmyvF8qleB19c9KpfJqWdZdo9E4juP4gdoJ3J8J6Xa7BgzXQr1er1/CMHwjBwyC8AW6vpgYpmCzMQAAAABJRU5ErkJggg==`, // for card front badges only
Are you a Trello enthusiast looking to start developing you own Power-Up? Trello Power-Ups are custom integrations add new functionality to your Trello boards, and creating one yourself is easier than you might think.
I created the following tutorial to walk you through the process of developing a Trello Power-Up in Visual Studio Code using npm (Node Package Manager). By the end, you’ll have a basic project that you can further enhance as needed. But this will take you some time. I took my time walking through this and it took me a good hour to get through all the steps below. The good news is once you have done this, you will have a quick, easy to use project that is totally reusable for multiple Power-Ups. With that said, let’s get started…
Prerequisites
Before we dive in, make sure you have the following prerequisites:
Node.js and npm: If you don’t have Node.js and npm installed, download and install them from the official website here.
Trello Account: You’ll need a Trello account to create and test your Power-Up.
Once you have VS Code install, here are some suggested Extensions to make your life MUCH easier:
ESLint
Code Spell Checker
Prettier – Code formatter
Inline HTML
Something to read so you can get an idea of how powerful VS Code can be with extensions and other capabilities, here is more about JavaScript development in VS Code: https://code.visualstudio.com/Docs/languages/javascript
Step 1: Create your Project Folder
In the least you ONLY need two files [index.js] and [index.html]. But it helps to build out your project with the proper folder structure right off the bat. So here are the folders I create:
[certs] – required for local development and covered later
[js] – for all your code files
+– [common] – where you will keep common files (usually static defined stuff)
+– [pages] – for all your js page files (more below)
+– [components] – we will not get to this here, but might cover it in a future post.
When I decided to make the Type Definitions file for Trello Power-Ups it CHANGED MY LIFE. Now, it is not perfect and I am still working on adding things to it, and find errors every now and then, but please notify me if you find anything wrong. But when I added this to my project it took the guesswork out of creating a Power-Up, in that “what does this return”, or “what are the properties of this or that.” And I did not have to have the Trello API reference page open in the browser all the time. My code got cleaner, more concise, and I was able to more quickly develop Power-Ups.
Step 2: Add files and Code
So, now we add the files.
If you do things “creatively” – correctly in my opinion – you really only need one HTML file for your WHOLE project even if you open multiple forms.
In the [views] folder, create the [index.html] file:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now in the root of the [js/common] folder you will create a file [common.js]:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now in the root of the [js] folder create the [client.js] file:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hooking to the board buttons callback from Trello and adding a custom board button
The button calls the Trello List Popup (essentially menu), when clicked.
In that menu, I added ONE item, to show the settings in a pop-up iframe. Now, this is where things get interesting…
You might see how I might be doing something different from what Trello tutorials might have you doing. But if you look at the iframe reference, to Common.detailsPage, you will see that we added that as “details.html.” But WAIT, you did not ask me to create that page, so how is it going to work? Trust me, it will and in a moment, I will show you how it all works out. First clue is something called Web Pack. The second is pay close attention to the ARGS we are sending.
Next, create a new file called [details.js] and place it in the [js] folder with [details.js]. Here is the code for that page:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What we are doing here is setting this up for “reuse.” Gosh, I love that word. “Reuse,” said it again. REUSE. Ok…
So, we read the PAGE args (remember how I told you to pay close attention). I ask Trello for the arg passed call “page” and from that get which page to load. I then create an instance of a page object.
Now this is where I love, love, love ES6 and classes. I created an instance of the SettingsPage class and called render on it, passing the ever-important reference to the Trello context object (t). But what the heck, there still is not a Settings Page and details.html still does not exist??? Wait for it…
Now, in the [pages] folder, you will create the [settingsPage.js] file, and you will add this code:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What we are doing here is PURE ES6 GLORIOUS MAGIC. I generate a string using inline HTML (via the beautiful backtick), and you will see some VS Code fun stuff (/*html*/), this makes your code look like React inline HTML via the Inline HTML extension. OMG, it is awesome. Ok, then remember in the [index.html] file the div with the “id” of “content.” Well, I then assign the HTML string to the content div and viola, the settings page comes alive in the iframe of the Trello Popup window – just like that. And then because it is dynamic, I hook to the controls I created, add event hooks and such. I then call t.sizeTo() to tell Trello to fit the contents of the iframe neatly into the Popup window.
Hey, but there still is not a [details.html] page… should I not go and create that? NO!!! It’s coming, I promise.
Now, that is it for the code that makes your Power-Up tick. The rest is getting the development environment configured for runtime testing and building your code via Web Pack.
Step 3: Set Up Node and Web Pack
So, writing the code is half the battle. You could just make a copy if index.html and called it details.html place all the above code on a web server and call it a day. And everything will run.
But building a Power-Up and being able to update and test your code live is crucial to being able to make a compelling Power-Up in short order. You could just make changes, publish to the web, test, rinse – repeat. But it will take you a long time, frustration and for just a little more work, you will get SO MUCH MORE. And finally, your code will not be optimized (minified) for better browser runtime compile. So, here is how you round out your development environment for a Trello Power-Up.
Next thing you do is create a [package.json] at the root of the project folder. This file will tell NODE which packages to go pull of the Internet so that you can do the paragraph above. Here is the code:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The next thing you need is the Web Pack file. Ok, remember how I kept putting off the creating the [details.html] file. Wait for it…
The following file is going to look rather complex if you have not used Web PAck before. What this does it tells NODE how to “compile” your code and setup the development environment for local development testing.
So, let’s get started by adding the following file to the root of you project folder [webpack.config.js]:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am not going into huge depth explaining this file as that is a whole post on its own. Bottom line what this is doing is configuring web pack. I will explain it like this:
defines the core entry points as chunks [detial.js] and [client.js].
in the plugins section, you will see the “reuse” coolness I was referring to above. On the fly we use the same file [index.html] for creating TWO files: index and details. And there you have it.
the devServer is the last bit that makes this whole journey worthwhile. This creates a NODE server on your box, running on port 12345.
Your own Dev Server running locally on your box is the key but it will not work without this next bit. Trello REQUIRES all connections to be protected by HTTPS, so you MUST have SSL certificates.
Generating certs is a mild amount of pain, but with a LONG-TERM gain. So, you WILL need to do this part. And it is not hard. Here is how you generate a cert (and key) for yourself:
It will ask you for a passphrase (something like “test” is ok), and to confirm the passphrase, then country, state, city, company, unit, and such. Nothing is critical here, put what you want for these fields.
It will create two files in the root of your project [server.crt] and [server.key].
Move these files to the [certs] folder.
And this cert is good for 10 years, so you can add it to all your future projects.
You are now ready to start development. Open a terminal (press CTRL+`) and in the root directory of your project, run the following command to enable/init/update the project:
npm update
This pulls in all the bits to make your development environment come alive.
Step 4: Setup Trello Admin Panel
To test your Power-Up, you can use the Trello development sandbox. Ensure you’ve created a Trello board and head to https://trello.com/power-ups/admin to enable the developer mode (see Trello documentation on this part).
Then, add your Power-Up to start testing. Here are the steps for our demo:
You will see a REJECTION, something like: Your connection isn’t private!
You must click Advanced, then click [Continue to localhost (unsafe)]
You can get around this by adding the certificate to the Trusted Root Certificate Authorities on your computer. But that is different for Mac and Windows users, so I will let you look that one up on your own.
By the way, I never do that. I just ALWAYS run this step before I run locally. Just remember if you go into Trello and it appears to hang and your Power-Up is not loaded… did you forget this step?
Now we go to Trello to add your Power-Up. Go to Trello, and go to your board:
Click Power-Ups, Add Power-Up.
Go to the Custom option.
Select Hello World, then click Add.
You will now see the [Hello World] board button appears. You are now running a local developer environment from VS Code with a live running debug in Trello. Go make a code change, refresh the browser and viola – your updated code changes are there and ready to test.
Now a word about “DEBUG.” I have not found a way to really hook up VS Code to Edge/Chrome yet and live debug. I am sure there is a way and if someone knows, please add a comment — I will give it a whirl and add a future post. What I do instead is open F12. When I get an error, it usually tells me the exact line it failed on, and I can go there in VS Code. I also use a lot of console.log() statements to follow code flow and get results. And when I feel particularly stuck, I though in a good debugger; line or two in the code so the F12 tools stop, and I can review things there. In the end this has worked rather well, but I really would like to be able to set a breakpoint in VS Code too… for now, I am happy enough.
Conclusion
Creating a Trello Power-Up in Visual Studio Code using npm is the only way to go as far as I am concerned.
Happy coding, and remember, the possibilities are endless when it comes to creating Trello Power-Ups to match your specific workflow. And over time, I will probably extend on this Power-Up tutorial as I find new things to write about.
I have developed 6 Power-Ups now for Trello. When I first started developing for Trello it was HARD to keep track of and use the Power-Up API. I would ask myself questions like:
“t.alert(), is the JSON it takes {message:’…’} or {text:’…’} and was the delay set with ‘duration’ or ‘time’…?”
I kept having to jump back and forth from the online documentation and my code. It took forever. My code was full of errors. I usually did not know I got something wrong until I saw red in the F12 Developer Tools in Edge. It felt so… 1995 all over again.
I might be dating myself a bit here, but when I started development, I learned BASIC on a TI-99/4a. In those days, outside plain old “compile errors” (which, it took a while to compile too), you usually learned about errors when you got a syntax error at runtime. In my first job, job as a developer, I wrote COBOL and you learned about an error in your code when the job failed its run at 2am in the morning and was pulled off the mainframe.
In today’s modern programming landscape, you get intellisense helping you identify the properties of objects and what comes next. You have ChatGPT helping you write out the super complex sorting algorithms. Algorithms, by the way, that you went to college to learn. You know algorithms, those ugly mind warping beasts where professors cackled like Smith in the Matrix as they assigned them. Algorithms that caused you to break and sharpen thousands of #2 pencils. Algorithms that wasted brain-cells. Oh, so many brain cells. And after it all you still only made a C in the class. I digress… So… Yep… we have come a LONG way.
So, given how far we have come it boggles my mind that some object models are not brought forward to work with modern development platforms.
As a Trello developer, the one thing I think helps to keep me sane is that I am able to use the HECK out of the Type Definitions file, which makes my life much easier.
But my Type Definitions file is not perfect, and I am constantly “fixing it” and adding to it.
Yesterday was one such day. I have taken the last 4 months of Trello development (lessons learned, etc.) and published a rather significant update.
As per my previous post, the thing I found most interesting was how Excel full client seems to fail if you configure your server .htaccess file to prevent caching. Well, I found out that my Outlook Send to Trello add-in actually had the same problem too. The Outlook client just happened to refresh this morning and my icon disappeared there too. In Office online it seems to work, but in the full client you cannot seem to force the client to NOT cache. I see my files all pulled down locally in the Wef folder and my concern is that when I update the add-in it will not go get the latest every time… I have actually seem and beat my head over this problem a few times. But the solution there for anyone working on a BETA site for example making changes and all of a sudden the full-client stops refreshing your updates, this is a good article to keep handy.
But when Wef strikes in production, I have found customers are not so excited to blow away this folder and find all their add-ins, preferences, stored cached credentials and other goodies for each and every add-in are gone. Ergo why I added the no-cahce to the .htacess. Oh well. 🙁
Also, just to share something else as I am delving more and more into publishing add-ins for real. As an Office Developer, in the traditional sense (aka boomer 😛, VBA/VSTO/COM), there are aspects of living in an HTML web world that I still learning (although this is an old one it comes up now and again because I forget something).
You have to worry about various attack vectors and sanitizing HTML strings. There are LOTS of libraries and solutions out there and Mozilla even has documented a possible standard supported in several browsers, but not all. It is a tricky thing because some sanitizers do too much or not enough, and then you also rely on a dependency which has now burned me more often than just owning things that might be a hundred lines of code for my own common library of goodies.
So, I have created my own based on various library implementations, and found the best option is to escape most of the stuff you find “injected” rather than remove it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The important thing is that in the web world, anytime you take data from one service to another, or take input in a field, or grab input from some element on a page and insert it back into another element in your code, there is a hack waiting to happen if you do not sanitize.
A popular annual list of top installed Trello Power-ups (Blue Cat Reports) has called out one of my Trello Power-Ups for its quick growth. At less than a year old is already have over 5000+ active installs.
I have really enjoyed writing this bit of code because it stretched from Trello API to Office 365 API, two of my favorite programming interfaces. This Power-Up is similar to the default Trello Calendar Power-up, the key difference being is that it connects to your Outlook Calendar. So, you can see all your Trello Tasks and your Outlook appointments/meetings, side by side in one place, you can link your appointments to Trello cards and vice-versa. With a month view and a weekly view, you can manage your calendar easily by dragging and dropping your Trello Cards on the calendar to create linked appointments for specific tasks all in one place.
In writing my new Outlook Add-in (Send to Trello), I got stuck on attachments. The first version did not include an attachments option because of two unique problems that compounded each other:
The Office Add-in API no longer provides a Media Type/MIME Type with an attachment request. I am able to get the “blob()” from Office, but other than the file extension there is not a way to determine the type. But sometimes a file does not have an extension, or the extension is wrong, etc.
The Trello API will not let you upload without supplying a MIME type, you cannot just give it a Base64 string as an attachment and let them figure it out.
So, I found out something interesting while researching a workaround. Most every base64 string of a specific file type starts with the same “prolog” of text. Using this, combined with the fallback of the file extensions, I was able to get attachments to work (for the attachment types supported by Trello). So, v1.02 will now include attachments.
Anway, as for the workaround I found, this might be ugly, but wanted to share it anyway:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have been using Trello for a while now and one of the features I have found most useful is to take an email I received and turn it into a Kanban item on my backlog to address later. This allows me to archive the email but keeps it on my “Trello radar” as I work at my own pace through my personal backlog.
Recently, Trello removed their add-in from the Microsoft Office store. If you have the add-in installed, you will see this error:
Well, since they say necessity is the mother of all invention and I really had to fill the gap as it is part of my routine, I rolled my own. 🤓 To add a degree of difficulty, I wrote this in VS Code in Linux running in Windows Subsystem for Linux (WSL). See my previous post. It was a fun exercise as I am on vacation and using the time tom learn new things, engage in self-improvement and relax (coding is relaxing to me 🤓🤓🤓). In the end, I learned something and created something for everyone to enjoy.
To date I have created four Trello Power-Ups that I use every day to fill a gap that I need in order to scrum my life’s “backlog.” I was first turned towards Trello when I read Deep Work by Cal Newport. Since then I created:
And I am working on another for Outlook Calendar integration – with a possible companion OfficeJS Add-in to boot.
Each time I created a Power-Up, I found myself going back to the documentation over and over again for the most trivial items. So, I finally sat down and hacked out a type definitions file based on the existing Trello Power-Up Documentation.
You can find all the information about the type library I created here: