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

Handle unnamed cluster event #497

Merged
merged 6 commits into from May 10, 2022
Merged

Handle unnamed cluster event #497

merged 6 commits into from May 10, 2022

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented May 5, 2022

Handle unnamed cluster (field Name coming empty in the cluster discovery event).
In the frontend, it shows a truncated version of the cluster id. I have chosen 14 chars length mostly for cosmetic reasons, as it is the length that better fits in the current views.

Here some pics:
Clusters view:
image

Cluster details view:
image
image

Hosts view:
image
image

@arbulu89 arbulu89 added the bug Something isn't working label May 5, 2022
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

The truncation logic can be revamped, other than that LGTM

Comment on lines 5 to 15
const truncatedLength = 14; // Using 14 as it cuts the uuid format after the 2nd -
export const getClusterName = (cluster) => {
return cluster?.name || cluster?.id.slice(0, truncatedLength) + '...';
};

const ClusterLink = ({ cluster }) => {
const clusterName = getClusterName(cluster);

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of just cutting this way, an alternative approach is letting the browser deal with this through the text-ellipsis class, you wanna try?

https://tailwindcss.com/docs/text-overflow#ellipsis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated here: e61e618

@arbulu89 arbulu89 marked this pull request as draft May 5, 2022 15:01
@arbulu89
Copy link
Contributor Author

arbulu89 commented May 5, 2022

Moving to draft. I have found a nasty bug. Even though the frontend is updated, the database is not, so in page refresh, the name goes back to the previous one apparently. Working on it

@arbulu89 arbulu89 force-pushed the handler-unnamed-cluster-event branch from 234c2b3 to e61e618 Compare May 6, 2022 11:37
@arbulu89 arbulu89 marked this pull request as ready for review May 6, 2022 11:39
@arbulu89 arbulu89 force-pushed the handler-unnamed-cluster-event branch from e61e618 to 2850cbf Compare May 6, 2022 11:50
Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

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

Nice job!

Here's a though about the UI of the cluster detail.

cluster-detail

If no cluster name has been detected, I'd consider:

  • showing something like N/A undefined or whatever else better comes to your mind
  • possibly add the full id in the details card (it would give a more comprehensive information about the resource, and maybe we could do the same in other pages)

No strong opinions here, just sharing some thoughts.

@@ -17,7 +17,7 @@ defmodule Trento.ClusterReadModel do
@derive {Jason.Encoder, except: [:__meta__, :__struct__]}
@primary_key {:id, :binary_id, autogenerate: false}
schema "clusters" do
field :name, :string
field :name, :string, default: ""
Copy link
Member

Choose a reason for hiding this comment

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

My ocd calls for a nil here. 😄
Would that make sense? And would it be possible or does it have to be an empty string because of ecto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't set the default value, when we get a nil value in the name field (which is the current scenario), it doesn't apply any change in the persistent storage, I guess because ecto works this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nelsonkopliku I will add some default value in the name field by now. Let's postpone the addition of the ID, as it would requires to change the nice 3x3 grid we have now, and I don't want to play with that by now hehe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we go (a434de3):
image

Copy link
Member

Choose a reason for hiding this comment

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

ok makes sense! Thanks!

@arbulu89 arbulu89 merged commit 51f6997 into main May 10, 2022
@arbulu89 arbulu89 deleted the handler-unnamed-cluster-event branch May 10, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

None yet

3 participants