-
Notifications
You must be signed in to change notification settings - Fork 38
HMS-9590: refactor create and edit template worflow #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Starle21
wants to merge
54
commits into
content-services:main
Choose a base branch
from
Starle21:HMS-9590
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
551c379
jest: add new entry into module name mapper
Starle21 de25016
clean: forgotten console.log in TagsFilter
Starle21 b622db2
move: StatusIcon and PackageCount under generic components
Starle21 2adedff
change: early return in EmptyTableState component
Starle21 4503af5
move: helpers for TemplateDetails into that folder
Starle21 450b6af
move: AddOrEditTemplate under features
Starle21 09f1044
extract: create and edit workflows
Starle21 52c68ac
extract: cancel modal behavior
Starle21 a35de2a
extract: choose step behavior
Starle21 4abe5af
extract: logic from DefineContentStep
Starle21 3cc2425
extract: logic from RedhatRepositoriesStep
Starle21 d3e7af8
extract: logic from CustomRepositoriesStep
Starle21 7621680
extract: logic from SetUpDateStep
Starle21 27e14bc
extract: logic from DetailStep
Starle21 3479c40
extract: logic from ReviewStep
Starle21 578352d
rename: AddOrEditTemplate -> TemplateModalBase
Starle21 2e4ba76
extract: defineContent logic from AddTemplateContext
Starle21 998e4a8
rename: templateHelpers -> repositoryURLs
Starle21 262fab8
change: data structure of repositoryURLs
Starle21 92ffb67
extract: edit use-case from AddTemplateContext
Starle21 5fc6073
extract: checkIsDisabledStep from AddTemplateContext
Starle21 ec7f361
extract: queryClient from AddTemplateContext
Starle21 3ab5c16
add: types for the workflow
Starle21 bd725a7
move: shared core functions into shared folder
Starle21 f7af956
change: storage in AddTemplateContext
Starle21 43e7a4e
add: temporary set state from old to new storage
Starle21 55e4887
add, change: checking isEmptyTemplateRequest in AddTemplateContext
Starle21 ab63b15
change: use new template store api in enableStep
Starle21 cb55886
change: use new template store api in createTemplate
Starle21 2f2d1d2
change: use new template store api in editTemplate confirm
Starle21 c26182c
change: use new template store api in reviewTemplateRequest
Starle21 76e0ece
change: use new template store api in describeTemplate
Starle21 36455e7
change: use new template store api in defineContent
Starle21 a75e938
change: use new template store api in selectSnapshots
Starle21 612b230
change: use new template store api in repositories selection
Starle21 dc33809
change: use new template store api in editTemplate initialize
Starle21 6af4411
delete: old template request store in AddTemplateContext
Starle21 37261ad
change: enableStep
Starle21 148003e
rename: AddTemplateContextProvider -> TemplateStore
Starle21 4355dad
change: AddOrEditTemplateModal
Starle21 8a54a0c
extract: createNewTemplate use-case
Starle21 298605e
extract: confirmEditTemplate and getTemplate use-cases
Starle21 f6fcdb1
extract, change: use-cases in DefineContent
Starle21 bf73c30
extract, change: use-case and UI in selectSnapshots
Starle21 86af607
extract: restrictFutureDates and props in SnapshotPicker
Starle21 ccbee4b
extract, change: formatTemplateReview, ReviewTemplateContent
Starle21 7dc0518
extract, change: validate use-cases in describeTemplate
Starle21 0457704
extract: sort repositories table
Starle21 3cc7f35
extract: toggleSelectedRepository in redhatRepositories
Starle21 417962c
extract, change: structure of RedhatRepositoriesStore
Starle21 f6eb6c9
extract: toggleOtherRepository in otherRepositories
Starle21 5656ad0
extract: refreshRepositories
Starle21 74c5f9b
extract, change: structure of CustomRepositoriesStore
Starle21 19e8a9d
documentation: notes for create template feature refactor
Starle21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/features/createAndEditTemplate/defineContent/api/fetchHardcodedRepositories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { RepositoryListServerResponse } from 'features/createAndEditTemplate/shared/types/types.repository'; | ||
| import useErrorNotification from 'Hooks/useErrorNotification'; | ||
| import { useQueryClient } from 'react-query'; | ||
| import { ContentOrigin, getContentList } from 'services/Content/ContentApi'; | ||
| import { CONTENT_LIST_KEY } from 'services/Content/ContentQueries'; | ||
| import { FetchHardcodedRepositories } from '../core/ports'; | ||
|
|
||
| const PAGE = 1; | ||
| const LIMIT = 10; | ||
| const SORTBY = ''; | ||
| const CONTENT_ORIGIN = [ContentOrigin.REDHAT]; | ||
|
|
||
| export const useFetchHardcodedRepositories = () => { | ||
| const queryClient = useQueryClient(); | ||
| const errorNotifier = useErrorNotification(); | ||
|
|
||
| const fetch: FetchHardcodedRepositories = async (filterData) => { | ||
| const { architecture, osVersion } = filterData; | ||
| const queryKey = [CONTENT_LIST_KEY, architecture, osVersion]; | ||
|
|
||
| const formattedFilterData = { | ||
| availableForArch: architecture, | ||
| availableForVersion: osVersion, | ||
| }; | ||
| const queryFn = () => getContentList(PAGE, LIMIT, formattedFilterData, SORTBY, CONTENT_ORIGIN); | ||
|
|
||
| const options = { | ||
| staleTime: 20000, | ||
| }; | ||
|
|
||
| try { | ||
| const data = await queryClient.fetchQuery<RepositoryListServerResponse>( | ||
| queryKey, | ||
| queryFn, | ||
| options, | ||
| ); | ||
| return data.data; | ||
| } catch (err) { | ||
| errorNotifier( | ||
| 'Unable to get repositories list', | ||
| 'An error occurred', | ||
| err, | ||
| 'content-list-error', | ||
| ); | ||
| return []; | ||
| } | ||
| }; | ||
|
|
||
| return fetch; | ||
| }; |
25 changes: 25 additions & 0 deletions
25
src/features/createAndEditTemplate/defineContent/core/ports.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { FullRepository } from 'features/createAndEditTemplate/shared/types/types.repository'; | ||
| import { | ||
| SystemConfigurationsLists, | ||
| SelectedSystemConfiguration, | ||
| SystemConfigurationsResponse, | ||
| } from './types'; | ||
| import { | ||
| AllowedArchitecture, | ||
| AllowedOSVersion, | ||
| } from 'features/createAndEditTemplate/shared/types/types'; | ||
| import { UseQueryResult } from 'react-query'; | ||
|
|
||
| // input ports | ||
| export type GetRepositoryVersionsLists = () => SystemConfigurationsLists; | ||
| export type SelectArchitecture = (architecture: AllowedArchitecture) => void; | ||
| export type SelectOSVersion = (version: AllowedOSVersion) => void; | ||
| export type ChooseHardcodedUUIDs = (version: SelectedSystemConfiguration) => Promise<void>; | ||
|
|
||
| // output ports | ||
| export type FetchSystemConfigurations = () => UseQueryResult<SystemConfigurationsResponse>; | ||
| export type FetchHardcodedRepositories = ( | ||
| version: SelectedSystemConfiguration, | ||
| ) => Promise<FullRepository[]>; | ||
| // read from top level store - selectedArchitecture, selectedOSVersion | ||
| // set data in top level store - setArchitecture, setOSVersion, resetTemplateRequestContent |
24 changes: 24 additions & 0 deletions
24
src/features/createAndEditTemplate/defineContent/core/use-cases/chooseHardcodedUUIDs.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { useCallback } from 'react'; | ||
|
|
||
| import { useTemplateRequestApi } from 'features/createAndEditTemplate/workflow/store/TemplateStore'; | ||
| import { useFetchHardcodedRepositories } from '../../api/fetchHardcodedRepositories'; | ||
| import { lookupUrls } from 'features/createAndEditTemplate/shared/core/lookupUrls'; | ||
| import { filterHardcodedUUIDs } from '../domain/filterHardcodedUUIDs'; | ||
| import { ChooseHardcodedUUIDs } from '../ports'; | ||
|
|
||
| export const useChooseHardcodedUUIDs = () => { | ||
| const fetchHardcodedRepositories = useFetchHardcodedRepositories(); | ||
| const { setHardcodedUUIDs } = useTemplateRequestApi(); | ||
|
|
||
| const chooseHardcodedRedhatUUIDs: ChooseHardcodedUUIDs = async (version) => { | ||
| const repositories = await fetchHardcodedRepositories({ | ||
| architecture: version.architecture, | ||
| osVersion: version.osVersion, | ||
| }); | ||
| const hardcodedRedhatRepoUrls = lookupUrls(version); | ||
| const uuids = filterHardcodedUUIDs(repositories, hardcodedRedhatRepoUrls); | ||
| setHardcodedUUIDs(uuids); | ||
| }; | ||
|
|
||
| return useCallback(chooseHardcodedRedhatUUIDs, []); | ||
| }; |
12 changes: 12 additions & 0 deletions
12
src/features/createAndEditTemplate/defineContent/core/use-cases/initializeSystemsLists.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useMemo } from 'react'; | ||
| import { toDomain } from '../../api/versionsListToDomain'; | ||
| import { GetRepositoryVersionsLists } from '../ports'; | ||
| import { useRepositoryParams } from 'services/Content/ContentQueries'; | ||
|
|
||
| export const useInitializeSystemsLists: GetRepositoryVersionsLists = () => { | ||
| const { data } = useRepositoryParams(); | ||
|
|
||
| const filteredLists = useMemo(() => toDomain(data), [data]); | ||
|
|
||
| return filteredLists; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a different name here 😵💫
"systems" is a little miss-leading since that's something usually connected to Patch and actual systems, while this just gets the available template content config (repository parameters) options 💭