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

feat(PaginatedStorage): add grouping #1364

Merged
merged 10 commits into from
Sep 30, 2024

Conversation

artemmufazalov
Copy link
Member

@artemmufazalov artemmufazalov commented Sep 26, 2024

Closes: #1365

Stand: https://nda.ya.ru/t/_9dz2Iw678WGs4

To test grouping, enable Use paginated tables setting in experiments

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
124 120 0 4 0

Bundle Size: 🔺

Current: 79.13 MB | Main: 79.08 MB
Diff: +0.04 MB (0.06%)

⚠️ Bundle size increased. Please review.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Comment on lines +106 to +108
const chunkOffset = id * limit;
const remainingLenght = totalLength - chunkOffset;
const calculatedChunkLength = remainingLenght < limit ? remainingLenght : limit;
Copy link
Member Author

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

Comment on lines +176 to +194
<StorageGroupsControls
withTypeSelector
entitiesCountCurrent={storageGroups.length}
entitiesCountTotal={groupsTotalCount}
entitiesLoading={isLoading}
columnsToSelect={storageGroupsColumnsToSelect}
handleSelectedColumnsUpdate={setStorageGroupsSelectedColumns}
/>
) : null}
{isNodes ? (
<StorageNodesControls
withTypeSelector
entitiesCountCurrent={storageNodes.length}
entitiesCountTotal={nodesTotalCount}
entitiesLoading={isLoading}
columnsToSelect={storageNodesColumnsToSelect}
handleSelectedColumnsUpdate={setStorageNodesSelectedColumns}
/>
) : null}
Copy link
Member Author

Choose a reason for hiding this comment

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

Added different controls to the same component. As the next step Storage could be split into two components like PaginatedStorage

Comment on lines -12 to -14
const getConcurrentId = (limit?: number, offset?: number) => {
return `getStorageGroups|offset${offset}|limit${limit}`;
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Requests are managed by PaginatedTable and rtk-query, there is no need to manage it additionally by axios, moreover - in case with grouping it creates a bug

@Raubzeug
Copy link
Contributor

Let's add padding on the right of the groups container.
Screenshot 2024-09-30 at 09 49 45

@Raubzeug
Copy link
Contributor

If filter is set, I would probably expand groups, that contain filtered entities.
Screenshot 2024-09-30 at 09 55 34

@Raubzeug
Copy link
Contributor

I think we should preserve selected GroupBy setting when switch between Groups and Nodes storage.


const renderTitle = () => {
return (
<div onClick={toggleCollapsed} className={b('title-wrapper')}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets try to use button here, otherwise the element isn't reachable from keyboard

Copy link
Member Author

Choose a reason for hiding this comment

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

Button applies it's own styles, that doesn't fit here, so I added tabIndex to div

Copy link
Contributor

Choose a reason for hiding this comment

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

For now I may focus, but it doesn't expand on Enter.
Lets use button css api, like in this example.

@artemmufazalov
Copy link
Member Author

If filter is set, I would probably expand groups, that contain filtered entities

Groups are filtered as well, so all groups on the screen will have only filtered entities

@artemmufazalov
Copy link
Member Author

If filter is set, I would probably expand groups, that contain filtered entities

Groups are filtered as well, so all groups on the screen will have only filtered entities

There is an issue with groups being closed every time search changes, I will fix it

@artemmufazalov
Copy link
Member Author

I think we should preserve selected GroupBy setting when switch between Groups and Nodes storage.

It's preserved if it's the property, that exist for both nodes and groups. You may try "Disk space usage".

However, if it's a property, that doesn't valid for one type of storage - it isn't used, so if groups will be grouped by PoolName and then storage type will change, storage nodes won't be grouped by PoolName - currently it is not possible

In the code single search query groupBy param is used for both types of storage:

// StorageGroups
export const storageGroupsGroupByParamSchema = z
    .custom<
        GroupsGroupByField | undefined
    >((value) => STORAGE_GROUPS_GROUP_BY_PARAMS.includes(value))
    .catch(undefined);

// StorageNodes
export const storageNodesGroupByParamSchema = z
    .custom<NodesGroupByField | undefined>((value) => STORAGE_NODES_GROUP_BY_PARAMS.includes(value))
    .catch(undefined);

// useStorageQueryParams
const storageGroupsGroupByParam = storageGroupsGroupByParamSchema.parse(queryParams.groupBy);
const storageNodesGroupByParam = storageNodesGroupByParamSchema.parse(queryParams.groupBy);

@Raubzeug
Copy link
Contributor

It's preserved if it's the property, that exist for both nodes and groups. You may try "Disk space usage".

I'm not sure this is a proper way to handle it... as for me, we have to different storage types. And we should treat them separately. All controls should belong to selected storage type.

@Raubzeug
Copy link
Contributor

There is an issue with groups being closed every time search changes, I will fix it

It seems you did a fix, for now expand state doesn't reset on search change. But what do you think if we automatically expand a group, if 1) search is not empty 2) only one group is in result.

@artemmufazalov
Copy link
Member Author

It seems you did a fix, for now expand state doesn't reset on search change. But what do you think if we automatically expand a group, if 1) search is not empty 2) only one group is in result.

I don't like the idea to expand something automatically.

This groups can be used not only to group entities, but also to view overall cluster statistics. By enabling some group by option, I can see, how cluster feels in term of that option.

Automatic expand does't really suit this case. There is no indication on how much table groups are rendered. We have only one group -> it's automatically expanded -> it's not obvious for me, that we have only one group until I scroll to bottom.

Also it's optimization - content is not loaded and rendered until group is expanded.

To sum up, I don't think we should auto expand, but we can discuss it and implement in next iteration if needed

@Raubzeug
Copy link
Contributor

To sum up, I don't think we should auto expand, but we can discuss it and implement in next iteration if needed

Agree with your args! lets stick to this implementation. Think about it if we have users request.

@artemmufazalov artemmufazalov added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 93dd920 Sep 30, 2024
5 checks passed
@artemmufazalov artemmufazalov deleted the 1302-paginated-storage-grouping branch September 30, 2024 16:10
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.

add grouping to PaginatedStorage
2 participants