Module: lib/util

    Namespaces

    Interfaces

    Type aliases

    DateFormatOptions

    Ƭ DateFormatOptions: "brief" | "mini"

    Defined in

    lib/util.ts:32


    DateParam

    Ƭ DateParam: string | number | Date

    Defined in

    lib/util.ts:30

    Variables

    CLUSTER_ACTION_GRACE_PERIOD

    CLUSTER_ACTION_GRACE_PERIOD: 5000

    Defined in

    lib/util.ts:28

    Functions

    compareUnits

    compareUnits(quantity1, quantity2): boolean

    Parameters

    Name Type
    quantity1 string
    quantity2 string

    Returns

    boolean

    Defined in

    lib/util.ts:407


    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

    lib/util.ts:195


    filterResource

    filterResource(item, filter, matchCriteria?): boolean

    Parameters

    Name Type
    item KubeObjectInterface | KubeEvent
    filter FilterState
    matchCriteria? string[]

    Returns

    boolean

    Defined in

    lib/util.ts:152


    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

    lib/util.ts:64


    getCluster

    getCluster(): string | null

    Returns

    string | null

    Defined in

    lib/util.ts:262


    getClusterPrefixedPath

    getClusterPrefixedPath(path?): string

    Parameters

    Name Type
    path? null | string

    Returns

    string

    Defined in

    lib/util.ts:254


    getPercentStr

    getPercentStr(value, total): null | string

    Parameters

    Name Type
    value number
    total number

    Returns

    null | string

    Defined in

    lib/util.ts:101


    getReadyReplicas

    getReadyReplicas(item): any

    Parameters

    Name Type
    item Workload

    Returns

    any

    Defined in

    lib/util.ts:110


    getResourceMetrics

    getResourceMetrics(item, metrics, resourceType): any[]

    Parameters

    Name Type
    item Node
    metrics KubeMetrics []
    resourceType "cpu" | "memory"

    Returns

    any[]

    Defined in

    lib/util.ts:128


    getResourceStr

    getResourceStr(value, resourceType): string

    Parameters

    Name Type
    value number
    resourceType "cpu" | "memory"

    Returns

    string

    Defined in

    lib/util.ts:118


    getTotalReplicas

    getTotalReplicas(item): any

    Parameters

    Name Type
    item Workload

    Returns

    any

    Defined in

    lib/util.ts:114


    localeDate

    localeDate(date): string

    Parameters

    Name Type
    date DateParam

    Returns

    string

    Defined in

    lib/util.ts:84


    normalizeUnit

    normalizeUnit(resourceType, quantity): string

    Parameters

    Name Type
    resourceType string
    quantity string

    Returns

    string

    Defined in

    lib/util.ts:416


    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

    lib/util.ts:45


    useErrorState

    useErrorState(dependentSetter?): any[]

    Parameters

    Name Type
    dependentSetter? (…args: any) => void

    Returns

    any[]

    Defined in

    lib/util.ts:274


    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

    lib/util.ts:239


    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

    lib/util.ts:495


    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

    lib/util.ts:299

    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>>]

    Defined in

    lib/util.ts:303