-
Notifications
You must be signed in to change notification settings - Fork 151
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
base: main
Are you sure you want to change the base?
Conversation
d1de90b
to
fe2cec7
Compare
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 |
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.
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)
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. |
4fda387
to
fe2cec7
Compare
2af16dd
to
205914c
Compare
2886872
to
51b00c8
Compare
ccb85e4
to
5268668
Compare
5536809
to
ae5828a
Compare
cf4f9b1
to
e7d0024
Compare
Backend Code coverage changed from 53.2% to 53.4%. Change: .2% 😃. |
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.
Looks like there's some unrelated changes I think from a messed up merge in this PR.
c5e93f8
to
5f5599f
Compare
Backend Code coverage changed from 60.2% to 60.4%. Change: .2% 😃. |
ddd6c4a
to
664e8c1
Compare
664e8c1
to
63cb5cf
Compare
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.
Gave it another go. A few things need to be improved but is getting there.
|
||
const newItemDefs = obj!; | ||
|
||
if (!applyOnSave) { |
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.
Shouldn't this be if applyOnSave
is true? We are calling the apply function.
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 essentially checking whether or not to use an external dispatch (formerly called externalDispatch
). The name might be a bit confusing so I think it could be changed to something closer to what it was originally, but setting this to true means no dispatch is performed when creating a resource and 2 dispatches are performed when editing
frontend/src/lib/k8s/secret.ts
Outdated
static getBaseObject(): KubeSecret { | ||
const baseObject = super.getBaseObject() as KubeSecret; | ||
return { | ||
...baseObject, | ||
kind: Secret.kind, | ||
metadata: { ...baseObject.metadata, name: 'base-secret' }, | ||
}; | ||
} |
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 was hoping we could make things work without having to override this function everywhere (but only in cases where e.g. the objectName is not matching the kind).
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 imagine it makes more sense to keep the attributes (metadata, etc.) in each resource's respective file (meaning keeping this function override) over consolidating it all somehow in cluster.ts?
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.
What I mean is that I think there should be a way for us to have this logic abstract enough in the cluster.ts that it adapts correctly to most of the subclasses. We should definitely not move individual resources' logic into the cluster.ts file.
63cb5cf
to
4e3dbb1
Compare
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
4e3dbb1
to
134179c
Compare
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 <eskopelitis@microsoft.com>
6f3ad30
to
88d8c26
Compare
Backend Code coverage changed from 60.1% to 60.3%. Change: .2% 😃. Coverage report
|
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
cd app & npm start
) and navigate to a resource (e.g. Config Maps)EditorDialog changes
cd app & npm start
) and click the 'Create / Apply' buttonScreenshots