Commit graph

80 commits

Author SHA1 Message Date
mgold1234
7cb3f2d0b6 Wizard: add description field to Details steps 2023-07-28 12:24:25 +02:00
mgold1234
5c1952d8c9 Wizard: change the name of wizard details
This commit change the name of wizard-details to details, to prevent misconfusion with the image-name component
2023-07-26 17:13:42 +02:00
regexowl
d03b17de13 Wizard: Remove ModalProps from schema
These changes were introduced in #1079 to ensure that quickstarts stay visible even after opening a Wizard modal as they are both top-most components.

`ModalProps` which were used for this purpose were introduced in version 3.20.6 of `@data-driven-forms/pf4-component-mapper`. Since then we had to regress the version to 3.20.5 as it was crashing the application on closing of a modal. The issue linked to this can be found here: https://github.com/data-driven-forms/react-forms/issues/1389

As we are now using mapper version that does not allow to use `ModalProps` the functionality of the workaround was lost and it was causing following console.error: `Warning: React does not recognize the `ModalProps` prop on a DOM element.`
2023-07-11 17:49:18 +02:00
Sanne Raymaekers
f20686df4d CreateImageWizard: Add support for vsphere-ova imagetype
The OVA type is also the default when checking VMWare now.
2023-07-05 13:02:39 +02:00
lucasgarfield
0fe9770bc3 Wizard: Hotfix for recreate image rate limiting issue
Related to HMS-1886: Clicking the recreate button on a build with a lot
of packages results in the user being rate limited.

Package summaries are obtained by querying the Content Sources API. A
large number of packages requires a large number of requests and leads
to the rate limiting problem when using the 'Recreate image' function.

This commit fixes the problem by not requesting or displaying package
summaries when 'Recreate image' is used. (Note that newly added packages
will still request and display a summary.)

The 'Recreate image' function will soon be replaced by
blueprints. This hotfix should carry us forward until then.
2023-06-05 17:49:18 +02:00
regexowl
83206171f9 ImagesTable: Ensure created_at date for a new image
This adds a temporary value of current date to `created_at` for newly created images.

This is not the most elegant solution and will be reworked after the ImagesTable refactor.
2023-05-04 17:09:47 +02:00
lucasgarfield
383f2a6855 Wizard: Add filtering to repositories
This commit adds filtering based on architecture and version to the
repositories table in the wizard.

Apart from filtering, this commit now shows *all* repositories,
regardless of their status. Previously, invalid repositories were not
displayed. A future PR will add a status column and edge case handling
(how to handle an invalid repo, etc...). For now, invalid repos are
displayed and can be selected.

RTK Query is now used to manage the state of the repositories.
Previously, the repositories were fetched in a useEffect hook upon
opening the wizard.

MSW is now used instead of jest mocking for the tests involving
repositories. The repositories test fixture now contains a function that
mimics the content sources API.
2023-05-04 14:13:17 +02:00
Sanne Raymaekers
23d58d563d CreateImageWizard/Repositories: set custom-repositories
Embed the payload repositories into the image.
2023-05-02 14:33:53 +02:00
Sanne Raymaekers
f0679d1196 CreateImageWizard: rename custom- to payload-repositories
To avoid confusion between custom and payload repositories.

Custom repositories will be embedded in the yum config, payload
repositories are used for installing packages.
2023-05-02 14:33:53 +02:00
lucasgarfield
7bca4c7438 LandingPage/ImagesTable/Wizard: Remove all insights global calls
This commit replaces all calls to the insights.chrome global with calls
to the useChrome() hook (or the useGetEnvironment() custom hook that
wraps useChrome()).
2023-04-28 17:07:31 +02:00
lucasgarfield
b2e6e3cf04 Wizard: Use useChrome hook to set beta feature flag
The use of chrome.isBeta is deprecated, the useChrome hook should be
used instead to obtain an isBeta() function. Using the deprecrated
chrome.isBeta pollutes the browser console with warning messages.

This commit replaces the isBeta() helper function with a new custom
hook, useGetEnvironment().

We still sometimes need to know which environment is running outside of
React components, where we cannot call the useChrome() or
useGetEnvironment() hooks. For instance, in the json used to define a
wizard step. Therefore a new isBeta variable has been added to the
form's initialState for use in these cases.
2023-04-28 17:07:31 +02:00
Pavel Odvody
2f13390eee Add MODAL_ANCHOR and anchor ShareImageModal
This patch adds a constant `MODAL_ANCHOR` so that the value
can be used in multiple modals that require it. Also the
ShareImageModal is now properly anchored to it.

