From d4c8d71bd17bcef45aff6f4d07421267f823106d Mon Sep 17 00:00:00 2001 From: lucasgarfield Date: Tue, 3 Jan 2023 11:43:01 +0100 Subject: [PATCH] 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. --- .../CreateImageWizard/CreateImageWizard.js | 12 +++++++++--- .../CreateImageWizard/formComponents/Repositories.js | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Components/CreateImageWizard/CreateImageWizard.js b/src/Components/CreateImageWizard/CreateImageWizard.js index bd7dc2e3..55dadb9f 100644 --- a/src/Components/CreateImageWizard/CreateImageWizard.js +++ b/src/Components/CreateImageWizard/CreateImageWizard.js @@ -359,9 +359,15 @@ const requestToState = (composeRequest) => { formState['selected-packages'] = packs; // repositories - // 'payload-repositories' is treated as read-only and is used to populate - // the table in the repositories table - formState['payload-repositories'] = + // 'original-payload-repositories' is treated as read-only and is used to populate + // the table in the repositories step + // This is necessary because there may be repositories present in the request's + // json blob that are not managed using the content sources API. In that case, + // they are still displayed in the table of repositories but without any information + // from the content sources API (in other words, only the URL of the repository is + // displayed). This information needs to persist throughout the lifetime of the + // Wizard as it is needed every time the repositories step is visited. + formState['original-payload-repositories'] = composeRequest?.customizations?.payload_repositories; // 'custom-repositories' is mutable and is used to generate the request // sent to image-builder diff --git a/src/Components/CreateImageWizard/formComponents/Repositories.js b/src/Components/CreateImageWizard/formComponents/Repositories.js index 566303af..19b3a9ba 100644 --- a/src/Components/CreateImageWizard/formComponents/Repositories.js +++ b/src/Components/CreateImageWizard/formComponents/Repositories.js @@ -135,7 +135,8 @@ const Repositories = (props) => { // Repositories in the form state can be present when 'Recreate image' is used // to open the wizard that are not necessarily in content sources. - const formStateReposList = getState()?.values?.['payload-repositories']; + const formStateReposList = + getState()?.values?.['original-payload-repositories']; const mergeRepositories = (contentSourcesRepos, formStateReposList) => { const formStateRepos = {};