Skip to content
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

refactor(web): use queries for dealing with software #1483

Merged
merged 22 commits into from
Jul 23, 2024
Merged

Conversation

dgdavid
Copy link
Contributor

@dgdavid dgdavid commented Jul 18, 2024

Similar to #1439, #1452, and #1470, this set of changes aims to replace the client/software with TanStack queries.

Note that was not possible to fully drop the software client. It has to wait until migration of WithStatus and WithProgress mixins too.

Which allows to move some business logic from the UI to the queries,
helping to simplify the SoftwarePatternsSelection component.
Based on a query and as a replacement of client.software.onSelectedPatternsChange.
Otherwise does not work as expected. This changes, however, will force
to export all types in the file which was not the case until now.
Something to learn about and change or improve.
To avoid TS complaints after exporting the SelectedBy enum. Something to
re-check.
To avoid complaint about

> Property 'toBeChecked' does not exist on type 'Matchers<void, Element>'

See
testing-library/jest-dom#442 (comment)
and https://github.com/testing-library/jest-dom/releases/tag/v6.2.0
By using the useQueryClient hook instead of creating a new QueryClient
instance. Needed to make it work better when invalidating queries.
To make the export explicit but using the same approach as it is already
in use in JS files: exporting things at the end of file.
To avoid below error when running tests for tsx components

> Cannot read properties of undefined (reading 'createElement')

To know more see

  * https://dev.to/kkazala/jest-errors-1in7
  * https://www.typescriptlang.org/tsconfig/#esModuleInterop
Along with other small changes detected while resurrecting such tests.
@dgdavid dgdavid marked this pull request as ready for review July 22, 2024 16:03
@dgdavid dgdavid requested a review from imobachgs July 22, 2024 16:03
teclator added a commit that referenced this pull request Jul 23, 2024
Adapted the UI using TanStack query instead of route loaders and
useEffect hooks.


---

Related to #1439,
#1452,
#1470, and
#1483
Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good, just some minor things.

web/src/components/software/SoftwarePage.test.tsx Outdated Show resolved Hide resolved
web/src/queries/software.ts Show resolved Hide resolved
@dgdavid
Copy link
Contributor Author

dgdavid commented Jul 23, 2024

@imobachgs,

I have no idea why the src/components/users/RootAuthMethods.test.jsx test is failing now in CI. I have run it locally and, as expected, it pass.

PASS  src/components/users/RootAuthMethods.test.jsx (12.938 s)
...
Test Suites: 1 passed, 1 total
Tests:       21 passed, 21 total

@dgdavid
Copy link
Contributor Author

dgdavid commented Jul 23, 2024

@imobachgs,

I have no idea why the src/components/users/RootAuthMethods.test.jsx test is failing now in CI. I have run it locally and, as expected, it pass.
...

#1493 should fix the issue.

@dgdavid dgdavid merged commit 22d0125 into master Jul 23, 2024
1 of 2 checks passed
@dgdavid dgdavid deleted the software-queries branch July 23, 2024 14:00
dgdavid added a commit that referenced this pull request Jul 24, 2024
#1483 didn't drop dead software
client methods that were replaced by queries. Let's do it now.
dgdavid added a commit that referenced this pull request Jul 24, 2024
Defined types now live at types/software.

Related to #1483 and
#1496.
imobachgs added a commit that referenced this pull request Jul 25, 2024
At this moment, the code for working with product registration is not
used. Moreover, it has to be migrated to a TanStack Query approach
because reasons stated at #1439


Thus, we've agreed to drop it meanwhile in order to have less
dead/unused/pending to adapt code.

Please, note that changes were done on top of
#1498, reason why would be nice to
merge this after it. Additionally, it includes a removal of software
typedef comments that were forgotten at
#1483 and
#1496.
dgdavid added a commit that referenced this pull request Aug 2, 2024
By mistake, #1483 introduced a
tiny bug in the `useProductChanges` query hook by checking the
`event.type` against an empty string instead of the exepected
`ProductChanged` event.

https://github.com/openSUSE/agama/pull/1483/files#diff-e671c06f4a1cefe3bef4af838681c780f2ba41356d44f72f5ce97be1b6eead66R172-R185

This PR fixes it for properly performs the software config query
invalidation.
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants