-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/kubernetes' into kubernetes
- Loading branch information
Showing
20 changed files
with
996 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
assets/src/components/kubernetes/common/HorizontalPodAutoscalers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ReactElement } from 'react' | ||
import { Table } from '@pluralsh/design-system' | ||
import { createColumnHelper } from '@tanstack/react-table' | ||
import { Link } from 'react-router-dom' | ||
|
||
import { | ||
Horizontalpodautoscaler_HorizontalPodAutoscaler as HorizontalPodAutoscalerT, | ||
Maybe, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { DateTimeCol } from '../../utils/table/DateTimeCol' | ||
import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' | ||
import { InlineLink } from '../../utils/typography/InlineLink' | ||
import { useKubernetesCluster } from '../utils' | ||
import { ClusterTinyFragment } from '../../../generated/graphql' | ||
|
||
const columnHelper = createColumnHelper<HorizontalPodAutoscalerT>() | ||
|
||
const COLUMNS = [ | ||
columnHelper.accessor((hpa) => hpa?.objectMeta?.name, { | ||
id: 'name', | ||
header: 'Name', | ||
cell: ({ getValue }) => getValue(), | ||
}), | ||
columnHelper.accessor((hpa) => hpa?.minReplicas, { | ||
id: 'minreplicas', | ||
header: 'Min Replicas', | ||
cell: ({ getValue }) => getValue(), | ||
}), | ||
columnHelper.accessor((hpa) => hpa?.maxReplicas, { | ||
id: 'maxreplicas', | ||
header: 'Max Replicas', | ||
cell: ({ getValue }) => getValue(), | ||
}), | ||
columnHelper.accessor((hpa) => hpa, { | ||
id: 'reference', | ||
header: 'Reference', | ||
cell: ({ getValue, table }) => { | ||
const { cluster } = table.options.meta as { | ||
cluster?: ClusterTinyFragment | ||
} | ||
const hpa = getValue() | ||
const ref = hpa?.scaleTargetRef | ||
|
||
return ( | ||
<Link | ||
to={getResourceDetailsAbsPath( | ||
cluster?.id, | ||
ref?.kind?.toLowerCase(), | ||
ref?.name, | ||
hpa?.objectMeta?.namespace | ||
)} | ||
> | ||
<InlineLink>{ref?.name}</InlineLink> | ||
</Link> | ||
) | ||
}, | ||
}), | ||
columnHelper.accessor((hpa) => hpa?.objectMeta?.creationTimestamp, { | ||
id: 'creationTimestamp', | ||
header: 'Creation', | ||
enableSorting: true, | ||
cell: ({ getValue }) => <DateTimeCol date={getValue()} />, | ||
}), | ||
] | ||
|
||
interface HorizontalPodAutoscalersProps { | ||
hpas: Array<Maybe<HorizontalPodAutoscalerT>> | ||
} | ||
|
||
export default function HorizontalPodAutoscalers({ | ||
hpas, | ||
}: HorizontalPodAutoscalersProps): ReactElement { | ||
const cluster = useKubernetesCluster() | ||
|
||
return ( | ||
<Table | ||
data={hpas} | ||
columns={COLUMNS} | ||
reactTableOptions={{ meta: { cluster } }} | ||
css={{ | ||
maxHeight: '500px', | ||
height: '100%', | ||
}} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { ChipList } from '@pluralsh/design-system' | ||
|
||
import { V1_LabelSelector as LabelSelectorT } from '../../../generated/graphql-kubernetes' | ||
|
||
interface LabelSelectorProps { | ||
selector: LabelSelectorT | ||
} | ||
|
||
export function LabelSelector({ selector }: LabelSelectorProps): ReactNode { | ||
return ( | ||
<ChipList | ||
size="small" | ||
values={Object.entries(selector.matchLabels)} | ||
limit={3} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ReactNode, useMemo } from 'react' | ||
|
||
import { Common_PodInfo as PodInfoT } from '../../../generated/graphql-kubernetes' | ||
|
||
interface PodInfoProps { | ||
info: PodInfoT | ||
} | ||
|
||
export function PodInfo({ info }: PodInfoProps): ReactNode { | ||
return useMemo(() => { | ||
const running = info?.running ?? 0 | ||
const current = info?.current ?? 0 | ||
const succeeded = info?.succeeded ?? 0 | ||
const pending = info?.pending ?? 0 | ||
const failed = info?.failed ?? 0 | ||
const desired = info?.desired ?? 0 | ||
|
||
let result = '' | ||
|
||
if (running > 0) { | ||
result += `${running} Running /` | ||
} | ||
|
||
if (succeeded > 0) { | ||
result += `${succeeded} Succeeded / ` | ||
} | ||
|
||
if (pending > 0) { | ||
result += `${pending} Pending / ` | ||
} | ||
|
||
if (failed > 0) { | ||
result += `${failed} Failed / ` | ||
} | ||
|
||
result += ` ${current} Current / ` | ||
result += ` ${desired} Desired` | ||
|
||
return result | ||
}, [info]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.