-
Notifications
You must be signed in to change notification settings - Fork 177
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
Node resource table and modals #3565
base: main
Are you sure you want to change the base?
Conversation
WIP: needs some clarification around UX and data validation |
frontend/src/pages/hardwareProfiles/nodeResource/NodeResourceTableRow.tsx
Outdated
Show resolved
Hide resolved
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
13a9f2d
to
60d87b6
Compare
fd5b060
to
fd8a726
Compare
frontend/src/pages/hardwareProfiles/nodeResource/NodeResourceForm.tsx
Outdated
Show resolved
Hide resolved
frontend/src/pages/hardwareProfiles/nodeResource/ManageNodeResourceModal.tsx
Outdated
Show resolved
Hide resolved
frontend/src/pages/hardwareProfiles/nodeResource/ManageNodeResourceModal.tsx
Outdated
Show resolved
Hide resolved
frontend/src/pages/hardwareProfiles/nodeResource/NodeResourceTableRow.tsx
Outdated
Show resolved
Hide resolved
frontend/src/pages/hardwareProfiles/nodeResource/NodeResourceForm.tsx
Outdated
Show resolved
Hide resolved
I believe there should be a space between the numbers and the units in the table, e.g., "1 GiB", not "1GiB", bur defer to @kaedward. Also, the units in the table should match the units in the dropdown, e.g., "GiB", not "Gi". |
frontend/src/pages/hardwareProfiles/nodeResource/CountFormField.tsx
Outdated
Show resolved
Hide resolved
Could you also update the other table node table to now use your view only table |
I think all the tables should use |
@vconzola this formatting is consistent across the Dashboard, and you can see the same approach on the spawner page under cluster storage. Do you recommend we change it? |
@dpanshug Please keep the units and spacing consistent with what's in the dashboard today - don't change it. I thought I got it right everywhere in the mockups, but I guess not. Apologies for the confusion. |
<Td dataLabel="Default">{identifier.defaultCount}</Td> | ||
<Td dataLabel="Minimum allowed">{identifier.minCount}</Td> | ||
<Td dataLabel="Maximum allowed">{identifier.maxCount}</Td> | ||
{!showKebab && ( |
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 should be showKebab && ...
const NodeResourceTable: React.FC<NodeResourceTableProps> = ({ | ||
nodeResources, | ||
onUpdate, | ||
viewOnly, |
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.
Maybe considering change this to
const viewOnly = !onUpdate;
Because if it's not view only, it should always have an onUpdate
function.
updatedIdentifiers.splice(rowIndex, 1); | ||
onUpdate?.(updatedIdentifiers); | ||
}} | ||
showKebab={!!viewOnly} |
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.
Should be showKebab={!viewOnly}
after you make the change in the NodeResourceTableRow
label="Default" | ||
fieldId="default" |
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.
These are maximum allowed.
setNodeResources: (identifiers: Identifier[]) => void; | ||
}; | ||
|
||
export const ManageNodeResourceSection: React.FC<ManageNodeResourceSectionProps> = ({ |
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 is a single file, maybe consider exporting it as default
like other components?
|
||
return ( | ||
<Form> | ||
<FormGroup label="Resource label" fieldId="resource-label"> |
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.
Should add isRequired
/> | ||
</FormGroup> | ||
|
||
<FormGroup label="Resource identifier" fieldId="resource-identifier"> |
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.
Should add isRequired
if (existingIdentifier) { | ||
return true; | ||
} |
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.
Why are you not checking the identifier when editing? If I am editing a custom identifier, then it could be duplicated to another one, right? Try to create 2 identifiers, then edit one to change the identifier to the other and see if it throws the error.
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.
In another word, this check only needs to be
const isUniqueIdentifier =
identifier.identifier === existingIdentifier?.identifier ||
!nodeResources.some((i) => i.identifier === identifier.identifier);
existingIdentifier && | ||
(identifier.identifier === 'cpu' || identifier.identifier === 'memory') |
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.
I think this should be just:
existingIdentifier && | |
(identifier.identifier === 'cpu' || identifier.identifier === 'memory') | |
existingIdentifier?.identifier === 'cpu' || existingIdentifier?.identifier === 'memory' |
<FormGroup label="Resource identifier" fieldId="resource-identifier"> | ||
<TextInput | ||
value={identifier.identifier || ''} | ||
onChange={(_, value) => setIdentifier('identifier', value)} |
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 field should also be disabled if it's CPU
or RAM
based on what I saw in the mockups (Or probably disable it based on the identifier field, WDYT? @Gkrumbach07 )
|
||
return ( | ||
<Modal | ||
title={existingIdentifier ? 'Edit resource' : 'Add resource'} |
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.
Should be Edit node resource
and Add node resource
here.
|
||
const [unitOptions, setUnitOptions] = React.useState<UnitOption[]>(); | ||
|
||
const isUniqueIdentifier = React.useMemo(() => { |
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.
You don't need to use useMemo
on a boolean IMO, it's always reference-stable.
} | ||
}, [identifier]); | ||
|
||
const isButtonDisabled = React.useMemo(() => { |
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.
Same here, no need to use useMemo
const [validated, setValidated] = React.useState<'default' | 'error' | 'success'>('default'); | ||
|
||
React.useEffect(() => { | ||
setValidated(isUniqueIdentifier ? 'default' : 'error'); | ||
}, [isUniqueIdentifier]); |
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.
You don't need these at all:
const [validated, setValidated] = React.useState<'default' | 'error' | 'success'>('default'); | |
React.useEffect(() => { | |
setValidated(isUniqueIdentifier ? 'default' : 'error'); | |
}, [isUniqueIdentifier]); | |
const validated = isUniqueIdentifier ? 'default' : 'error'; |
existingIdentifier && | ||
(identifier.identifier === 'cpu' || identifier.identifier === 'memory') | ||
} | ||
validated={validated} |
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.
Missed error message here? Another resource with the same identifier already exists. The resource identifier must be unique.
const [isNodeResourceModalOpen, setIsNodeResourceModalOpen] = React.useState<boolean>(false); | ||
return ( | ||
<> | ||
<FormSection |
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.
In the mockup, there is a description under this section title. Also, the button is a link style below the table but not next to the section title. However, the description is missed here in this PR and the button becomes the secondary button next to the title.
I am OK with changing the edit and delete icon to the kebab menu. However, I am not sure about the description and also the add button because it can affect how we show the empty state.
Can you check and help confirm that @vconzola?
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.
Please implement as shown in the mockup including the description, the action icons in place of a kebab and the link button for Add resource. Thanks.
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.
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 is not the latest mocks. did you verify with the latest
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.
Where is the latest mock? I checked this one https://www.figma.com/design/UFhLtsPxoETwd39pnMsASV/Hardware-profiles?node-id=0-1&p=f&t=52XPdoeFVdZ2Bkl6-0.
|
||
return ( | ||
<> | ||
<Table |
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.
You will need to use TableBase
instead of Table
here. Otherwise, It will automatically sort on the first column, which is Resource label
even if we set sortable: false
here.
RHOAIENG-16256
Description
Added table and modal for Node resource for Hardware profile
How Has This Been Tested?
Currently this table and modal are standalone components and are not used anywhere, to tests you can import
<ManageNodeResourceSection />
to any form page, like i have tested this inManageAcceleratorProfile
Test Impact
Add unit tests for validation utility functions
Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main
@vconzola