Skip to content

Development Tips and Tricks

patrick-austin edited this page Jan 26, 2021 · 2 revisions

This page is intended to serve as a point of reference for common issues when developing Sci/DataGateway to ensure solutions are recorded, and as such should be updated as required to cover any issues people have had.

Changes to datagateway-common not taking effect

Unlike changes to the plugins themselves, changes to datagateway-common do not immediately impact plugins running locally. This is because they import from datagateway-common/lib rather than datagateway-common/src. Changes to the latter can be compiled by running yarn tsc in datagateway-common, at which point any plugins being run with yarn start should immediately update to reflect the changes that have been made.

Plugin strings displaying incorrectly when serving through SciGateway

When serving plugins through SciGateway, translated strings in the plugins UI may appear as the key used for their translation rather than the value itself, for example investigations.title rather than Title. When serving through Scigateway, the plugin's own public/res/default.json file is not used, only the key/values from the same file in scigateway. So to ensure the strings display as intended, you can simply copy the contents from the plugin file and append it to the JSON in scigateway.

No data when serving through SciGateway

Unlike when running the plugins standalone, some changes are needed to the configuration files to access data through SciGateway. There are a few ways of doing this, the easiest being to use the existing pre-production authUrl:

  • Set "auth-provider": "icat" in scigateway/public/settings.json
  • Set "proxy": "http://scigateway-preprod.esc.rl.ac.uk:8000/" in scigateway/package.json

Once these changes are applied, logging in with the same credentials as pre-prod should populate the plugins with data.

Choosing the port when serving plugins

The port used by running yarn serve:build is determined in package.json for each individual plugin, and by default is 5001 for each. This means when serving your 2nd plugin a random port will be chosen instead, which means configuring scigateway/public/settings.json to match each time you serve the plugin. This can be prevented by changing the port in package.json for each plugin (e.g. to 5002, 5003) so that they won't serve to the same port. Be aware that unlike scigateway/public/settings.json, package.json is a tracked file and so care should be taken when committing and checking out changes to it.

Clone this wiki locally