Signed-off-by: Pavel Odvody <pavel@redhat.com>
2023-04-20 17:02:04 +02:00
Pavel Odvody
466f158374 Anchor modal to proper element
By default all modals are anchored to document.body
which interferes with Quickstarts by overlaying them.
This patch anchors the modal to the main element outside
of the Quickstart so that both can be visible at the same time.

Signed-off-by: Pavel Odvody <pavel@redhat.com>
2023-04-20 17:02:04 +02:00
lucasgarfield
bc1435994d Router: Modify /share and /imagewizard routing
Insights offers 'quickstarts', which can be used to provide
mini-tutorials in a sidebar.

Unfortunately, these quickstarts change our URL... they add an optional
query parameter related to the quickstart. The process of doing so
destroys our router's `location`, setting it to undefined.

We have been using the location state to store the GUID of the image,
needed when opening the wizard via the `Recreate image` action or when
opening the share modal.

As a workaround, we can simply accept that the quickstarts will change
our URL and destroy our router's location. Instead, we now put the image
id (its UUID) in the route itself. We can access it in the components as
necessary via the useParams hook.
2023-04-20 14:59:12 +02:00
Ondrej Ezr
065900c0f8 Add sources selection for Azure
Fixes HMS-1511
2023-04-13 13:32:23 +02:00
lucasgarfield
c7add821c2 Wizard: Fix bug causing crash upon visiting Azure step
This commit fixes a bug in the wizard. The Azure step name was
incorrectly set when using the 'Recreate image' option which caused the
wizard to crash when trying to access the Azure step.
2023-04-12 16:33:19 +02:00
Sanne Raymaekers
1df2df1360 CreateImageWizard: show error details on save
Show details when the wizard sends a request that results in an
error. Now that AWS and Azure have a maximum size, this needs to be
shown.
2023-04-03 10:51:54 +02:00
lucasgarfield
4c2a410dd7 Wizard: Expose beta features in qa environment
The QE team has requested that all beta features be exposed in the
ephemeral environment (insights.chrome.getEnvironment() === 'qa').
2023-03-28 09:26:13 +02:00
Sanne Raymaekers
9e6d951641 CreateImageWizard: rhc support 2023-03-08 16:45:31 +01:00
regexowl
753afa197d Wizard: Get distribution repositories from an api endpoint
Previously the base repository links for each distribution were read from `repos.js` file. This gets the needed information
from a call to api endpoint `architectures/{distribution}`. The data is fetched via RTK Query and is then filtered by an
architecture. For now the x86_64 architecture is hardcoded, this will change when multiple architectures get available.
2023-03-07 08:34:03 +01:00
lucasgarfield
53ce67ab47 Wizard: Add beta flag for AWS sources
This commit makes the new AWS sources feature only available in beta.

Note that the RTKQ hooks related to AWS sources are called in several
places outside of the AWS Target step (a prefetch on the Image Output
step and useQuery hook on the review step) but have not been hidden
behind beta flags - this should not present any problems and will make
exposing this feature in stable much easier when the time comes.
2023-03-01 11:25:28 +01:00
lucasgarfield
a474163343 Wizard: Add ability to specify AWS target using sources
This commit adds the ability to specify AWS targets using the sources
service on insights.

This is the first commit to the codebase that makes use of the new RTK
Query endpoints, so I will provide a bit of additional context here:

The sources are obtained by calling the `useGetAWSSourcesQuery()` hook.
This hook can be called in any component where information about the
sources is needed.

A few tricks are used to make the user experience as responsive as
possible.

The `prefetch()` hook provided by RTK Query is called when the user
clicks on the AWS button on the image output step. This triggers the
initial request for the sources, which will then (hopefully) be ready by the
time the user clicks to the next step (the AWS target environment step)
where they are needed.

Because we anticipate a common user workflow to involve using the Create
image wizard in one browser tab and the sources service in another tab,
sources are also refetched every time the source dropdown is opened.
This means that if a user adds a source while in the middle of using the
wizard, they will be able to see it in the wizard's sources dropdown
without refreshing their browser.

