You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
Define a database route and api endpoint and its getters. Since database viewing is cluster specific, remember to pass in the clusterId to this route and endpoint.
services/database/ is a directory that contains all logic for retrieving/processing/typing response values from api:
Create a database class that will define a fetch method to get a list of all database servers for the specified clusterId.
The response value from the fetch method (or any api responses really) will need to be processed. The convention is to create a separate file named make.ts, and it will contain methods named makeXXX that will be responsible for processing the responses we get from api. There are variety of reasons why we want to process the response values:
Arrays may come as undefined and needs to be replaced with an empty array to avoid accessing undefined props errors.
Setting default values to objects if undefined
Sometimes json response contains field names containing underscore ie. expires_in. JS conventions dictates we use camelCase, so we can rename this field to expiresIn: json.expires_in
Sometimes with the response given, we want to add an extra field. For example, if the response value contained a field date: Date, and we wanted a formatted string version of this date, we can add a field dateText: stringValue (while keeping the original data). These text values often helps with table searching.
Sometimes we want to reformat the response value
All of the above helps create consistent responses sent to our components
Instantiate this class in our teleportContext.tsx file, so that children components can have access to it.
Test the class you made, to ensure the response received from api, is processed and formatted as you expected.
Table Cell formatting
Format the database columns protocol and type cells to the following:
Uh oh!
There was an error while loading. Please reload this page.
Define route, api endpoint, and service
In
config.ts
:route
andapi endpoint
and its getters. Since database viewing is cluster specific, remember to pass in theclusterId
to this route and endpoint.services/database/
is a directory that contains all logic for retrieving/processing/typing response values from api:make.ts
, and it will contain methods namedmakeXXX
that will be responsible for processing the responses we get from api. There are variety of reasons why we want to process the response values:undefined
and needs to be replaced with an empty array to avoid accessing undefined props errors.expires_in
. JS conventions dictates we use camelCase, so we can rename this field toexpiresIn: json.expires_in
date: Date
, and we wanted a formatted string version of this date, we can add a fielddateText: stringValue
(while keeping the original data). These text values often helps with table searching.teleportContext.tsx
file, so that children components can have access to it.Table Cell formatting
protocol
andtype
cells to the following:Protocol Formatting
Type Formatting
Mocked response
This is what response data would look like from the api
This is what data should look like after being processed:
Note
We won't be using this service until the next issue.
The text was updated successfully, but these errors were encountered: