forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
onboard to automated consumer testing
Signed-off-by: Austin Sullivan <[email protected]>
- Loading branch information
1 parent
3cf032f
commit 30c21cb
Showing
15 changed files
with
204 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
161 changes: 161 additions & 0 deletions
161
client/src/app/hooks/table-controls/useLocalTableControlState.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { useSelectionState } from "@pf-consumer-testing/lib-ui"; | ||
import { | ||
getLocalFilterDerivedState, | ||
useFilterState, | ||
useFilterUrlParams, | ||
} from "./filtering"; | ||
import { | ||
useSortState, | ||
getLocalSortDerivedState, | ||
useSortUrlParams, | ||
} from "./sorting"; | ||
import { | ||
getLocalPaginationDerivedState, | ||
usePaginationState, | ||
usePaginationUrlParams, | ||
} from "./pagination"; | ||
import { useExpansionState, useExpansionUrlParams } from "./expansion"; | ||
import { useActiveRowState, useActiveRowUrlParams } from "./active-row"; | ||
import { | ||
IExtraArgsForURLParamHooks, | ||
IUseLocalTableControlStateArgs, | ||
IUseTableControlPropsArgs, | ||
} from "./types"; | ||
|
||
export const useLocalTableControlState = < | ||
TItem, | ||
TColumnKey extends string, | ||
TSortableColumnKey extends TColumnKey, | ||
>( | ||
args: IUseLocalTableControlStateArgs<TItem, TColumnKey, TSortableColumnKey> | ||
): IUseTableControlPropsArgs<TItem, TColumnKey, TSortableColumnKey> => { | ||
const { | ||
items, | ||
filterCategories = [], | ||
sortableColumns = [], | ||
getSortValues, | ||
initialSort = null, | ||
hasPagination = true, | ||
initialItemsPerPage = 10, | ||
idProperty, | ||
initialSelected, | ||
isItemSelectable, | ||
} = args; | ||
|
||
const filterState = useFilterState(args); | ||
const { filteredItems } = getLocalFilterDerivedState({ | ||
items, | ||
filterCategories, | ||
filterState, | ||
}); | ||
|
||
const selectionState = useSelectionState({ | ||
items: filteredItems, | ||
isEqual: (a, b) => a[idProperty] === b[idProperty], | ||
initialSelected, | ||
isItemSelectable, | ||
}); | ||
|
||
const sortState = useSortState({ sortableColumns, initialSort }); | ||
const { sortedItems } = getLocalSortDerivedState({ | ||
sortState, | ||
items: filteredItems, | ||
getSortValues, | ||
}); | ||
|
||
const paginationState = usePaginationState({ | ||
initialItemsPerPage, | ||
}); | ||
const { currentPageItems } = getLocalPaginationDerivedState({ | ||
paginationState, | ||
items: sortedItems, | ||
}); | ||
|
||
const expansionState = useExpansionState<TColumnKey>(); | ||
|
||
const activeRowState = useActiveRowState(); | ||
|
||
return { | ||
...args, | ||
filterState, | ||
expansionState, | ||
selectionState, | ||
sortState, | ||
paginationState, | ||
activeRowState, | ||
totalItemCount: items.length, | ||
currentPageItems: hasPagination ? currentPageItems : sortedItems, | ||
}; | ||
}; | ||
|
||
// TODO refactor useUrlParams so it can be used conditionally (e.g. useStateOrUrlParams) so we don't have to duplicate all this. | ||
// this would mean all use[Feature]UrlParams hooks could be consolidated into use[Feature]State with a boolean option for whether to use URL params. | ||
|
||
export const useLocalTableControlUrlParams = < | ||
TItem, | ||
TColumnKey extends string, | ||
TSortableColumnKey extends TColumnKey, | ||
TURLParamKeyPrefix extends string = string, | ||
>( | ||
args: IUseLocalTableControlStateArgs<TItem, TColumnKey, TSortableColumnKey> & | ||
IExtraArgsForURLParamHooks<TURLParamKeyPrefix> | ||
): IUseTableControlPropsArgs<TItem, TColumnKey, TSortableColumnKey> => { | ||
const { | ||
items, | ||
filterCategories = [], | ||
sortableColumns = [], | ||
getSortValues, | ||
initialSort = null, | ||
hasPagination = true, | ||
initialItemsPerPage = 10, | ||
idProperty, | ||
initialSelected, | ||
isItemSelectable, | ||
} = args; | ||
|
||
const filterState = useFilterUrlParams(args); | ||
const { filteredItems } = getLocalFilterDerivedState({ | ||
items, | ||
filterCategories, | ||
filterState, | ||
}); | ||
|
||
const selectionState = useSelectionState({ | ||
items: filteredItems, | ||
isEqual: (a, b) => a[idProperty] === b[idProperty], | ||
initialSelected, | ||
isItemSelectable, | ||
}); | ||
|
||
const sortState = useSortUrlParams({ ...args, sortableColumns, initialSort }); | ||
const { sortedItems } = getLocalSortDerivedState({ | ||
sortState, | ||
items: filteredItems, | ||
getSortValues, | ||
}); | ||
|
||
const paginationState = usePaginationUrlParams({ | ||
...args, | ||
initialItemsPerPage, | ||
}); | ||
const { currentPageItems } = getLocalPaginationDerivedState({ | ||
paginationState, | ||
items: sortedItems, | ||
}); | ||
|
||
const expansionState = useExpansionUrlParams<TColumnKey>(args); | ||
|
||
const activeRowState = useActiveRowUrlParams(args); | ||
|
||
return { | ||
...args, | ||
filterState, | ||
expansionState, | ||
selectionState, | ||
sortState, | ||
paginationState, | ||
activeRowState, | ||
totalItemCount: items.length, | ||
currentPageItems: hasPagination ? currentPageItems : sortedItems, | ||
}; | ||
}; |
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...pages/issues/issue-detail-drawer/file-incidents-detail-modal/file-all-incidents-table.tsx
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
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
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
5 changes: 4 additions & 1 deletion
5
client/src/app/pages/reports/application-selection-context.tsx
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["config:base"], | ||
"enabledManagers": ["npm"], | ||
"rangeStrategy": "bump", | ||
"includeForks": true, | ||
"packageRules": [ | ||
{ | ||
"packagePatterns": ["*"], | ||
"excludePackagePatterns": ["@patternfly/*"], | ||
"enabled": false | ||
}, | ||
{ | ||
"datasources": ["npm"], | ||
"packagePatterns": ["@patternfly/*"], | ||
"excludePackageNames": ["@patternfly/documentation-framework", "@patternfly/patternfly-a11y"], | ||
"groupName": "patternfly", | ||
"followTag": "prerelease" | ||
}, | ||
{ | ||
"datasources": ["npm"], | ||
"matchPackageNames": ["@patternfly/documentation-framework", "@patternfly/patternfly-a11y"], | ||
"groupName": "patternfly", | ||
"followTag": "latest" | ||
} | ||
] | ||
} |