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.git
Navigate into the command line and switch to the current updated branch of stripes-sample-platform:
git checkout ramsons-yarnv1
Back in the Create a
package.json
file 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
yarn
command from the âFOLIO_Workspaceâ folder. Give the dependencies a few minutes to install.
The install process creates anode_modules
folder as well as ayarn.lock
file 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-cli
will ask for a brief description. Fill it in with âMy First FOLIO App!â Just for example purposes.stripes-cli
will 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/update
dependencies within the workspace as well.Now your workspace directory structure will look like this:
Â
Within the stripes-sample-platform folder, open the
stripes.config.js
file. This configuration controls the build process. Look for themodules
field. It contains only a single entry -"@folio/users": {}
Add your UI module to thismodules
list 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-platform
folder, and run the command:yarn stripes serve stripes.config.js
Youâ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_admin
andadmin
for 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>/translations
folder and copy theen.json
file, renaming the copy toen_US.json
- or to whichever locale you set the FOLIO UI to. Exiting theserve
command and re-running it should now display your moduleâs name up top!Â
The branch we switched
stripes-sample-platform
to a âtraining wheelsâ branch to make this process quicker.
If youâre developing your own backend module, you should definitely modifystripes.config.js
to point to your locally running okapi instance (set theurl
under theokapi
field -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_admin
This will remove the need for the
hasAllPerms: true
(or the--hasAllPerms
command-line flag.)
The list of your custom appâs permissions can be found in thepackage.json
. The process executed byyarn stripes app create
filled in your custom moduleâs name into the baseline permissions.