Getting Started on your first FOLIO UI module
This tutorial requires Git, NodeJS and Yarn.
It includes screenshots from the VS CODE UI to display directory/file structure.
Create a single development folder for your workspace. We’ll call it the “FOLIO_Workspace” folder for sake of examples.
From a command line, navigate to the workspace folder and clone the sample platform.
git clone https://github.com/folio-org/stripes-sample-platform.gitNavigate into the command line and switch to the current updated branch of stripes-sample-platform:
git checkout ramsons-yarnv1Back in the Create a
package.jsonfile in your workspace folder, sibling to the stripes-sample-platform folder. Add these contents to the file:{ "private": true, "workspaces": [ "*" ], "devDependencies": { "@folio/stripes-cli": "^3.2.0" } }
Your project directory should now look like this:Install the workspace by running the
yarncommand from the “FOLIO_Workspace” folder. Give the dependencies a few minutes to install.
The install process creates anode_modulesfolder as well as ayarn.lockfile in the “FOLIO_Workspace” folder.Now the exciting part: Create a new FOLIO App by running the following command in the “FOLIO_Workspace” folder:
yarn stripes app create "starter"Feel free to substitute the intended name of your app for “starter”.
stripes-cliwill ask for a brief description. Fill it in with “My First FOLIO App!” Just for example purposes.stripes-cliwill clone an example repo to the folder and fill out the templated strings using your app’s name and the description that you provided. It willyarn install/updatedependencies within the workspace as well.Now your workspace directory structure will look like this:
Within the stripes-sample-platform folder, open the
stripes.config.jsfile. This configuration controls the build process. Look for themodulesfield. It contains only a single entry -"@folio/users": {}
Add your UI module to thismoduleslist like so:modules: { '@folio/users': {}, '@folio/starter': {} // <-- your module package name from its package.json file. },Back at the command line, navigate to the
stripes-sample-platformfolder, and run the command:yarn stripes serve stripes.config.jsYou’ll see console output that looks like the following. Notice the name of our module (
ui-starter) shows up in the list!Eventually you’ll see something like
Open a web browser to
localhost:3000
The login page will appear. Enderdiku_adminandadminfor credentials.The FOLIO Landing page will appear. You should see a link to our custom UI module in the Main navigation:
The title looks odd in the header, right? It’s actually rendering a key to a translation string. To fix this, you’ll need to navigate to the
<your app>/translationsfolder and copy theen.jsonfile, renaming the copy toen_US.json- or to whichever locale you set the FOLIO UI to. Exiting theservecommand and re-running it should now display your module’s name up top!The branch we switched
stripes-sample-platformto a ‘training wheels’ branch to make this process quicker.
If you’re developing your own backend module, you should definitely modifystripes.config.jsto point to your locally running okapi instance (set theurlunder theokapifield -okapi: { 'url':'http://localhost:9130', 'tenant':'diku' })
and apply your custom app’s permissions to your local okapi’s “diku_admin” user with the following command from the app’s directory:yarn stripes perm assign --user diku_adminThis will remove the need for the
hasAllPerms: true(or the--hasAllPermscommand-line flag.)
The list of your custom app’s permissions can be found in thepackage.json. The process executed byyarn stripes app createfilled in your custom module’s name into the baseline permissions.