Finally, because of the `Recreate image` feature, the
`useGetAWSSourcesQuery` hook also needs to be called on the review step.
2023-03-01 11:25:28 +01:00
lucasgarfield
4000b8d5e5 ESLint: Add prefer-const rule
Require const declarations for variables that are never reassigned after
being declared. If a variable is never reassigned, using the const
declaration is better. const declaration tells readers, “this variable
is never reassigned,” reducing cognitive load and improving
maintainability.
2023-02-10 11:37:06 +01:00
Sanne Raymaekers
3207afce90
config: remove module name in webpack config (#959)
Due to merging the openshift and chrome plugin systems there's
additional requirements on the format of the module name.

Camelcase is the default, so the values can just be removed from the
config.
2023-02-09 12:17:27 +01:00
Sanne Raymaekers
a25ec459d8 CreateImageWizard: use content sources in production beta
Enables package searching and custom repositories.
2023-01-25 16:15:51 +01:00
regexowl
cbd6b1e4cb Wizard: Update the File system step
Fixes #911. Fixes #912.

This updates the File system step. The changes are:
- changed the toggle group for selecting the mode of partitioning to radio select and updated information for each radio button as mentioned in #911
- added information to the "automatic" option of the file system configuration as mentioned in #912
- updated information for the "manual" option of the configuration as mentioned in mocks
2023-01-19 16:07:58 +01:00
lucasgarfield
d4c8d71bd1 Wizard: Clarify variable names and comments in requestToState()
This commit clarifies variable names and comments that were found to be
confusing during the review of 5adc0e.
2023-01-06 10:29:27 +01:00
lucasgarfield
280c11c824 Wizard: Change '3rd party repositories' to 'Custom repositories'
All instances of '3rd party repositories' (and its variations) have been
changed to 'Custom repositories'. This is in better agreement with the
content sources app on consoledot, which generally is called either
'Custom Repositories' or 'Repositories'. Additionally, it is possible to
add and manage Red Hat repositories via content sources, which makes
'3rd party' confusing.
2023-01-04 16:16:25 +01:00
lucasgarfield
5adc0e7d4a Wizard: Add 3rd Party Repositories
Adds support for 3rd party repositories using the Red Hat Insights
Repositories app on console.redhat.com.

The packages step has been refactored heavily to reduce the bug surface
area and improve its reusability (it is now used in two Wizard steps).

New features related to the Repositories app are currently only exposed
in stage. Because stage and production are quite divergent (they have
different steps, for instance) there are separate test suites for the
production and stage versions of the Wizard. When these features are
moved into production, the two test suites can be merged into one.
2023-01-03 10:05:39 +01:00
Sanne Raymaekers
cb8ab9347e CreateImageWizard: use non-deprecated image type aliases
'ami' was deprecated a while ago, and is kept around as an alias of
'aws'. Same with 'vhd' and 'azure', and 'vhd' and 'gcp'.

This maintains support for the old aliases where necessary.
2022-12-06 15:14:53 +01:00
regexowl
ab1a7f4aab ESLint: Use --fix with updated rules to order imports
This applies the updated sorting rules to the files by running `npm run lint:js:fix`
2022-12-02 16:29:58 +01:00
jkozol
414dff3ed7 api: use content-sources api for package search on stage beta
The Content Sources service can now be used for handling package info and
search. The api call to this service requires a list of repo urls. The
`repos.json` file tracks the supported repositories for each distro.
This is then mapped into a url array for whichever distro we are
searching for packages. The response body is similar to what existed in
image-builder but the key `package_name` needs to be mapped to just
`name`. Also, there is no pagination in Content Sources for `/rpms/names`
so we can currently only fetch a limit of 20 packages.
2022-11-02 17:32:51 +01:00
Sanne Raymaekers
03421acc74 src/Router: use release as a basename in BrowserRouter
The insights platform is moving to react router v6, meaning router
contexts can no longer be nested. As a result all applications will end
up sharing the same `BrowserRouter`.

Switch to using the release (`/` or `/beta/`) as a basename for the
BrowserRouter, and offload the full path (`/insights/$appname`) to the
individual routes. This makes it easier to drop the BrowserRouter in
image builder for the platform one in future.
2022-10-17 15:53:21 +02:00
lucasgarfield
a17a759d5e Redux: Modernize Redux store
This commit modernizes the Redux store to bring it in line with the
current recommended best practices/patterns. It is possible because of a
recent previous commit that added Redux Toolkit as a dependency.

For detailed information on what modern Redux entails, see the Redux docs:
https://redux.js.org/introduction/getting-started#learn-modern-redux-livestream

Practically speaking, this means a huge reduction in boilerplate code.
Maintaining and extending the code will be much easier. All Redux logic
is now encapsulated by 'slices'. Reducers are defined in the slices, and
action creators and action types are generated automatically.

Redux Toolkit includes Immer, which greatly simplifies writing reducer logic
much simpler - state updates in Redux must be immutable, but working
with Javascript objects in an immutable fashion is clumsy, requiring
gratuitious use of the spread ... operator. With Immer, the state can be
updated as if mutable updates were allowed. Reducer logic has been
changed to take advantage of this in this commit.

This commit also removes a large amount of unused code. Fingers crossed
that nothing breaks. The tests do pass, afterall...

One other minor change... composesGet was renamed to fetchComposes and
composeGetStatus was renamed to fetchComposeStatus. This is in line with
the Redux documentation examples.
2022-09-30 13:17:09 +02:00
regexowl
0bced556a9 ESLint: Use --fix with new rules to order import declarations
Related to #795. This applies the new sorting rules in ESLint to the files by running `npm run lint:js:fix`
2022-09-14 13:24:38 +02:00
Sanne Raymaekers
1c5542ca81 CreateImageWizard: Use stage candlepin urls on stage consoledot 2022-06-07 14:53:45 +02:00
Jacob Kozol
4fa71cede8 update style across the project
The eslint updates require style changes in all components.
2022-05-23 12:47:20 +02:00
Sanne Raymaekers
cfaa8a463d CreateImageWizard: RHEL 9
Expose rhel-90, it has reached GA.
2022-05-18 15:24:04 +02:00
Sanne Raymaekers
294cb08a0f CreateImageWizard: Use 'gcp' image type for gcp
The vhd alias for gcp was dropped, as image-builder includes extra repos
for gcp.
2022-04-25 14:00:54 +02:00
Jacob Kozol
2f5f6dcc46 CreateImageWizard: move name image step to end
The Details step is renamed to Name Image and moved to the last step
before Review. Also, the validation is removed since all utf-8
characters are supported for image names.
2022-04-19 14:07:46 +02:00
Gianluca Zuccarelli
78123bff0e CreateImageWizard: target env validation
Validation is not enforced on the image output step
when selecting and then deselecting an image type. This
is because the only validation which is set is `Required`.
However, after deselecting an image type the input becomes
a key-value object with all the values set to false. This
commit adds a custom validator to check that at least one
value in the object is set to true. Fixes #575
2022-04-04 15:11:45 +02:00
lucasgarfield
e649e5c385 CreateImageWizard: Override Data Driven Form Enter behavior
Resolves #466. The default behavior for the DDF Wizard is to either advance to
the next step or submit the form when the ENTER is pressed.

This is inappropriate for complex forms that contain many different
types of elements that are typically interacted with using ENTER. For
instance, the default behavior when a link is focused and ENTER is pressed
is not to open the link in a browser but to advance or submit the form.

This commit overrides the default behavior by passing an onKeyDown prop
to the wizard which calls a custom onKeyDown function. The new custom
function does not define any behavior for when ENTER is pressed,
but does recreate DDF's default ESCAPE behavior, which is to close the
modal.
2022-03-25 15:47:48 +01:00
Jacob Kozol
20c1537d8e CreateImageWizard: navigate to review step on recreate
When recreating an image navigate to the review step instead of the
initial step. This requires forming the step history to enable a
functional sidebar.
2022-03-23 12:30:42 +01:00
Jacob Kozol
d16f71c98f ImagesTable: add ability to recreate image type 2022-03-23 12:30:42 +01:00
Jacob Kozol
c3f86f3575 CreateImageWizard: enable passing initial state to CreateImageWizard 2022-03-23 12:30:42 +01:00
Jacob Kozol
7aaedd67ab CreateImageWizard: rename google to gcp in form state 2022-03-23 12:30:42 +01:00
lucasgarfield
db9bb31887 CreateImageWizard: Update Wizard description to match UI design
Changes the Wizard's description (defined in the schema) to `Image
builder allows you to create a custom image and push it to target
environments` as indicated in the UI design prototype. The previous
description (`Create a RHEL image and push it to cloud providers`)
is no longer accurate since CentOS images are also currently supported.
2022-03-04 16:44:12 +01:00
Jacob Kozol
c257eec540 CreateImageWizard: add image name field
Add a details step where the user can enter a descriptive image name.
This name is displayed in the review step above the Release. Both these
fields are now horizontal to save vertical space.
2022-03-02 16:24:35 +01:00
Sanne Raymaekers
350acbd21b CreateImageWizard: File system configuration 2022-02-28 15:27:09 +01:00
Jacob Kozol
e48e2ca659 CreateImageWizard: redesign registration step
Update the registration options to include registering without insights.
Also, improve the text info in the step.

The org id is also removed from the registration step since we no
longer display the id in this step.
2022-01-21 11:57:04 +01:00