@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
55 lines (54 loc) • 1.99 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useTranslation } from 'react-i18next';
import CreateResourceForm from '../common/Resource/CreateResourceForm';
/** Pod-specific creation form built on {@link CreateResourceForm}. Defines
* sections for metadata (name, namespace, labels), containers, and node
* scheduling. */
export default function CreatePodForm(props) {
const { resource, onChange } = props;
const { t } = useTranslation(['translation', 'glossary']);
const normalizedResource = resource ?? {};
const sections = [
{
title: t('translation|Metadata'),
fields: [
{ key: 'name', path: 'metadata.name', label: t('translation|Name'), required: true },
{
key: 'namespace',
path: 'metadata.namespace',
label: t('glossary|Namespace'),
type: 'namespace',
},
{
key: 'labels',
path: 'metadata.labels',
label: t('translation|Labels'),
type: 'labels',
},
],
},
{
title: t('translation|Spec'),
fields: [
{
key: 'containers',
path: 'spec.containers',
label: t('translation|Containers'),
type: 'containers',
},
],
},
{
title: t('translation|Node'),
fields: [
{
key: 'nodeName',
path: 'spec.nodeName',
label: t('translation|Node Name'),
helperText: t('translation|Optional: schedule the pod on a specific node'),
},
],
},
];
return (_jsx(CreateResourceForm, { sections: sections, resource: normalizedResource, onChange: onChange }));
}