Module: lib/util
Namespaces
Interfaces
Type aliases
DateFormatOptions
Ƭ DateFormatOptions: "brief"
| "mini"
Defined in
DateParam
Ƭ DateParam: string
| number
| Date
Defined in
Variables
CLUSTER_ACTION_GRACE_PERIOD
• CLUSTER_ACTION_GRACE_PERIOD: 5000
Defined in
Functions
compareUnits
▸ compareUnits(quantity1
, quantity2
): boolean
Parameters
Name | Type |
---|---|
quantity1 |
string |
quantity2 |
string |
Returns
boolean
Defined in
filterGeneric
▸ filterGeneric<T
>(item
, filter
, matchCriteria?
): boolean
Filters a generic item based on the filter state. The item is considered to match if any of the matchCriteria (described as JSONPath) matches the filter.search contents. Case matching is insensitive.
Type parameters
Name | Type |
---|---|
T |
extends Object = { [key: string] : any ; } |
Parameters
Name | Type | Description |
---|---|---|
item |
T |
The item to filter. |
filter |
FilterState
|
The filter state. |
matchCriteria? |
string [] |
The JSONPath criteria to match. |
Returns
boolean
Defined in
filterResource
▸ filterResource(item
, filter
, matchCriteria?
): boolean
Parameters
Name | Type |
---|---|
item |
KubeObjectInterface
|
KubeEvent
|
filter |
FilterState
|
matchCriteria? |
string [] |
Returns
boolean
Defined in
formatDuration
▸ formatDuration(duration
, options?
): string
Format a duration in milliseconds to a human-readable string.
Parameters
Name | Type | Description |
---|---|---|
duration |
number |
The duration in milliseconds. |
options |
TimeAgoOptions
|
format takes “brief” or “mini”. “brief” rounds the date and uses the largest suitable unit (e.g. “4 weeks”). “mini” uses something like “4w” (for 4 weeks). |
Returns
string
The formatted duration.
Defined in
getCluster
▸ getCluster(): string
| null
Returns
string
| null
Defined in
getClusterPrefixedPath
▸ getClusterPrefixedPath(path?
): string
Parameters
Name | Type |
---|---|
path? |
null | string |
Returns
string
Defined in
getPercentStr
▸ getPercentStr(value
, total
): null
| string
Parameters
Name | Type |
---|---|
value |
number |
total |
number |
Returns
null
| string
Defined in
getReadyReplicas
▸ getReadyReplicas(item
): any
Parameters
Name | Type |
---|---|
item |
Workload
|
Returns
any
Defined in
getResourceMetrics
▸ getResourceMetrics(item
, metrics
, resourceType
): any
[]
Parameters
Name | Type |
---|---|
item |
Node
|
metrics |
KubeMetrics
[] |
resourceType |
"cpu" | "memory" |
Returns
any
[]
Defined in
getResourceStr
▸ getResourceStr(value
, resourceType
): string
Parameters
Name | Type |
---|---|
value |
number |
resourceType |
"cpu" | "memory" |
Returns
string
Defined in
getTotalReplicas
▸ getTotalReplicas(item
): any
Parameters
Name | Type |
---|---|
item |
Workload
|
Returns
any
Defined in
localeDate
▸ localeDate(date
): string
Parameters
Name | Type |
---|---|
date |
DateParam
|
Returns
string
Defined in
normalizeUnit
▸ normalizeUnit(resourceType
, quantity
): string
Parameters
Name | Type |
---|---|
resourceType |
string |
quantity |
string |
Returns
string
Defined in
timeAgo
▸ timeAgo(date
, options?
): string
Show the time passed since the given date, in the desired format.
Parameters
Name | Type | Description |
---|---|---|
date |
DateParam
|
The date since which to calculate the duration. |
options |
TimeAgoOptions
|
format takes “brief” or “mini”. “brief” rounds the date and uses the largest suitable unit (e.g. “4 weeks”). “mini” uses something like “4w” (for 4 weeks). |
Returns
string
The formatted date.
Defined in
useErrorState
▸ useErrorState(dependentSetter?
): any
[]
Parameters
Name | Type |
---|---|
dependentSetter? |
(…args : any ) => void |
Returns
any
[]
Defined in
useFilterFunc
▸ useFilterFunc<T
>(matchCriteria?
): (item
: T
) => boolean
Type parameters
Name | Type |
---|---|
T |
extends
KubeObjectInterface
|
KubeEvent
| { [key: string] : any ; } =
KubeObjectInterface
|
KubeEvent
|
Parameters
Name | Type |
---|---|
matchCriteria? |
string [] |
Returns
fn
▸ (item
): boolean
Parameters
Name | Type |
---|---|
item |
T |
Returns
boolean
Defined in
useId
▸ useId(prefix?
): undefined
| string
Creates a unique ID, with the given prefix. If UNDER_TEST is set to true, it will return the same ID every time, so snapshots do not get invalidated.
Parameters
Name | Type | Default value |
---|---|---|
prefix |
string |
'' |
Returns
undefined
| string
Defined in
useURLState
▸ useURLState(key
, defaultValue
): [number
, React.Dispatch
<React.SetStateAction
<number
>>]
A hook to manage a state variable that is also stored in the URL.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The name of the key in the URL. If empty, then the hook behaves like useState. |
defaultValue |
number |
- |
Returns
[number
, React.Dispatch
<React.SetStateAction
<number
>>]
Defined in
▸ useURLState(key
, valueOrParams
): [number
, React.Dispatch
<React.SetStateAction
<number
>>]
A hook to manage a state variable that is also stored in the URL.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
The name of the key in the URL. If empty, then the hook behaves like useState. |
valueOrParams |
number | URLStateParams <number > |
- |
Returns
[number
, React.Dispatch
<React.SetStateAction
<number
>>]