This commit improves the file system configuration step's error handling by performing validation only when the next button is clicked. This allows an invalid state to temporarily exist while the user is modifying the mountpoints without bothersome error messages needlessly appearing. Broadly speaking there were two options for the implementation: (1) delay the validation, performing validation only upon clicking the next button -or- (2) perform validation immediately as normal but hide error messages until the next button is clicked. Option (1) proved to be untenable - Data Driven Forms does provide `pauseValidation()` and `resumeValidation()` functions from React Final Form which theoretically would make this option possible... However, we need to call `resumeValidation()` in the next button's click handler and then immediately make a decision based on the validation results either to remain on the step and display the errors or move to the next step. When we tried implmenting this we found that `resumeValidation()` does not immediately peform validation - validation only resumes after exiting the handler. Therefore, this approach was not considered and option (2) was used. In order to gain control over the behavior of the next button, custom buttons are implemented for this step. Sharing state between the custom buttons and the form was a challenge. With pure React it would have been as simple as moving the relevant state to the parent component, but that was not possible due to Data Driven Forms. Instead, state is shared using the form state. A new property, `'file-system-config-show-errors'`, in the form state is used to determine whether or not error messages should be displayed. In order to cause a re-render upon a change in `'file-system-config-show-errors'`, the file system configuration component is wrapped in a `<FormSpy>` component. |
||
|---|---|---|
| .github | ||
| .travis | ||
| config | ||
| devel | ||
| distribution | ||
| schutzbot | ||
| src | ||
| .eslintrc.yml | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .stylelintrc.json | ||
| .travis.yml | ||
| babel.config.js | ||
| codecov.yml | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
image-builder-frontend
Frontend Development
To develop the frontend you can use a proxy to run image-builder-frontend locally against the chrome and backend at console.redhat.com.
Working against the production environment is preferred, as any work can be released without worrying if a feature from stage has been released yet.
Nodejs and npm version
Make sure you have npm@7 and node 15+ installed. If you need multiple versions of nodejs check out nvm.
Webpack proxy
-
run
npm ci -
run
npm run prod-beta. This command uses a prod-beta env by default. Configure your environment by theenvattribute indev.webpack.config.js. -
Secondly redirect a few
prod.foo.redhat.comto localhost, if this has not been done already.
echo "127.0.0.1 prod.foo.redhat.com" >> /etc/hosts
- open browser at
https://prod.foo.redhat.com:1337/beta/insights/image-builder
Webpack proxy (staging) -- Runs with image-builder's stage deployment
-
run
npm ci -
run
npm run stage-beta. This command uses a stage-beta env by default. Configure your environment by theenvattribute indev.webpack.config.js. -
Secondly redirect a few
stage.foo.redhat.comto localhost, if this has not been done already.
echo "127.0.0.1 stage.foo.redhat.com" >> /etc/hosts
- open browser at
https://stage.foo.redhat.com:1337/beta/insights/image-builder
Insights proxy (deprecated)
-
Clone the insights proxy: https://github.com/RedHatInsights/insights-proxy
-
Setting up the proxy
Choose a runner (podman or docker), and point the SPANDX_CONFIG variable to
profile/local-frontend.jsincluded in image-builder-frontend.sudo insights-proxy/scripts/patch-etc-hosts.sh export RUNNER="podman" export SPANDX_CONFIG=$PATH_TO/image-builder-frontend/profiles/local-frontend.js sudo -E insights-proxy/scripts/run.sh -
Starting up image-builder-frontend
In the image-builder-frontend checkout directory
npm install npm start
The UI should be running on https://prod.foo.redhat.com:1337/beta/insights/image-builder/landing. Note that this requires you to have access to either production or stage (plus VPN and proxy config) of insights.
Backend Development
To develop both the frontend and the backend you can again use the proxy to run both the frontend and backend locally against the chrome at cloud.redhat.com. For instructions see devel/README.md.
Style Guidelines
This project uses eslint's recommended styling guidelines. These rules can be found here: https://eslint.org/docs/rules/
Test Guidelines
Testing is done using React Testing Library. All UI contributions must also include a new test or update an existing test in order to maintain code coverage.
Tests can be run with
npm run test
These tests will also be run in our Travis CI when a PR is opened.