Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Dec 16, 2024
1 parent 7d62552 commit eed3c61
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 111 deletions.
2 changes: 1 addition & 1 deletion backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const blankDashboardCR: DashboardConfig = {
disableKServeRaw: true,
disableModelMesh: false,
disableAcceleratorProfiles: false,
disableHardwareProfiles: true,
disableHardwareProfiles: false,
disableDistributedWorkloads: false,
disableModelRegistry: false,
disableModelRegistrySecureDB: true,
Expand Down
16 changes: 0 additions & 16 deletions frontend/src/__tests__/cypress/cypress/pages/hardwareProfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Contextual } from '~/__tests__/cypress/cypress/pages/components/Contextual';
import { Modal } from './components/Modal';
import { TableRow } from './components/table';

class HardwareProfileTableToolbar extends Contextual<HTMLElement> {
Expand Down Expand Up @@ -105,19 +104,4 @@ class HardwareProfile {
}
}

class DisableHardwareProfileModal extends Modal {
constructor() {
super('Disable hardware profile');
}

findDisableButton() {
return this.findFooter().findByRole('button', { name: 'Disable' });
}

findCancelButton() {
return this.findFooter().findByRole('button', { name: 'Cancel' });
}
}

export const hardwareProfile = new HardwareProfile();
export const disableHardwareProfileModal = new DisableHardwareProfileModal();
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
hardwareProfile,
disableHardwareProfileModal,
} from '~/__tests__/cypress/cypress/pages/hardwareProfile';
import { hardwareProfile } from '~/__tests__/cypress/cypress/pages/hardwareProfile';
import { mockHardwareProfile } from '~/__mocks__/mockHardwareProfile';
import { deleteModal } from '~/__tests__/cypress/cypress/pages/components/DeleteModal';
import { HardwareProfileModel } from '~/__tests__/cypress/cypress/utils/models';
Expand Down Expand Up @@ -90,7 +87,9 @@ describe('Hardware Profile', () => {
hardwareProfileTableToolbar.findFilterInput('name').clear();
hardwareProfile.findRows().should('have.length', 2);

hardwareProfileTableToolbar.findFilterMenuOption('filter-toolbar-dropdown', 'Enable').click();
hardwareProfileTableToolbar
.findFilterMenuOption('filter-toolbar-dropdown', 'Enabled')
.click();
hardwareProfileTableToolbar.selectEnableFilter('Enabled');
hardwareProfile.findRows().should('have.length', 1);
hardwareProfile.getRow('Test Hardware Profile').find().should('exist');
Expand Down Expand Up @@ -133,7 +132,6 @@ describe('Hardware Profile', () => {
hardwareProfile.getRow('Test Hardware Profile Delete').findEnabled().should('not.be.checked');
hardwareProfile.getRow('Test Hardware Profile').findEnabled().should('be.checked');
hardwareProfile.getRow('Test Hardware Profile').findEnableSwitch().click();
disableHardwareProfileModal.findDisableButton().click();

cy.wait('@toggleHardwareProfile').then((interception) => {
expect(interception.request.body).to.eql([
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import useNotification from '~/utilities/useNotification';
import { toggleHardwareProfileEnablement } from '~/api';
import { HardwareProfileKind } from '~/k8sTypes';

import DisableHardwareProfileModal from '~/pages/hardwareProfiles/DisableHardwareProfileModal';

type HardwareProfileEnableToggleProps = {
hardwareProfile: HardwareProfileKind;
refreshHardwareProfiles: () => void;
Expand All @@ -16,8 +14,6 @@ const HardwareProfileEnableToggle: React.FC<HardwareProfileEnableToggleProps> =
refreshHardwareProfiles,
}) => {
const { enabled } = hardwareProfile.spec;
const label = enabled ? 'enabled' : 'stopped';
const [isModalOpen, setIsModalOpen] = React.useState(false);
const [isEnabled, setEnabled] = React.useState(enabled);
const [isLoading, setLoading] = React.useState(false);
const notification = useNotification();
Expand Down Expand Up @@ -46,33 +42,14 @@ const HardwareProfileEnableToggle: React.FC<HardwareProfileEnableToggleProps> =
};

return (
<>
<Switch
aria-label={label}
data-testid="enable-switch"
id={`${hardwareProfile.metadata.name}-enable-switch`}
isChecked={isEnabled}
isDisabled={isLoading}
onChange={() => {
if (isEnabled) {
setIsModalOpen(true);
} else {
handleChange(true);
}
}}
/>
{isModalOpen ? (
<DisableHardwareProfileModal
data-testid="disable-hardware-profile-modal"
onClose={(confirmStatus) => {
if (confirmStatus) {
handleChange(false);
}
setIsModalOpen(false);
}}
/>
) : null}
</>
<Switch
aria-label={enabled ? 'enabled' : 'stopped'}
data-testid="enable-switch"
id={`${hardwareProfile.metadata.name}-enable-switch`}
isChecked={isEnabled}
isDisabled={isLoading}
onChange={(_e, checked) => handleChange(checked)}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const HardwareProfilesTable: React.FC<HardwareProfilesTableProps> = ({
() =>
hardwareProfiles.filter((cr) => {
const nameFilter = filterData.Name?.toLowerCase();
const enableFilter = filterData.Enable;
const enableFilter = filterData.Enabled;

if (nameFilter && !cr.spec.displayName.toLowerCase().includes(nameFilter)) {
return false;
Expand Down
15 changes: 4 additions & 11 deletions frontend/src/pages/hardwareProfiles/HardwareProfilesTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
StackItem,
Timestamp,
TimestampTooltipVariant,
Title,
} from '@patternfly/react-core';
import { ActionsColumn, ExpandableRowContent, Tbody, Td, Tr } from '@patternfly/react-table';
import { relativeTime } from '~/utilities/time';
Expand Down Expand Up @@ -51,7 +50,7 @@ const HardwareProfilesTableRow: React.FC<HardwareProfilesTableRowProps> = ({
truncateDescriptionLines={2}
/>
</Td>
<Td dataLabel="Enable">
<Td dataLabel="Enabled">
<HardwareProfileEnableToggle
hardwareProfile={hardwareProfile}
refreshHardwareProfiles={refreshHardwareProfiles}
Expand Down Expand Up @@ -105,29 +104,23 @@ const HardwareProfilesTableRow: React.FC<HardwareProfilesTableRowProps> = ({
{hardwareProfile.spec.identifiers &&
hardwareProfile.spec.identifiers.length !== 0 && (
<StackItem>
<Title headingLevel="h6" size="md">
Node resources
</Title>
<p className="pf-v6-u-font-weight-bold">Node resources</p>
<NodeResourceTable nodeResources={hardwareProfile.spec.identifiers} />
<Divider />
</StackItem>
)}
{hardwareProfile.spec.nodeSelectors &&
hardwareProfile.spec.nodeSelectors.length !== 0 && (
<StackItem>
<Title headingLevel="h6" size="md">
Node selectors
</Title>
<p className="pf-v6-u-font-weight-bold">Node selectors</p>
<NodeSelectorTable nodeSelectors={hardwareProfile.spec.nodeSelectors} />
<Divider />
</StackItem>
)}
{hardwareProfile.spec.tolerations &&
hardwareProfile.spec.tolerations.length !== 0 && (
<StackItem>
<Title headingLevel="h6" size="md">
Tolerations
</Title>
<p className="pf-v6-u-font-weight-bold">Tolerations</p>
<TolerationTable tolerations={hardwareProfile.spec.tolerations} />
<Divider />
</StackItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const HardwareProfilesToolbar: React.FC<HardwareProfilesToolbarProps> = ({
onChange={(_event, value) => onChange(value)}
/>
),
[HardwareProfileFilterOptions.enable]: ({ value, onChange, ...props }) => (
[HardwareProfileFilterOptions.enabled]: ({ value, onChange, ...props }) => (
<SimpleSelect
{...props}
dataTestId="hardware-profile-filter-enable-select"
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/hardwareProfiles/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const hardwareProfileColumns: SortableData<HardwareProfileKind>[] = [
},
{
field: 'enablement',
label: 'Enable',
label: 'Enabled',
sortable: false,
info: {
popover: 'Indicates whether the hardware profile is available for new resources.',
Expand Down Expand Up @@ -131,12 +131,12 @@ export enum HardwareProfileEnableType {

export enum HardwareProfileFilterOptions {
name = 'Name',
enable = 'Enable',
enabled = 'Enabled',
}

export const hardwareProfileFilterOptions = {
[HardwareProfileFilterOptions.name]: 'Name',
[HardwareProfileFilterOptions.enable]: 'Enable',
[HardwareProfileFilterOptions.enabled]: 'Enabled',
};

export type HardwareProfileFilterDataType = Record<
Expand All @@ -146,5 +146,5 @@ export type HardwareProfileFilterDataType = Record<

export const initialHardwareProfileFilterData: HardwareProfileFilterDataType = {
[HardwareProfileFilterOptions.name]: '',
[HardwareProfileFilterOptions.enable]: undefined,
[HardwareProfileFilterOptions.enabled]: undefined,
};

0 comments on commit eed3c61

Please sign in to comment.