Table of Contents
Customizing Your Customer Portal
Updated by Mitchell Paul-Soumis
Read Time: 7 mins
However, we are unable to test the changes you make and can't predict what will happen when someone customizes the code to suit their needs. For this reason, our Support team is unable to provide assistance for portals that have been forked or customized, nor for the process of forking or customizing the portal; the party who changes the underlying code we provide assumes responsibility to support and maintain their code and will need to perform testing to ensure it's working as expected. If you do choose to customize the portal, be sure to document the steps taken and the changes made so that you can have a plan in place to remove the customizations before contacting Sonar Support.
While Sonar provides a pre-built Customer Portal that can be tied to your instance and used to provide more control to your customers, we want to avoid limiting your creativity, branding, or controlling how your customers access their information. The Sonar Customer Portal code repository is available on https://github.com/SonarSoftwareInc/customer_portal, and you're welcome to fork or clone this repository to modify the underlying code to suit your needs.
Before you get started
As you explore this document and customize your Customer Portal, you'll need to make sure that changes to your docker-compose.yaml
take effect. If you've already run the Customer Portal container before making any changes, you'll need to run the following commands:
- Take the docker container down and remove any leftover elements
docker-compose down --remove-orphans
- Bring the docker container back up with the new "docker-compose.yml" file we've just created
docker-compose up --build -d
Cloning the Repository
For cloning the repository to make minor changes, you can follow the guide below:
- git clone the portal onto a droplet
droplet# git clone github.com/sonarsoftwareinc/customer_portal
- Modify the Docker Compose file:
droplet# nano ./customer_portal/docker-compose.yml
- Change image name in Docker Compose file from
image: "sonarsoftware/customerportal:stable"
to a unique name. In this example, we'll be changing it to "image: customized:stable"
- Remove the lines containing "watchtower"
40 watchtower:
41 image: v2tec/watchtower
42 restart: always
43 volumes:
44 - /var/run/docker.sock:/var/run/docker.sock
45 command: sonar-customerportal
- Save the modified "docker-compose.yml"
Customization Example: Remove the ability to delete a payment method
- Enter the source file to the specific location housing billing parameters:
droplet#nano ./customer_portal/resources/views/pages/billing/index.blade.php
- Remove lines 321 - 326 & 391 - 396 (inclusive)
- Save "Index.blade.php"
Customization Example: Disable the Auto-Pay toggle
- Enter the source file to the specific location housing billing parameters:
droplet#nano ./customer_portal/resources/views/pages/billing/index.blade.php
- Remove lines 308 - 320, which contains the Auto-pay toggle code:
1 @if($paymentMethod->auto == 1)
2 {!! Form::open(['action' => ["BillingController@toggleAutoPay",$paymentMethod->id],'id' => 'deletePaymentMethodForm', 'method' => 'patch']) !!}
3 <button class="dropdown-item btn btn-sm btn-danger" onClick="submit(); this.disabled=true;this.innerHTML='<i class="fe fe-loader mt-2 mr-2 "></i> {{utrans("billing.disabling")}}'">
4 <i class="fe fe-minus-circle mr-2"></i> {{utrans("billing.disableAuto")}}
5 </button>
6 {!! Form::close() !!}
7 @else
8 {!! Form::open(['action' => ["BillingController@toggleAutoPay",$paymentMethod->id],'id' => 'deletePaymentMethodForm', 'method' => 'patch']) !!}
9 <button class="dropdown-item btn btn-sm btn-primary" onClick="submit(); this.disabled=true;this.innerHTML='<i class="fe fe-loader mt-2 mr-2"></i> {{utrans("billing.enabling")}}'">
10 <i class="fe fe-check-circle mr-2"></i> {{utrans("billing.enableAuto")}}
11 </button>
12 {!! Form::close() !!}
13 @endif
- Save "Index.blade.php"
- Modify Auto-pay on new credit card payments by entering the file which controls the logic for adding new cards:\
droplet#nano ./customer_portal/resources/views/pages/billing/add_card.blade.php
- Replace the following lines:
<div class="col mt-1">
{!! Form::checkbox("auto",1,false,['id' => 'auto', 'class' => 'custom-control-input']) !!}
<label class="custom-control-label" for="auto"></label>
with:
<input type="hidden" id="auto" class="custom-control-input" name="auto" value="1">
- Because the above lines remove the toggle on the "Add Credit Card" page, we also want to remove the visible tooltip that contains the "Automatically charge this card for all future invoices" text:
<div class="col mt-1">
<small class="text-muted">
{{utrans("billing.saveAsAutoPayMethod")}}
</small>
</div>
Customization Example: Using alternative SSL certificates
- After your installation has completed, stop Certbot from running:
docker-compose stop certbot
- Modify the Docker compose file:
droplet# nano ./customer_portal/docker-compose.yml
- Comment out the entire section containing Certbot instructions. It should appear similar to the below:
# certbot:
# image: certbot/certbot
# restart: always
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
# volumes:
# - ./data/certbot/conf:/etc/letsencrypt
# - ./data/certbot/www:/var/www/certbot - Navigate to the storage location for your SSL certificates generated by Certbot:
cd /data/certbot/conf/live/<CUSTOMERPORTAL HOST NAME>
- Replace the fullkey.pem and privkey.pem files with your certificates
- Restart the Nginx server within the Customer Portal:
docker-compose exec app sv restart nginx
Your docker-compose.yml file should look something like this:
version: 'X.x'
services:
app:
build:
context: .
dockerfile: Dockerfile
image: sonarsoftware/customerportal:stable
container_name: sonar-customerportal
restart: always
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./deploy/conf/nginx/sonar-customerportal.template:/etc/nginx/conf.d/sonar-customerportal.template
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
- ./public/assets/img/logo.png:/var/www/html/public/assets/img/logo.png
- ./public/assets/img/cover.png:/var/www/html/public/assets/img/cover.png
- storage:/var/www/html/storage
env_file:
- .env
environment:
REDIS_HOST: redis
depends_on:
- redis
redis:
image: redis:5.0.4-alpine
restart: always
# certbot:
# image: certbot/certbot
# restart: always
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
# volumes:
# - ./data/certbot/conf:/etc/letsencrypt
# - ./data/certbot/www:/var/www/certbot
watchtower:
image: v2tec/watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: sonar-customerportal
volumes:
storage:
driver: local
What about Portal Updates?
After you update your Sonar portal to the newest version, customizations will be cleared. While you could manually upload the custom files back into the upgraded portal, a more common method to reintroduce these customizations would be through synchronizing a fork. Below is the GitHub recommended approach to doing this:
Syncing a fork
Sync a fork of a repository to keep it up-to-date with the upstream repository.
Before you can sync your fork with an upstream repository, you must configure a remote that points to the upstream repository in Git.
- Open Terminal.
- Change the current working directory to your local project.
- Fetch the branches and their respective commits from the upstream repository. Commits to
master
will be stored in a local branch,upstream/master
.$ git fetch upstream
> remote: Counting objects: 75, done.
> remote: Compressing objects: 100% (53/53), done.
> remote: Total 62 (delta 27), reused 44 (delta 9)
> Unpacking objects: 100% (62/62), done.
> From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
> * [new branch] master -> upstream/master - Check out your fork's local
master
branch.$ git checkout master
> Switched to branch 'master' - Merge the changes from
upstream/master
into your localmaster
branch. This brings your fork'smaster
branch into sync with the upstream repository, without losing your local changes.$ git merge upstream/master
If your local branch didn't have any unique commits, Git will instead perform a "fast-forward":
> Updating a422352..5fdff0f
> Fast-forward
> README | 9 -------
> README.md | 7 ++++++
> 2 files changed, 7 insertions(+), 9 deletions(-)
> delete mode 100644 README
> create mode 100644 README.md$ git merge upstream/master
> Updating 34e91da..16c56ad
> Fast-forward
> README.md | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)