This commit updates the Redux store so that the new clone API end points can be used. The composes slice is updated - composes now have a clones property - and a clones slice is added. Selectors are added as well. Although not used in this commit, the selectors will allow us to significantly simplify our React components that need to retreive data from the store. We now must work with both `composes` and `clones`. `Composes` and `clones` have slightly different schema in the Redux store because of differences in their API responses (the store schema generally mirrors the API response schema). Selectors are defined for `images` that work for both `composes` and `clones`. Using selectors allows our React components to interact with the Redux store as if it were a database - components can simply query the store by id using a selector. This hugely simplifies our React components - they no longer need to accept multiple props related to a `compose` (or `clone` or `image`). They can simply take a `composeId` (or `cloneId` or `imageId`) prop and use an appropriate selector to obtain the necessary information. Selectors also encapsulate the store schema. Components no longer need to know about the store schema to get information about an image - they simply use a selector and in return receive a normalized (and flat) object. This means that in the future we could easily migrate the API and slices to RTK Query without the need to modify any of our React components. |
||
|---|---|---|
| .github | ||
| .travis | ||
| config | ||
| deploy | ||
| devel | ||
| distribution | ||
| schutzbot | ||
| src | ||
| .eslintrc.yml | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .stylelintrc.json | ||
| .travis.yml | ||
| babel.config.js | ||
| build_deploy.sh | ||
| codecov.yml | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| pr_check.sh | ||
| 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.