Skip to content

Html Customization migration guide to React

Aurora Lahtela edited this page Feb 5, 2023 · 11 revisions

Plan Header

Html Customization -migration guide to React

React version of the frontend is currently enabled through Plugin.Frontend_BETA configuration setting.
After the new frontend is feature-complete the configuration setting and old frontend will be removed.

The principles behind using plain .html, .css and .js files and React-bundle are completely different, so it makes sense that Html Customization had to be completely revamped. This may increase level to entry for those new to web development, but several steps have been taken to try make customization easier.

Table of contents

  • 🏁 Goals
  • ✔️ Requirements
  • ⚙️ Preparing for modifying React-bundle
  • 🏗️ Using a customized bundle
  • 👓 Tools that help with modifications
  • 🗳️ Migration Examples

🏁 Goals of the new Customization environment

  • Allow anything to be changed
  • Allow you to keep your customized files up-to-date with latest Plan changes, using git

✔️ Requirements

Following software needs to be installed before you can start customizing

⚙️ 1.0 Prepare for modifying the React-bundle

1.1 Open command prompt / terminal

Navigate to a suitable folder and run the following on your command prompt/terminal.

On windows you can right-click in a folder and 'Git bash here' image

1.2 Clone Plan-repository

Run this on the terminal to get the React-bundle

git clone https://github.com/plan-player-analytics/Plan.git

(If you want to propose your changes for merging to Plan later, fork image and clone the fork instead)

The react files will be placed in {command execution directory}/Plan/Plan/react.
Navigate there using

cd ../Plan/Plan/react

🏗️ 2.0 Using a new customized bundle

2.1 Build a new React-bundle

in the folder Plan/react run:

./buildBundle.sh

or on Windows you can click buildBundle.bat
image

2.2 Copy the new bundle to Plan public_html folder

On your server with Plan installed, there is a /plugins/Plan/public_html folder (Configurable with Webserver.Public_html_directory config setting). If this folder has not been created, access the webserver or create it manually.

Copy files inside Plan/react/dashboard/build to /plugins/Plan/public_html
image ➡️ image

This will override the default bundle inside Plan.jar

👓 3.0 Development tools to help see what you're doing

Development tooling is still being improved, but this should get you started.

⚙️ 3.1 Configure Plan address for development

Open Plan/react/dashboard/package.json and change "proxy" to the address of your Plan webserver

image

The webserver can be anywhere (Even on your currently running Plan instance)

3.2 Start react development server

in the folder Plan/react run:

./devServer.sh

or on Windows you can click devServer.bat
image

A browser will open with localhost:3000 as the address. Any changes you make to the react files will automatically be visible here.

⚠️ Important After you're done with your changes do steps 2.1 - 2.2 to get your new react bundle into use!

🐞 Bug in current dev tools: After you stop the devServer program you need to manually kill node through Task Manager on Windows or kill on linux

3.3 Updating your files when updating Plan

When Plan updates the html files can change. You can use git to update your files to newest version.

in the folder Plan/react run:

git pull --rebase

This will update all files to newest version while keeping your changes on top.

If this fails, run

git add -A
git commit -m "My changes"
git pull --rebase

You may need to fix conflicts if a line in the files was modified by you and Plan developers. You can use following command to keep track if you have fixed them.

git status

🗳️ Examples

Changing favicon.ico

  • Place your custom favicon.ico directly to public_html folder

Changing Plan logo

  • Replace Plan/react/dashboard/src/Flaticon_circle.png with your logo image
  • Build the bundle and place it to public_html folder (Steps 2.1 - 2.2)

Adding new link to the sidebar on all pages

  • Open Plan/react/dashboard/src/views/layout
  • Open any of the ___Page.js files and look for const items
  • Add a new entry to the list {name: 'My link', icon: faGoogle, href: "https://www.google.com", external: true}, image

Changing color scheme

  • All colors are stored in style.css
    image

Something else?

Clone this wiki locally