-
Notifications
You must be signed in to change notification settings - Fork 44
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
✨ Dynamic Reports: Implement server-side filtering hooks and example usage on Dependencies table and Issues table #839
Merged
Conversation
This file contains 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
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
…tate, start on useFilterState Signed-off-by: Mike Turley <[email protected]>
…terState Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
…he filter/sort/pagination folders Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
97e8d5d
to
36c907f
Compare
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
54452ee
to
20a94eb
Compare
Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
…tests?" This reverts commit 3ad7625. Signed-off-by: Mike Turley <[email protected]>
Signed-off-by: Mike Turley <[email protected]>
ibolton336
approved these changes
Apr 28, 2023
This was referenced May 2, 2023
mturley
added a commit
that referenced
this pull request
May 3, 2023
Just a couple little things I missed in #839. --------- Signed-off-by: Mike Turley <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #829.
Part of #827. All that remains to close that issue is adding the drawer.
@app/shared/hooks/use-table-controls
totable-controls
filtering
,sorting
andpagination
undertable-controls
, each with:use*State.ts
, for state storage only (with React state and URL param variants of each)getLocal*DerivedState.ts
, for the logic specific to client-side filtering/sorting/pagination that was removed from each state hookuseLocal*DerivedState
because they were not calling any hooks, and it made sense to reserve theuse
naming for things that must conform to React's hook rules.get*HubRequestParams.ts
, for returning partial slices of theHubRequestParams
object relevant to each concern from state and other args, and also containsserialize*RequestParamsForHub
functions for converting each slice ofHubRequestParams
into the actual URLSearchParams used by the backend.get*Props.ts
, for PatternFly-specific props we can derive for each concernusePaginationEffects.ts
, which contains the special useEffect case we needed for pagination only (making sure we return the user to a valid page if the results change in a refetch and they end up in an invalid place). If we end up needing useEffect calls for the other concerns, we could add a similar hook for them.getFilterHubRequestParams.ts
for most of the new complexity.useTableControlState
touseLocalTableControlState
to make it more clear that it is only for use when working with local client-side filtering/sorting/pagination.@app/utils/hub-request-utils.ts
to@app/shared/hooks/table-controls/getHubRequestParams.ts
because it is coupled to the table-controls concerns and its logic could be refactored out into the separate functions for each concern described above.getHubRequestParams.ts
now simply calls all theget*HubRequestParams
andserialize*RequestParamsForHub
functions that have been separated per slice, and combines them.HubRequestParams
and converting that toURLSearchParams
is useful becauseHubRequestParams
is retained on response objects for inspection, and it provides a structured way to think about the hub's params without worrying about the actual serialization of them.useLegacyFilterState
was introduced to replace the existing usages ofuseFilterState
which rely on retaining the derived state logic (client-side filtering). I was able to fully reuseuseFilterState
andgetLocalFilterDerivedState
within it so we don't have any duplicated logic, just a shim for the old calls.useLegacyPaginationState
to reuseusePaginationState
,usePaginationEffects
,getLocalPaginationDerivedState
andgetPaginationProps
so we no longer have any duplicated logic. Any bug fixes to filtering and pagination will apply to old usages of them as well.useLegacySortState
because its paradigm is too different to easily share code (it relies on column indexes instead of columnKeys).useUrlParams
to support removing params from the URL when they are empty (represented by a null value in the deserialized param). This is used so that when filters are missing or cleared, we don't have an extrafilters
param in the URL with nothing in it, and we can simplify logic that checks if there are no filters.TFilterCategoryKey
to theFilterCategory
types anduseFilterState
/useLegacyFilterState
hooks. This allows thefilterValues
object to be strictly typed (asRecord<TFilterCategoryKey, FilterValue>
instead ofRecord<string, FilterValue>
) and support autocomplete, because its keys are known (they come from thekey
property of each filter category object).useLegacyFilterState
across the UI. Also, in each of the old calls, sincefilterCategories
must be initialized in a variable outside the state hooks and FilterToolbar where theTItem
type is known, it must be passed the type params explicitly. TypeScript does not currently support inference of some generic type params when others are passed in, you must pass in either none of them or all of them. So this means each of those calls must repeat all thekey
values from the filterCategories as a string union type. This is something we could fix if TypeScript incorporates a new feature in development: Perform partial inference with partially filled type parameter lists microsoft/TypeScript#54047