-
Notifications
You must be signed in to change notification settings - Fork 434
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
Feature/1269 add shortcut to tailwarden in inventory table #1306
Feature/1269 add shortcut to tailwarden in inventory table #1306
Conversation
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.
Hey, thank you for opening your Pull Request ! 🙂 While a Tailwarden team member takes a look at your PR we would like to invite you to join our official Discord server, where you can interact directly with other contributors and Tailwarden team members. Link here: https://discord.tailwarden.com
…n-inventory-table
…ble' of https://github.com/syedbarimanjan/komiser into feature/1269-Add-shortcut-to-Tailwarden-in-inventory-table
Co-authored-by: Azanul Haque <42029519+Azanul@users.noreply.github.com>
…ble' of https://github.com/syedbarimanjan/komiser into feature/1269-Add-shortcut-to-Tailwarden-in-inventory-table
@Azanul did the changes. |
@@ -0,0 +1,229 @@ | |||
// Define a union type for supported cloud providers. | |||
export type Providers = |
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.
Do you think having an api that returns the list of resources would be more better. I find this a bit redundant but open to discuss
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.
there is an api which returns the services/resources which the user has in the database I am utilizing it in the useInventory hook but the problem is how do we identify which one of those services which the user is using are not supported
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.
one thing we could do is that change the /services api to return an object which has the name of the service and then another property which indicates if it is supported or not
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.
@Azanul do you think we can keep the cost field in db as null? if yes will it be a good choice(I feel that would be costly!) the main reason I want to do this is because there is manual work in adding the names in frontend too and I want to keep this as separate. Thoughts?
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.
Indeed, that approach would work if the service/resource is not supported, the cost should be set to null. This way, we can then handle errors accordingly. But it would be hard to check if the service is supported or not and then setting the cost to null, and that might even have some manual work init.
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 think that should be a simple, we can convert the cost
field of Resource
schema to either be null or float value. This way we can have just call for resoources that have null value in it
ref: https://bun.uptrace.dev/guide/models.html#nulls
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 think that should be a simple, we can convert the
cost
field ofResource
schema to either be null or float value. This way we can have just call for resoources that have null value in it ref: https://bun.uptrace.dev/guide/models.html#nulls
Ok I will try to do this and can you confirm that are we using bun as an orm here and where should I start.
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.
here https://github.com/tailwarden/komiser/blob/develop/models/resource.go and you can use above link
@AllieMendes whats your take on above |
Hey everyone! The positioning is intentional and ties in with the layout we use at Tailwarden, which creates familiarity for similar features/information. It would be great if we could keep the original layout from the designs. |
…n-inventory-table
@Azanul could we merge this one? |
…n-inventory-table
Yes, another approval is needed |
I am working on implementing this the backend way as suggested by Avinesh but if this is all right then maybe I shouldn't? |
Although I agree with @AvineshTripathi, this PR looks good. We can work on the recommended changes on a different PR. |
I will INSHAALLAH commit the changes in some days. |
Can you just merge this one when I get time I will raise a new pr for implementing this the backend way. @mlabouardy |
…n-inventory-table
|
* feat: add service check helpers * feat(useInventory): track unsupported services state * feat(ui): enhance ui to reflect unsupported services * docs: update contributing guidelines * docs: update contributing guidelines * Update CONTRIBUTING.md * style: suggested changes Co-authored-by: Azanul Haque <42029519+Azanul@users.noreply.github.com> * fix: type error * style: add border radius --------- Co-authored-by: Azanul Haque <42029519+Azanul@users.noreply.github.com>
Problem
When a service is not supported, there is no interaction with the user, leading to confusion as the user may perceive the tool as broken. #1269
Solution
I created a
servicehelper
utility that stores all the providers and their services in an object. Two functions were implemented:1.
checkIfServiceIsSupported(provider: string, service: string): boolean
2.
checkIsSomeServiceUnavailable(receivedServices: string[]): boolean
In the
useInventory
hook, I added a new state to check if some service is unavailable. If there is something in thesearchedInventory
array, I loop over it and use the first function to check if even one element is not a supported service. If true, I set the state. If thesearchedInventory
is empty, I fetch all services from the API endpoint and use the second function to check if any service is not available. The result is set to the state.Finally, the state is returned from the
useInventory
hook, and in theInventoryPage
, it is destructured and passed to theInventoryStatsCard
. If the state is true, an error icon is displayed, and clicking on it redirects to the Tailwarden page for more information.Screenshots
Notes
I have updated the contributing guide to include a reminder for contributors to add any new provider or service to the list in the
serviceHelper
utility.Checklist
Reviewers
@Azanul @jakepage91 @mlabouardy @Traxmaxx @ShubhamPalriwala @AvineshTripathi @greghub