import "./config-map-details.scss"; import React from "react"; import { autorun, observable } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { Trans } from "@lingui/macro"; import { DrawerTitle } from "../drawer"; import { Notifications } from "../notifications"; import { Input } from "../input"; import { Button } from "../button"; import { KubeEventDetails } from "../+events/kube-event-details"; import { configMapsStore } from "./config-maps.store"; import { KubeObjectDetailsProps } from "../kube-object"; import { ConfigMap } from "../../api/endpoints"; import { KubeObjectMeta } from "../kube-object/kube-object-meta"; import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry"; interface Props extends KubeObjectDetailsProps { } @observer export class ConfigMapDetails extends React.Component { @observable isSaving = false; @observable data = observable.map(); async componentDidMount() { disposeOnUnmount(this, [ autorun(() => { const { object: configMap } = this.props; if (configMap) { this.data.replace(configMap.data); // refresh } }) ]); } save = async () => { const { object: configMap } = this.props; try { this.isSaving = true; await configMapsStore.update(configMap, { ...configMap, data: this.data.toJSON() }); Notifications.ok(

ConfigMap {configMap.getName()} successfully updated.

); } finally { this.isSaving = false; } }; render() { const { object: configMap } = this.props; if (!configMap) return null; const data = Object.entries(this.data.toJSON()); return (
{ data.length > 0 && ( <> Data}/> { data.map(([name, value]) => { return (
{name}
this.data.set(name, v)} />
); }) }
); } } kubeObjectDetailRegistry.add({ kind: "ConfigMap", apiVersions: ["v1"], components: { Details: (props) => } }); kubeObjectDetailRegistry.add({ kind: "ConfigMap", apiVersions: ["v1"], priority: 5, components: { Details: (props) => } });