Skip to content

feat(ws): Add properties tile to new workspace creation #262

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

Open
wants to merge 4 commits into
base: notebooks-v2
Choose a base branch
from

Conversation

henschwartz
Copy link

this PR resolve issue #225

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ederign for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenny-s51
Copy link
Member

jenny-s51 commented Apr 22, 2025

Great work here @henschwartz! I’ve PR‑ed your branch with a several tweaks, which includes:

  • Fix for the modal title so it’s now rendering correctly
  • Investigated the compact table issue - it is applying the correct pf-m-compact modifier and styling 🎉:
Screenshot 2025-04-22 at 5 00 48 PM

Copy link

@paulovmr paulovmr left a comment

Choose a reason for hiding this comment

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

Thanks @henschwartz ! I like the updates proposed by @jenny-s51 in her PR to your branch. I left a few more comments below.

import { WorkspaceCreationPropertiesTable } from '~/app/pages/Workspaces/Creation/properties/WorkspaceCreationPropertiesTable';
import { WorkspaceImage } from '~/shared/types';

interface Volume {

Choose a reason for hiding this comment

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

There is a part of the Workspace type that has the volumes inside it. Please consider extracting two types there (WorkspaceVolumes containing what is inside the volumes field and WorkspaceVolume containing what is inside the data field). Then this interface would not be needed, and the WorkspaceVolume type created could be used instead of it.

FormGroup,
} from '@patternfly/react-core';

interface Volume {

Choose a reason for hiding this comment

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

Same here.

readOnly: boolean;
}

interface WorkspaceCreationPropertiesTableProps {

Choose a reason for hiding this comment

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

Suggested change
interface WorkspaceCreationPropertiesTableProps {
interface WorkspaceCreationPropertiesVolumesProps {

setVolumes: React.Dispatch<React.SetStateAction<Volume[]>>;
}

export const WorkspaceCreationPropertiesTable: React.FC<WorkspaceCreationPropertiesTableProps> = ({

Choose a reason for hiding this comment

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

Suggested change
export const WorkspaceCreationPropertiesTable: React.FC<WorkspaceCreationPropertiesTableProps> = ({
export const WorkspaceCreationPropertiesVolumes: React.FC<WorkspaceCreationPropertiesVolumesProps> = ({

const [deleteIndex, setDeleteIndex] = useState<number | null>(null);
const [dropdownOpen, setDropdownOpen] = useState<number | null>(null);

const handleAddOrEdit = () => {

Choose a reason for hiding this comment

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

Please consider using useCallback here.

resetForm();
};

const handleEdit = (index: number) => {

Choose a reason for hiding this comment

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

Please consider using useCallback here.

setIsModalOpen(true);
};

const openDetachModal = (index: number) => {

Choose a reason for hiding this comment

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

Please consider using useCallback here.

setIsDeleteModalOpen(true);
};

const handleDelete = () => {

Choose a reason for hiding this comment

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

Please consider using useCallback here.

}
};

const resetForm = () => {

Choose a reason for hiding this comment

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

Please consider using useCallback here.

Copy link

@paulovmr paulovmr left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @henschwartz ! I left two more comments, and also there are a few linting errors, you can check and automatically fix some of them with npm run test:fix.

@@ -0,0 +1,205 @@
import React, { useCallback, useState } from 'react';

Choose a reason for hiding this comment

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

This file should be called WorkspaceCreationPropertiesVolumes.tsx.

/>
<ModalBody>
<Form>
<FormGroup label="PVC Name" isRequired fieldId="pvc-name">

Choose a reason for hiding this comment

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

IMO the volume creation modal should allow the user to set the volume as read-only with the slider component, like in the table.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Paulo, do you mean to take the read-only button to the create modal, put it inside, and disable the availability to edit it from the actual table? it means that it will be available for edit inside the next modal of edit exiting row in the table...
please confirm if that what you meant for

Choose a reason for hiding this comment

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

@henschwartz yes that is right, it would be only for visualization at the table.
Maybe @jenny-s51 could give an input on that to confirm it is better this way.

Copy link
Member

Choose a reason for hiding this comment

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

Great call-out @paulovmr - yes, for consistency we should handle the "read only" configuration in the modal and display the value in the table, rather than the switch. The "Edit" functionality should be reserved for within the modal.

@paulovmr
Copy link

/ok-to-test

Comment on lines 96 to 104
<Switch
id={`readonly-switch-${index}`}
isChecked={volume.readOnly}
onChange={() => {
const updated = [...volumes];
updated[index].readOnly = !updated[index].readOnly;
setVolumes(updated);
}}
/>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Switch
id={`readonly-switch-${index}`}
isChecked={volume.readOnly}
onChange={() => {
const updated = [...volumes];
updated[index].readOnly = !updated[index].readOnly;
setVolumes(updated);
}}
/>
{volume.readOnly ? 'Enabled' : 'Disabled'}

<Tr>
<Th>PVC Name</Th>
<Th>Mount Path</Th>
<Th>Read Only</Th>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Th>Read Only</Th>
<Th>Read-only Access</Th>

onChange={(_, val) => setFormData({ ...formData, mountPath: val })}
id="mount-path"
/>
</FormGroup>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
</FormGroup>
</FormGroup>
<FormGroup
fieldId="readonly-access"
>
<Switch
id="readonly-access-switch"
label="Enable read-only access"
isChecked={formData.readOnly}
onChange={() => setFormData({ ...formData, readOnly: !formData.readOnly })}
/>
</FormGroup>

@jenny-s51
Copy link
Member

jenny-s51 commented Apr 28, 2025

Thanks for making these updates @henschwartz!

I've left a few specific suggestions directly on the code to implement these changes following the thread above (cc @paulovmr).

The main points are:

  1. Relocating the Switch: Move from the table row into a new FormGroup within the create/edit volume modal, below the 'Mount Path' input.
  2. Update Table Display: Modify the 'Read-only Access' column in the table to display the status ('Enabled'/'Disabled') instead of using the switch.

This approach should provide a more intuitive flow for users by keeping all settings together in the modal.

Updated table:
Screenshot 2025-04-28 at 4 39 16 PM
Updated modal:
Screenshot 2025-04-28 at 4 39 28 PM

Just noting that with these changes, there is a vertical spacing difference between the text inputs and the switch in the modal. This is related to the text inputs not using FormFieldset yet, which is tracked in #263.

Copy link

@paulovmr paulovmr left a comment

Choose a reason for hiding this comment

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

Hi Hen, thanks for the changes! Just a minor change on the interface and component name there, and it looks good to me.

} from '@patternfly/react-core';
import { WorkspaceVolume } from '~/shared/types';

interface WorkspaceCreationPropertiesVolumes {

Choose a reason for hiding this comment

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

Suggested change
interface WorkspaceCreationPropertiesVolumes {
interface WorkspaceCreationPropertiesVolumesProps {

setVolumes: React.Dispatch<React.SetStateAction<WorkspaceVolume[]>>;
}

export const WorkspaceCreationPropertiesVolumesProps: React.FC<

Choose a reason for hiding this comment

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

Suggested change
export const WorkspaceCreationPropertiesVolumesProps: React.FC<
export const WorkspaceCreationPropertiesVolumes: React.FC<

}

export const WorkspaceCreationPropertiesVolumesProps: React.FC<
WorkspaceCreationPropertiesVolumes

Choose a reason for hiding this comment

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

Suggested change
WorkspaceCreationPropertiesVolumes
WorkspaceCreationPropertiesVolumesProps

Copy link

@paulovmr paulovmr left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

3 participants