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(Storage): sort on backend #510

Merged
merged 3 commits into from
Aug 16, 2023
Merged

feat(Storage): sort on backend #510

merged 3 commits into from
Aug 16, 2023

Conversation

artemmufazalov
Copy link
Member

No description provided.

@@ -91,6 +94,7 @@ const storage: Reducer<StorageState, StorageAction> = (state = initialState, act
return {
...state,
visible: action.data,
usageFilter: [],
Copy link
Member Author

Choose a reason for hiding this comment

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

Reset usage filter on selector change. This fixes the bug when you select some values in storage filter and then change selector to some value (e.g. "Out of space"), and receive empty table with no opportunity to update the selector

Comment on lines +85 to +88
groupsSortValue?: StorageSortValue;
groupsSortOrder?: OrderType;
nodesSortValue?: NodesSortValue;
nodesSortOrder?: OrderType;
Copy link
Member Author

Choose a reason for hiding this comment

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

I split groups and nodes sort params to ensure more strict typing and reduce number of conditions connected with currently selected entity type

Copy link
Contributor

Choose a reason for hiding this comment

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

Moreover I'd better split this into two different reducers in the end.

Comment on lines +94 to +105
let defaultSortValue: StorageSortValue = STORAGE_SORT_VALUES.PoolName;
let defaultSortOrder: OrderType = ASCENDING;

if (visibleEntities === VISIBLE_ENTITIES.missing) {
defaultSortValue = STORAGE_SORT_VALUES.Degraded;
defaultSortOrder = DESCENDING;
}

if (visibleEntities === VISIBLE_ENTITIES.space) {
defaultSortValue = STORAGE_SORT_VALUES.Usage;
defaultSortOrder = DESCENDING;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

These default values previously was set in StorageGroups.

Changed UsedSpaceFlag to Usage since UsedSpaceFlag cannot be sorted via request params

Comment on lines +82 to +88
const defaultSortValue: NodesSortValue = NODES_SORT_VALUES.NodeId;
const defaultSortOrder: OrderType = ASCENDING;

return {
sortValue: state.storage.nodesSortValue || defaultSortValue,
sortOrder: state.storage.nodesSortOrder || defaultSortOrder,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

These default values previously was set in StorageNodes.

Removed sorting by Degraded disks since this values cannot be sorted via request params

Comment on lines +138 to +139
if (visibleEntities !== VISIBLE_ENTITIES.missing) {
columns = columns.filter((col) => col.name !== TableColumnsIds.Missing);
Copy link
Member Author

@artemmufazalov artemmufazalov Aug 15, 2023

Choose a reason for hiding this comment

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

Do not display Missing column both for All and Out of space radio values

Comment on lines +25 to +33
const TableColumnsIds = {
NodeId: 'NodeId',
Host: 'Host',
DC: 'DC',
Rack: 'Rack',
Uptime: 'Uptime',
PDisks: 'PDisks',
Missing: 'Missing',
} as const;
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated names, so they correspond to NODES_SORT_VALUES

Comment on lines +27 to +40
const TableColumnsIds = {
PoolName: 'PoolName',
Kind: 'Kind',
Erasure: 'Erasure',
GroupId: 'GroupId',
Used: 'Used',
Limit: 'Limit',
Usage: 'Usage',
UsedSpaceFlag: 'UsedSpaceFlag',
Read: 'Read',
Write: 'Write',
VDisks: 'VDisks',
Degraded: 'Degraded',
} as const;
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated names, so they correspond to STORAGE_SORT_VALUES

@@ -50,11 +58,6 @@ import './Storage.scss';

const b = cn('global-storage');

const tableSettings: Settings = {
...DEFAULT_TABLE_SETTINGS,
defaultOrder: DataTable.DESCENDING,
Copy link
Member Author

Choose a reason for hiding this comment

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

Default order values are set in sort params selectors

@artemmufazalov artemmufazalov marked this pull request as ready for review August 15, 2023 14:36
@@ -155,19 +174,23 @@ export const Storage = ({additionalNodesInfo, tenant, nodeId}: StorageProps) =>
<StorageGroups
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets make an issue to refactor Storage component - now its a little mess with different storage types, as for me it should be splitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +85 to +88
groupsSortValue?: StorageSortValue;
groupsSortOrder?: OrderType;
nodesSortValue?: NodesSortValue;
nodesSortOrder?: OrderType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Moreover I'd better split this into two different reducers in the end.

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