1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Handle status values that contains an object (#693)

Signed-off-by: Trevor Nichols <trevor@theredfox.group>
Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Trevor Nichols 2020-08-20 00:49:17 +10:00 committed by GitHub
parent 0a5626fdb7
commit 905bbe9d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,11 +13,27 @@ import { apiManager } from "../../api/api-manager";
import { crdStore } from "./crd.store";
import { KubeObject } from "../../api/kube-object";
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
import { Input } from "../input";
// fixme: provide type-safe check for status
interface Props extends KubeObjectDetailsProps<KubeObject & { status: any }> {
}
function CrdColumnValue({ value }: { value: any[] | {} | string }) {
if (Array.isArray(value)) {
return <>{value.map((item, index) => <CrdColumnValue key={index} value={item} />)}</>
}
if (typeof(value) === 'object') return (
<Input
readOnly
multiLine
theme="round-black"
className="box grow"
value={JSON.stringify(value, null, 2)}
/>
);
return <span>{value}</span>;
}
@observer
export class CrdResourceDetails extends React.Component<Props> {
@computed get crd() {
@ -43,9 +59,10 @@ export class CrdResourceDetails extends React.Component<Props> {
<KubeObjectMeta object={object}/>
{extraColumns.map(column => {
const { name } = column;
const value = jsonPath.query(object, column.JSONPath.slice(1));
return (
<DrawerItem key={name} name={name}>
{jsonPath.query(object, column.JSONPath.slice(1))}
<CrdColumnValue value={value} />
</DrawerItem>
)
})}