refactor(meshes): refactor meshes to use our newer patterns #3233
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a little mix of things unfortunately, they are small things related to
meshes
refactoring, so happy to leave as is but would be fine to split smaller if thats preferred. The GH "Hide Whitespace" option is probably good for review.Collection/Table Loading:
We have this little 'wart' in quite a few places:
kuma-gui/packages/kuma-gui/src/app/meshes/views/MeshListView.vue
Line 36 in 765d9f5
Not only this but we have a lot of weirdness to support the fact that
KTable
is the only component we use that has its own loader embedded in it, for absolutely everything else we use DataLoader to provide loading states and loading visuals.I gave DataLoader a new
variant="default | list"
attribute, which is shorthand for avoiding providing a full#loading
slot to dataloader. By specifyinglist
you can tell it to use the exact same loader that KTable uses (KTable just uses<KSkeleton type="table" />
) so essentially<DataLoader variant="list" />
we replicate the exact same look=and-feel of KTable's loader, but we can also use it for other list type structures (that aren't KTables) if we need to.This also means that our listing pages work exactly the same as all our other pages. No weird
<template #loadable/>
things just to support the embedded loader inside KTable, and the 'wart' is gone 🎉I implemented this only in MeshList for the moment, with the plan to rollout in very near-future PRs.
This led me to realising I could upgrade a few more things in our
meshes/
module, so I did that while I was here:Other Upgrades
<div class="stack" />
to<XLayout type="stack" />
<KCard />
to<XCard />
div
s entirely.<div class="columns" />
which led me to do the next section:<XLayout type="columns" />
Still only 99% sure about XLayout, but I still prefer using it to
<div class="thing">
. I made a new layout type ofcolumns
and switched meshes to use that instead of the div. Its uses the exact same CSS.Lastly I wanted to point out that I really like the name
:variant
for an attribute that means "I choose this variable property". I've usedtype=""
in the past but found that in Vue this can clash with HTMLtype=""
and I fel back to use:action
which only worked as a good name for the specific usecase (I needed it for XAction).:variant
as a name would work in every case and would not clash with HTML at all. Nothing to do as yet, but as a nitty refactor PR at some point we might want to standardize on:variant
as a word and then make its usage consistent on all our components that use things like:type
or:action
.