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

frontend: Add create resource UI #1996

Merged
merged 2 commits into from
Dec 10, 2024
Merged

frontend: Add create resource UI #1996

merged 2 commits into from
Dec 10, 2024

Conversation

skoeva
Copy link
Contributor

@skoeva skoeva commented May 28, 2024

These changes introduce a new UI feature that allows users to create resources from the associated list view. Clicking the 'Create' button opens up the EditorDialog used in the generic 'Create / Apply' button, now accepting generic YAML/JSON text rather than explicitly expecting an item that looks like a Kubernetes resource. The dialog box also includes a generic template for each resource. The apply logic for this new feature (as well as the original 'Create / Apply' button) has been consolidated in EditorDialog, with a flag allowing external components to utilize their own dispatch functionality.

Fixes: #1820

Testing

Create resource button

  • Open a cluster in Headlamp (cd app & npm start) and navigate to a resource (e.g. Config Maps)
  • Click the + sign in the header and ensure the appropriate template appears in the editor
  • Apply changes and ensure the created resource appears in the list view

EditorDialog changes

  • Open Headlamp (cd app & npm start) and click the 'Create / Apply' button
  • Pass in a list of resources to the editor (e.g. a list of Config Maps)
  • Apply changes and ensure that all the resources in the list appear in the list view

Screenshots

image
image

@skoeva skoeva force-pushed the create-resource-ui branch 6 times, most recently from d1de90b to fe2cec7 Compare May 28, 2024 13:10
@skoeva skoeva marked this pull request as ready for review May 28, 2024 13:29
@skoeva skoeva requested a review from joaquimrocha May 28, 2024 13:29
@skoeva skoeva self-assigned this May 28, 2024
@skoeva skoeva added the frontend Issues related to the frontend label May 28, 2024
@ashu8912
Copy link
Member

These are some nice set of changes thanks @skoeva I was wandering what all resources we are covering to have the create resource button on?? And what is the reasoning behind adding it to some and not to others if that's the case?

@skoeva
Copy link
Contributor Author

skoeva commented Jun 10, 2024

These are some nice set of changes thanks @skoeva I was wandering what all resources we are covering to have the create resource button on?? And what is the reasoning behind adding it to some and not to others if that's the case?

@ashu8912 Currently covering config maps, secrets, leases, and runtime classes as those I already found with base templates in their associated directories, though if needed, we can add templates for more resources and cover those as well

Copy link
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

Nice work!

I left a few notes for your consideration.

As well as a CreateResourceButton.stories.tsx, maybe a few small pieces could be unit tested, and perhaps an e2e test would be useful for the overall feature?

(ps. it also needs rebasing against main now)
(pps. good work on adding the kube-ish function, we should validate the data matches what we're expecting a bit more... especially since we need to fix a bunch of types still)

@illume
Copy link
Collaborator

illume commented Jun 19, 2024

These are some nice set of changes thanks @skoeva I was wandering what all resources we are covering to have the create resource button on?? And what is the reasoning behind adding it to some and not to others if that's the case?

@ashu8912 Currently covering config maps, secrets, leases, and runtime classes as those I already found with base templates in their associated directories, though if needed, we can add templates for more resources and cover those as well

Probably you know this already... but the k8s website gives example yaml for each resource in their docs. But adding defaults for all the resources could be left for a future PR I reckon... it shouldn't block merging IMHO.

@illume illume marked this pull request as draft June 19, 2024 10:45
@skoeva skoeva force-pushed the create-resource-ui branch 2 times, most recently from 4fda387 to fe2cec7 Compare June 21, 2024 13:55
@skoeva skoeva force-pushed the create-resource-ui branch 5 times, most recently from 2af16dd to 205914c Compare June 27, 2024 18:20
@skoeva skoeva force-pushed the create-resource-ui branch from 2886872 to 51b00c8 Compare July 2, 2024 15:31
@skoeva skoeva force-pushed the create-resource-ui branch 3 times, most recently from ccb85e4 to 5268668 Compare July 8, 2024 14:18
frontend/src/components/configmap/List.tsx Outdated Show resolved Hide resolved
frontend/src/components/configmap/List.tsx Outdated Show resolved Hide resolved
frontend/src/components/common/CreateResourceButton.tsx Outdated Show resolved Hide resolved
@skoeva skoeva force-pushed the create-resource-ui branch 2 times, most recently from d3c178f to c0718f6 Compare October 25, 2024 15:41
@skoeva skoeva marked this pull request as ready for review October 25, 2024 15:59
@skoeva skoeva force-pushed the create-resource-ui branch 4 times, most recently from 0514bad to 4455ef0 Compare October 29, 2024 13:23
@skoeva skoeva force-pushed the create-resource-ui branch 2 times, most recently from 4200496 to 46f4e67 Compare November 12, 2024 14:57
Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

I have spotted something simple that needs to be improved in the code, but I have tested the feature again (creating a new item) and there's an inconsistency against the normal Create button:
When there's a failure to create a resource, the creation dialog should be brought back up again, and it's not in the case of this creation UI.

Steps to reproduce:

  1. Start creating a Node from the new + button
  2. Make sure you add an invalid name like my-super-node-
  3. Verify that it silently fails: no notification, and the dialog is not brought up. When then opening the dialog again, the error is there

frontend/src/components/common/Resource/CreateButton.tsx Outdated Show resolved Hide resolved
@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label Dec 6, 2024
@skoeva skoeva force-pushed the create-resource-ui branch from 46f4e67 to 45bf405 Compare December 6, 2024 18:35
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Dec 9, 2024
@skoeva skoeva force-pushed the create-resource-ui branch from f3c729d to 45bf405 Compare December 9, 2024 15:24
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 9, 2024
@skoeva skoeva force-pushed the create-resource-ui branch 2 times, most recently from b112193 to 1a8c04b Compare December 9, 2024 15:29
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Dec 9, 2024
@skoeva skoeva force-pushed the create-resource-ui branch from 1a8c04b to 46c0349 Compare December 9, 2024 15:34
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 10, 2024
These changes introduce a new UI feature that allows users to create
resources from the associated list view. Clicking the 'Create' button
opens up the EditorDialog used in the generic 'Create / Apply' button,
now accepting generic YAML/JSON text rather than explicitly expecting an
item that looks like a Kubernetes resource. The dialog box also includes
a generic template for each resource. The apply logic for this new
feature (as well as the original 'Create / Apply' button) has been
consolidated in EditorDialog, with a flag allowing external components
to utilize their own dispatch functionality.

Fixes: #1820

Signed-off-by: Evangelos Skopelitis <[email protected]>
@skoeva skoeva force-pushed the create-resource-ui branch from 46c0349 to 9f454b2 Compare December 10, 2024 16:45
@joaquimrocha joaquimrocha merged commit a11add3 into main Dec 10, 2024
17 of 18 checks passed
@joaquimrocha joaquimrocha deleted the create-resource-ui branch December 10, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Issues related to the frontend lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make create/editor dialog work with a given YAML/JSON
6 participants