-
Notifications
You must be signed in to change notification settings - Fork 14
feat(PaginatedStorage): add grouping #1364
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7fb1083
feat(PaginatedStorage): add grouping
artemmufazalov 99bf387
fix: enable search for table groups
artemmufazalov e68eb32
fix: add additional fields to grouping
artemmufazalov 03dd19b
fix(StorageControls): move group by label
artemmufazalov d8e5339
review: add groups right padding
artemmufazalov 8da4d30
preserve expanded groups on search change
artemmufazalov dfb88ca
review: add tabindes to table group title
artemmufazalov d27f6c0
review: use different group by query params
artemmufazalov 299910e
review: use button to wrap group title
artemmufazalov 35064d1
review: add button title
artemmufazalov 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1,22 @@ | ||
import {StringParam, useQueryParams} from 'use-query-params'; | ||
import {PaginatedStorageGroups} from './PaginatedStorageGroups'; | ||
import {PaginatedStorageNodes} from './PaginatedStorageNodes'; | ||
import {useStorageQueryParams} from './useStorageQueryParams'; | ||
|
||
import {AccessDenied} from '../../components/Errors/403/AccessDenied'; | ||
import {ResponseError} from '../../components/Errors/ResponseError/ResponseError'; | ||
import type {RenderControls, RenderErrorMessage} from '../../components/PaginatedTable'; | ||
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster'; | ||
import {VISIBLE_ENTITIES} from '../../store/reducers/storage/constants'; | ||
import {storageTypeSchema, visibleEntitiesSchema} from '../../store/reducers/storage/types'; | ||
import type {StorageType, VisibleEntities} from '../../store/reducers/storage/types'; | ||
import {NodesUptimeFilterValues, nodesUptimeFilterValuesSchema} from '../../utils/nodes'; | ||
import {useAdditionalNodeProps} from '../AppWithClusters/useClusterData'; | ||
|
||
import {StorageControls} from './StorageControls/StorageControls'; | ||
import {PaginatedStorageGroups} from './StorageGroups/PaginatedStorageGroups'; | ||
import {useStorageGroupsSelectedColumns} from './StorageGroups/columns/hooks'; | ||
import {PaginatedStorageNodes} from './StorageNodes/PaginatedStorageNodes'; | ||
import {useStorageNodesSelectedColumns} from './StorageNodes/columns/hooks'; | ||
|
||
interface PaginatedStorageProps { | ||
export interface PaginatedStorageProps { | ||
database?: string; | ||
nodeId?: string; | ||
groupId?: string; | ||
parentContainer?: Element | null; | ||
} | ||
|
||
export const PaginatedStorage = ({ | ||
database, | ||
nodeId, | ||
groupId, | ||
parentContainer, | ||
}: PaginatedStorageProps) => { | ||
const {balancer} = useClusterBaseInfo(); | ||
const {additionalNodesProps} = useAdditionalNodeProps({balancer}); | ||
export const PaginatedStorage = (props: PaginatedStorageProps) => { | ||
const {storageType} = useStorageQueryParams(); | ||
|
||
const [queryParams, setQueryParams] = useQueryParams({ | ||
type: StringParam, | ||
visible: StringParam, | ||
search: StringParam, | ||
uptimeFilter: StringParam, | ||
}); | ||
const storageType = storageTypeSchema.parse(queryParams.type); | ||
const isGroups = storageType === 'groups'; | ||
const isNodes = storageType === 'nodes'; | ||
|
||
const visibleEntities = visibleEntitiesSchema.parse(queryParams.visible); | ||
const searchValue = queryParams.search ?? ''; | ||
const nodesUptimeFilter = nodesUptimeFilterValuesSchema.parse(queryParams.uptimeFilter); | ||
|
||
const { | ||
columnsToShow: storageNodesColumnsToShow, | ||
columnsToSelect: storageNodesColumnsToSelect, | ||
setColumns: setStorageNodesSelectedColumns, | ||
} = useStorageNodesSelectedColumns({ | ||
additionalNodesProps, | ||
visibleEntities, | ||
database, | ||
groupId, | ||
}); | ||
|
||
const { | ||
columnsToShow: storageGroupsColumnsToShow, | ||
columnsToSelect: storageGroupsColumnsToSelect, | ||
setColumns: setStorageGroupsSelectedColumns, | ||
} = useStorageGroupsSelectedColumns(visibleEntities); | ||
|
||
const handleTextFilterChange = (value: string) => { | ||
setQueryParams({search: value || undefined}, 'replaceIn'); | ||
}; | ||
|
||
const handleGroupVisibilityChange = (value: VisibleEntities) => { | ||
setQueryParams({visible: value}, 'replaceIn'); | ||
}; | ||
|
||
const handleStorageTypeChange = (value: StorageType) => { | ||
setQueryParams({type: value}, 'replaceIn'); | ||
}; | ||
|
||
const handleUptimeFilterChange = (value: NodesUptimeFilterValues) => { | ||
setQueryParams({uptimeFilter: value}, 'replaceIn'); | ||
}; | ||
|
||
const handleShowAllGroups = () => { | ||
handleGroupVisibilityChange(VISIBLE_ENTITIES.all); | ||
}; | ||
|
||
const handleShowAllNodes = () => { | ||
setQueryParams( | ||
{ | ||
visible: VISIBLE_ENTITIES.all, | ||
uptimeFilter: NodesUptimeFilterValues.All, | ||
}, | ||
'replaceIn', | ||
); | ||
}; | ||
|
||
const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => { | ||
const columnsToSelect = isGroups | ||
? storageGroupsColumnsToSelect | ||
: storageNodesColumnsToSelect; | ||
|
||
const handleSelectedColumnsUpdate = isGroups | ||
? setStorageGroupsSelectedColumns | ||
: setStorageNodesSelectedColumns; | ||
|
||
return ( | ||
<StorageControls | ||
searchValue={searchValue} | ||
handleSearchValueChange={handleTextFilterChange} | ||
withTypeSelector | ||
storageType={storageType} | ||
handleStorageTypeChange={handleStorageTypeChange} | ||
visibleEntities={visibleEntities} | ||
handleVisibleEntitiesChange={handleGroupVisibilityChange} | ||
nodesUptimeFilter={nodesUptimeFilter} | ||
handleNodesUptimeFilterChange={handleUptimeFilterChange} | ||
entitiesCountCurrent={foundEntities} | ||
entitiesCountTotal={totalEntities} | ||
entitiesLoading={!inited} | ||
columnsToSelect={columnsToSelect} | ||
handleSelectedColumnsUpdate={handleSelectedColumnsUpdate} | ||
/> | ||
); | ||
}; | ||
|
||
const renderErrorMessage: RenderErrorMessage = (error) => { | ||
if (error.status === 403) { | ||
return <AccessDenied position="left" />; | ||
} | ||
|
||
return <ResponseError error={error} />; | ||
}; | ||
|
||
if (isNodes) { | ||
return ( | ||
<PaginatedStorageNodes | ||
searchValue={searchValue} | ||
visibleEntities={visibleEntities} | ||
nodesUptimeFilter={nodesUptimeFilter} | ||
database={database} | ||
onShowAll={handleShowAllNodes} | ||
parentContainer={parentContainer} | ||
renderControls={renderControls} | ||
renderErrorMessage={renderErrorMessage} | ||
columns={storageNodesColumnsToShow} | ||
/> | ||
); | ||
return <PaginatedStorageNodes {...props} />; | ||
} | ||
|
||
return ( | ||
<PaginatedStorageGroups | ||
searchValue={searchValue} | ||
visibleEntities={visibleEntities} | ||
database={database} | ||
nodeId={nodeId} | ||
onShowAll={handleShowAllGroups} | ||
parentContainer={parentContainer} | ||
renderControls={renderControls} | ||
renderErrorMessage={renderErrorMessage} | ||
columns={storageGroupsColumnsToShow} | ||
/> | ||
); | ||
return <PaginatedStorageGroups {...props} />; | ||
}; |
Oops, something went wrong.
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.
This allows not to show 50 (limit) loading rows for the last chunk, when we know how many entities are left. Also it allows to set some predefined initial length to table